- new config option
selfCloseTags
added which is used as an easier global setting to enable/disable self-closing tags.
- config option
contentMap
can now be passed to transform any XML content. For instance, if you want<a>null</a>
to instead appear as<a></a>
you pass incontentMap: (content) => { return content === null ? '' : content }
- fixed an issue with improper line breaks and indenting with null content
- BREAKING CHANGE: config option
attributesFilter
has been renamedattributeReplacements
- BREAKING CHANGE: config option
filter
has been renamedcontentReplacements
- CDATA blocks are now untouched (no HTML entity replacements) and unindented (#56)
true
attribute values can now be outputted by setting config optionattributeExplicitTrue: true
(#57)- attributes can now be filtered out by supplying a custom function to the new config option
attributeFilter
. For instance, to removenull
attribute values from the output, you can supply the config optionattributeFilter: (key, val) => val === null
(#58 and #10) devDependencies
: migrated frombabel-eslint
to@babel/eslint-parser
, migrated fromuglify-es
touglify-js
- Initial support for XML comments (#47)
- Fix for #48 (various 0-depth issues, bad "is output start" logic)
- New: automatic entity escaping for
&
,<
, and>
characters. In addition, quotes"
in attributes are also escaped (see #41). Prior to this, users had to provide their own filter manually. Note thatjstoxml
makes an effort not to escape entities that appear to have already been encoded, to prevent double-encoding issues.- E.g.
toXML({ foo: '1 < 2 & 2 > 1' }); // -> "<foo>1 < 2 & 2 > 1</foo>"
- To restore the default behavior from
v1.x.x
, simply pass infalse
tofilter
andattributesFilter
options:toXML({ foo: '1 < 2 & 2 > 1' }, { filter: false, attributesFilter: false }); // -> "<foo>1 < 2 & 2 > 1</foo>"
- E.g.
- fix for #40. Previously top-level objects and arrays were concatenated without proper line breaks.
- support for handling arrays of primitives, instead of simply concatenating #33
- restored
default
module export #31
- refactoring and cleanup
- Added support for attribute filtering (see Example 11b below).
- Complete rewrite! The code should now be easier to understand and maintain.
- now supports emoji/UTF8 tag attributes (needed for AMP pages - e.g.
<html ⚡ lang="en">
) (see example 14) - now supports duplicate attribute key names (see example 15)
- Fixed: functions returning objects now have now that output passed through toXML for XML conversion
- Fixed: empty text strings now properly output self-closing tags
- Migrated tests to mocha