Unpack self-closing tags when converting domToText (#3665)

* Unpack self-closing tags when converting domToText
This commit is contained in:
Sam El-Husseini
2020-01-27 15:32:12 -08:00
committed by GitHub
parent 6dbb023a1d
commit 4a94dc8a85
3 changed files with 4 additions and 6 deletions

View File

@@ -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.
// <block name="foo"/> -> <block name="foo"></block>
return text.replace(/<(\w+)([^<]*)\/>/g, '<$1$2></$1>');
};
/**

View File

@@ -340,10 +340,6 @@ WorkspaceFactoryController.prototype.exportXmlFile = function(exportMode) {
throw Error(msg);
}
// Unpack self-closing tags. These tags fail when embedded in HTML.
// <block name="foo"/> -> <block name="foo"></block>
configXml = configXml.replace(/<(\w+)([^<]*)\/>/g, '<$1$2></$1>');
// Download file.
var data = new Blob([configXml], {type: 'text/xml'});
this.view.createAndDownloadFile(fileName, data);

View File

@@ -29,7 +29,7 @@ var XML_TEXT = ['<xml xmlns="https://developers.google.com/blockly/xml">',
' <block type="variables_set" inline="true">',
' <field name="VAR">item</field>',
' <value name="VALUE">',
' <block type="lists_create_empty" />',
' <block type="lists_create_empty"></block>',
' </value>',
' <next>',
' <block type="text_print" inline="false">',