From 4a94dc8a85b90b61d678977849250ac29eb5d627 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Mon, 27 Jan 2020 15:32:12 -0800 Subject: [PATCH] Unpack self-closing tags when converting domToText (#3665) * Unpack self-closing tags when converting domToText --- core/xml.js | 4 +++- demos/blockfactory/workspacefactory/wfactory_controller.js | 4 ---- tests/jsunit/xml_test.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/xml.js b/core/xml.js index a1a4dd970..86d60b1c3 100644 --- a/core/xml.js +++ b/core/xml.js @@ -303,7 +303,9 @@ Blockly.Xml.domToText = function(dom) { oldText = text; text = text.replace(regexp, '$1 $2'); } while (text != oldText); - return text; + // Unpack self-closing tags. These tags fail when embedded in HTML. + // -> + return text.replace(/<(\w+)([^<]*)\/>/g, '<$1$2>'); }; /** diff --git a/demos/blockfactory/workspacefactory/wfactory_controller.js b/demos/blockfactory/workspacefactory/wfactory_controller.js index 30f032eae..b3a6ecbbe 100644 --- a/demos/blockfactory/workspacefactory/wfactory_controller.js +++ b/demos/blockfactory/workspacefactory/wfactory_controller.js @@ -340,10 +340,6 @@ WorkspaceFactoryController.prototype.exportXmlFile = function(exportMode) { throw Error(msg); } - // Unpack self-closing tags. These tags fail when embedded in HTML. - // -> - configXml = configXml.replace(/<(\w+)([^<]*)\/>/g, '<$1$2>'); - // Download file. var data = new Blob([configXml], {type: 'text/xml'}); this.view.createAndDownloadFile(fileName, data); diff --git a/tests/jsunit/xml_test.js b/tests/jsunit/xml_test.js index afd3dc9c7..2baff16c4 100644 --- a/tests/jsunit/xml_test.js +++ b/tests/jsunit/xml_test.js @@ -29,7 +29,7 @@ var XML_TEXT = ['', ' ', ' item', ' ', - ' ', + ' ', ' ', ' ', ' ',