mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Look up variable by name if not found by ID
This commit is contained in:
@@ -539,7 +539,13 @@ Blockly.Variables.getVariable = function(workspace, id, opt_name, opt_type) {
|
||||
if (!variable && potentialVariableMap) {
|
||||
variable = potentialVariableMap.getVariableById(id);
|
||||
}
|
||||
} else if (opt_name) {
|
||||
if (variable) {
|
||||
return variable;
|
||||
}
|
||||
}
|
||||
// If there was no ID, or there was an ID but it didn't match any variables,
|
||||
// look up by name and type.
|
||||
if (opt_name) {
|
||||
if (opt_type == undefined) {
|
||||
throw Error('Tried to look up a variable by name without a type');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user