Don't check typeof == undefined in variable deserialization (#1379)

This commit is contained in:
Rachel Fenichel
2017-10-23 11:28:00 -07:00
committed by GitHub
parent 2514976e80
commit bd1d199058

View File

@@ -498,7 +498,7 @@ Blockly.Xml.domToVariables = function(xmlVariables, workspace) {
var id = xmlChild.getAttribute('id');
var name = xmlChild.textContent;
if (typeof(type) === undefined || type === null) {
if (type == null) {
throw Error('Variable with id, ' + id + ' is without a type');
}
workspace.createVariable(name, type, id);
@@ -597,13 +597,11 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) {
variable = workspace.createVariable(text, type,
xmlChild.getAttribute(id));
}
if (typeof(type) !== undefined && type !== null) {
if (type !== variable.type) {
throw Error('Serialized variable type with id \'' +
variable.getId() + '\' had type ' + variable.type + ', and ' +
'does not match variable field that references it: ' +
Blockly.Xml.domToText(xmlChild) + '.');
}
if (type != null && type !== variable.type) {
throw Error('Serialized variable type with id \'' +
variable.getId() + '\' had type ' + variable.type + ', and ' +
'does not match variable field that references it: ' +
Blockly.Xml.domToText(xmlChild) + '.');
}
}
if (!field) {