Allow inheriting of fromJson in fields

This commit is contained in:
Neil Fraser
2021-06-30 12:00:33 -07:00
committed by Neil Fraser
parent 6ccff4431d
commit cba7a68207
12 changed files with 42 additions and 13 deletions

View File

@@ -135,7 +135,9 @@ Blockly.FieldAngle.prototype.DEFAULT_VALUE = 0;
* @nocollapse
*/
Blockly.FieldAngle.fromJson = function(options) {
return new Blockly.FieldAngle(options['angle'], undefined, options);
// `this` might be a subclass of FieldAngle if that class doesn't override
// the static fromJson method.
return new this(options['angle'], undefined, options);
};
/**