Merge pull request #2526 from BeksOmega/fixes/FieldNameXML

Moved Serializing the Field's Name up to xml.js
This commit is contained in:
Rachel Fenichel
2019-05-31 10:31:00 -07:00
committed by GitHub
3 changed files with 1 additions and 2 deletions

View File

@@ -292,7 +292,6 @@ Blockly.Field.prototype.fromXml = function(fieldElement) {
* @package
*/
Blockly.Field.prototype.toXml = function(fieldElement) {
fieldElement.setAttribute('name', this.name);
fieldElement.textContent = this.getValue();
return fieldElement;
};

View File

@@ -151,7 +151,6 @@ Blockly.FieldVariable.prototype.toXml = function(fieldElement) {
// Make sure the variable is initialized.
this.initModel();
fieldElement.setAttribute('name', this.name);
fieldElement.setAttribute('id', this.variable_.getId());
fieldElement.textContent = this.variable_.name;
fieldElement.setAttribute('variableType', this.variable_.type);

View File

@@ -109,6 +109,7 @@ Blockly.Xml.blockToDomWithXY = function(block, opt_noId) {
Blockly.Xml.fieldToDom_ = function(field) {
if (field.isSerializable()) {
var container = Blockly.Xml.utils.createElement('field');
container.setAttribute('name', field.name);
return field.toXml(container);
}
return null;