mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907)
Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities.
This commit is contained in:
committed by
GitHub
parent
ec878b02cd
commit
15827c5d30
@@ -467,7 +467,7 @@ Blockly.Extensions.register("math_is_divisibleby_mutator",
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
function() {
|
||||
goog.mixin(this, Blockly.Blocks.math.IS_DIVISIBLEBY_MUTATOR_MIXIN_);
|
||||
this.mixin(Blockly.Blocks.math.IS_DIVISIBLEBY_MUTATOR_MIXIN_);
|
||||
this.getField('PROPERTY').setValidator(function(option) {
|
||||
var divisorInput = (option == 'DIVISIBLE_BY');
|
||||
this.sourceBlock_.updateShape_(divisorInput);
|
||||
@@ -526,9 +526,8 @@ Blockly.Extensions.register("math_modes_of_list_mutator",
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
function() {
|
||||
var thisBlock = this;
|
||||
goog.mixin(this, Blockly.Blocks.math.LIST_MODES_MUTATOR_MIXIN_);
|
||||
this.mixin(Blockly.Blocks.math.LIST_MODES_MUTATOR_MIXIN_);
|
||||
this.getField('OP').setValidator(function(newOp) {
|
||||
thisBlock.updateType_(newOp);
|
||||
});
|
||||
this.updateType_(newOp);
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user