Skip to content

Commit

Permalink
preserve white for space only text node: <text> </text>
Browse files Browse the repository at this point in the history
  • Loading branch information
yffrankwang committed Feb 3, 2023
1 parent 4660fa2 commit 36aaea7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/wsdl/index.ts
Expand Up @@ -356,7 +356,9 @@ export class WSDL {
const name = splitQName(nsName).name;

if (typeof cur.schema === 'string' && (cur.schema === 'string' || cur.schema.split(':')[1] === 'string')) {
if (typeof obj === 'object' && Object.keys(obj).length === 0) { obj = cur.object = ''; }
if (typeof obj === 'object' && Object.keys(obj).length === 0) {
obj = cur.object = (this.options.preserveWhitespace ? cur.text || '' : '');
}
}

if (cur.nil === true) {
Expand Down Expand Up @@ -423,13 +425,17 @@ export class WSDL {
};

p.ontext = (text) => {
const top = stack[stack.length - 1];

const originalText = text;
text = trim(text);
if (!text.length) {
if (this.options.preserveWhitespace) {
top.text = (top.text || '') + originalText;
}
return;
}

const top = stack[stack.length - 1];
const name = splitQName(top.schema).name;
let value;

Expand Down

0 comments on commit 36aaea7

Please sign in to comment.