Backward compatibility check for ‘variableType’

This commit is contained in:
Neil Fraser
2019-07-03 15:44:40 -07:00
committed by Neil Fraser
parent 52b6ce18a5
commit dd6cb19f5d

View File

@@ -125,7 +125,10 @@ Blockly.FieldVariable.prototype.initModel = function() {
Blockly.FieldVariable.prototype.fromXml = function(fieldElement) {
var id = fieldElement.getAttribute('id');
var variableName = fieldElement.textContent;
var variableType = fieldElement.getAttribute('variabletype') || '';
// 'variabletype' should be lowercase, but until July 2019 it was sometimes
// recorded as 'variableType'. Thus we need to check for both.
var variableType = fieldElement.getAttribute('variabletype') ||
fieldElement.getAttribute('variableType') || '';
var variable = Blockly.Variables.getOrCreateVariablePackage(
this.workspace_, id, variableName, variableType);