Closed soulchild closed 2 years ago
Is the following supposed to still leave bla="undefined" in the resulting XML when an attribute is undefined within an @ object? I was expecting the typeHandler to remove the attribute altogether, like in the second example.
bla="undefined"
@
const { parse, Absent } = require('js2xmlparser'); const opts = { format: { pretty: true, doubleQuotes: true, }, typeHandlers: { '[object Undefined]': () => Absent.instance, }, }; console.log( parse( 'Foo', { foo: { '@': { bla: undefined, }, }, }, opts, ), ); // <?xml version="1.0"?> // <Foo> // <foo bla="undefined"/> // </Foo> console.log( parse( 'Foo', { foo: { bla: undefined, }, }, opts, ), ); // <?xml version="1.0"?> // <Foo> // <foo/> // </Foo>
This is what I would expect as well. I will fix this in the next major release.
Works perfectly! Thanks @michaelkourlas!
Is the following supposed to still leave
bla="undefined"
in the resulting XML when an attribute is undefined within an@
object? I was expecting the typeHandler to remove the attribute altogether, like in the second example.