Use instanceof to distinguish between blocks and workspaces.

This commit is contained in:
Rachel Fenichel 2016-07-13 12:50:44 -07:00
parent 3f0b2961a1
commit 75e06de477

View file

@ -44,7 +44,7 @@ Blockly.Variables.NAME_TYPE = 'VARIABLE';
*/
Blockly.Variables.allUsedVariables = function(root) {
var blocks;
if (root.getDescendants) {
if (root instanceof Blockly.Block) {
// Root is Block.
blocks = root.getDescendants();
} else if (root.getAllBlocks) {
@ -82,7 +82,7 @@ Blockly.Variables.allUsedVariables = function(root) {
* @return {!Array.<string>} Array of variable names.
*/
Blockly.Variables.allVariables = function(root) {
if (root.getDescendants) {
if (root instanceof Blockly.Block) {
// Root is Block.
console.warn('Deprecated call to Blockly.Variables.allVariables ' +
'with a block instead of a workspace. You may want ' +