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>$1>');
};
/**
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>$1>');
-
// 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',
' ',
- ' ',
+ ' ',
' ',
' ',
' ',