diff --git a/lib/parser.js b/lib/parser.js index eda231cb..e4b8bbf0 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -182,7 +182,7 @@ delete obj.cdata; } s = stack[stack.length - 1]; - if (obj[charkey].match(/^\s*$/) && !cdata) { + if (obj[charkey].match(/^\s*$/) && !cdata && !_this.options.includeWhiteChars) { emptyStr = obj[charkey]; delete obj[charkey]; } else { diff --git a/src/parser.coffee b/src/parser.coffee index eb19c5b0..45fb6218 100644 --- a/src/parser.coffee +++ b/src/parser.coffee @@ -132,7 +132,7 @@ class exports.Parser extends events s = stack[stack.length - 1] # remove the '#' key altogether if it's blank - if obj[charkey].match(/^\s*$/) and not cdata + if obj[charkey].match(/^\s*$/) and not cdata and not @options.includeWhiteChars emptyStr = obj[charkey] delete obj[charkey] else