From bea1569c9d38d5a5a9a43b7473857ddec8576f1c Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Thu, 2 Feb 2023 12:44:03 +0900 Subject: [PATCH] fix bug for missing space for (preverseWhitespace = true) --- src/wsdl/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wsdl/index.ts b/src/wsdl/index.ts index 48b182f32..774785845 100644 --- a/src/wsdl/index.ts +++ b/src/wsdl/index.ts @@ -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) { @@ -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;