Warn conflicts with Blockly.Generator.prototype (#1603)

Console warning if block prototypeName conflicts with Blockly.Generator.prototype.
This commit is contained in:
Andrew n marshall
2018-02-12 13:44:54 -08:00
committed by GitHub
parent 03538c19a7
commit dc7783ee01
2 changed files with 33 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ goog.require('Blockly.Blocks');
goog.require('Blockly.Comment');
goog.require('Blockly.Connection');
goog.require('Blockly.Extensions');
goog.require('Blockly.Generator');
goog.require('Blockly.Input');
goog.require('Blockly.Mutator');
goog.require('Blockly.Warning');
@@ -52,6 +53,14 @@ goog.require('goog.string');
* @constructor
*/
Blockly.Block = function(workspace, prototypeName, opt_id) {
if (typeof Blockly.Generator.prototype[prototypeName] !== 'undefined') {
console.warn('FUTURE ERROR: Block prototypeName "' + prototypeName
+ '" conflicts with Blockly.Generator members. Registering Generators '
+ 'for this block type will incur errors.'
+ '\nThis name will be DISALLOWED (throwing an error) in future '
+ 'versions of Blockly.');
}
/** @type {string} */
this.id = (opt_id && !workspace.getBlockById(opt_id)) ?
opt_id : Blockly.utils.genUid();