Permalink
Browse files

Document skipNullAttributes

  • Loading branch information...
oozcitak committed Apr 27, 2018
1 parent 225061a commit ce823e9e1b629d5afc2dfe5aaed7de46b999e3ba
Showing with 10 additions and 1 deletion.
  1. +2 −0 src/XMLDocument.coffee
  2. +5 −0 src/XMLDocumentCB.coffee
  3. +1 −1 src/XMLDummy.coffee
  4. +2 −0 src/index.coffee
View
@@ -10,6 +10,8 @@ module.exports = class XMLDocument extends XMLNode
# Initializes a new instance of `XMLDocument`
#
+ # `options.skipNullValues` whether nodes with null values will be ignored:
+ # true or false
# `options.skipNullAttributes` whether attributes with null values will be
# ignored: true or false
# `options.ignoreDecorators` whether decorator strings will be ignored when
View
@@ -26,6 +26,8 @@ module.exports = class XMLDocumentCB
# Initializes a new instance of `XMLDocumentCB`
#
+ # `options.skipNullValues` whether nodes with null values will be ignored:
+ # true or false
# `options.skipNullAttributes` whether attributes with null values will be
# ignored: true or false
# `options.ignoreDecorators` whether decorator strings will be ignored when
@@ -86,6 +88,9 @@ module.exports = class XMLDocumentCB
name = getValue name
+ if attributes == null and not text?
+ [attributes, text] = [{}, null]
+
attributes ?= {}
attributes = getValue attributes
# swap argument order: text <-> attributes
View
@@ -8,7 +8,7 @@ module.exports = class XMLDummy extends XMLNode
#
# `XMLDummy` is a special node representing a node with
# a null value. Dummy nodes are created while recursively
- # building the XML tree. Simple skipping null values doesn't
+ # building the XML tree. Simply skipping null values doesn't
# work because that would break the recursive chain.
constructor: (parent) ->
super parent
View
@@ -19,6 +19,8 @@ XMLStreamWriter = require './XMLStreamWriter'
#
# `options.headless` whether XML declaration and doctype will be included:
# true or false
+ # `options.skipNullValues` whether nodes with null values will be ignored:
+ # true or false
# `options.skipNullAttributes` whether attributes with null values will be
# ignored: true or false
# `options.ignoreDecorators` whether decorator strings will be ignored when

0 comments on commit ce823e9

Please sign in to comment.