Skip to content

Commit

Permalink
fix bug for missing space for <text> </text> (preverseWhitespace = true)
Browse files Browse the repository at this point in the history
  • Loading branch information
yffrankwang committed Feb 3, 2023
1 parent 4660fa2 commit bea1569
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/wsdl/index.ts
Original file line number Diff line number Diff line change
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 || '') + text;
}
return;
}

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

Expand Down

0 comments on commit bea1569

Please sign in to comment.