mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
Warn conflicts with Blockly.Generator.prototype (#1603)
Console warning if block prototypeName conflicts with Blockly.Generator.prototype.
This commit is contained in:
committed by
GitHub
parent
03538c19a7
commit
dc7783ee01
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user