From be5e02580181bdc95e164c682ec8844d9879faf2 Mon Sep 17 00:00:00 2001 From: Felix Kirchengast Date: Wed, 21 Oct 2020 11:58:28 +0200 Subject: [PATCH] Fix includeWhiteChars option --- lib/parser.js | 2 +- src/parser.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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