Merge pull request #4766 from moniika/develop

Cherrypick (#4758)
This commit is contained in:
Monica Kozbial
2021-04-08 16:13:05 -07:00
committed by GitHub
2 changed files with 12 additions and 13 deletions

View File

@@ -15,7 +15,6 @@
*/
'use strict';
goog.provide('Blockly.Blocks.lists'); // Deprecated
goog.provide('Blockly.Constants.Lists');
goog.require('Blockly');

View File

@@ -88,7 +88,7 @@ Blockly.Events.BlockBase.prototype.fromJson = function(json) {
* @extends {Blockly.Events.BlockBase}
* @constructor
*/
Blockly.Events.Change = function(opt_block, opt_element, opt_name, opt_oldValue,
Blockly.Events.BlockChange = function(opt_block, opt_element, opt_name, opt_oldValue,
opt_newValue) {
Blockly.Events.Change.superClass_.constructor.call(this, opt_block);
if (!opt_block) {
@@ -99,7 +99,7 @@ Blockly.Events.Change = function(opt_block, opt_element, opt_name, opt_oldValue,
this.oldValue = typeof opt_oldValue == 'undefined' ? '' : opt_oldValue;
this.newValue = typeof opt_newValue == 'undefined' ? '' : opt_newValue;
};
Blockly.utils.object.inherits(Blockly.Events.Change, Blockly.Events.BlockBase);
Blockly.utils.object.inherits(Blockly.Events.BlockChange, Blockly.Events.BlockBase);
/**
* Class for a block change event.
@@ -112,20 +112,20 @@ Blockly.utils.object.inherits(Blockly.Events.Change, Blockly.Events.BlockBase);
* @extends {Blockly.Events.BlockBase}
* @constructor
*/
Blockly.Events.BlockChange = Blockly.Events.Change;
Blockly.Events.Change = Blockly.Events.BlockChange;
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Change.prototype.type = Blockly.Events.CHANGE;
Blockly.Events.BlockChange.prototype.type = Blockly.Events.CHANGE;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Change.prototype.toJson = function() {
var json = Blockly.Events.Change.superClass_.toJson.call(this);
Blockly.Events.BlockChange.prototype.toJson = function() {
var json = Blockly.Events.BlockChange.superClass_.toJson.call(this);
json['element'] = this.element;
if (this.name) {
json['name'] = this.name;
@@ -139,8 +139,8 @@ Blockly.Events.Change.prototype.toJson = function() {
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.Change.prototype.fromJson = function(json) {
Blockly.Events.Change.superClass_.fromJson.call(this, json);
Blockly.Events.BlockChange.prototype.fromJson = function(json) {
Blockly.Events.BlockChange.superClass_.fromJson.call(this, json);
this.element = json['element'];
this.name = json['name'];
this.oldValue = json['oldValue'];
@@ -151,7 +151,7 @@ Blockly.Events.Change.prototype.fromJson = function(json) {
* Does this event record any change of state?
* @return {boolean} False if something changed.
*/
Blockly.Events.Change.prototype.isNull = function() {
Blockly.Events.BlockChange.prototype.isNull = function() {
return this.oldValue == this.newValue;
};
@@ -159,7 +159,7 @@ Blockly.Events.Change.prototype.isNull = function() {
* Run a change event.
* @param {boolean} forward True if run forward, false if run backward (undo).
*/
Blockly.Events.Change.prototype.run = function(forward) {
Blockly.Events.BlockChange.prototype.run = function(forward) {
var workspace = this.getEventWorkspace_();
var block = workspace.getBlockById(this.blockId);
if (!block) {
@@ -202,7 +202,7 @@ Blockly.Events.Change.prototype.run = function(forward) {
var dom = Blockly.Xml.textToDom(/** @type {string} */ (value) || '<mutation/>');
block.domToMutation(dom);
}
Blockly.Events.fire(new (Blockly.Events.get(Blockly.Events.CHANGE))(
Blockly.Events.fire(new Blockly.Events.BlockChange(
block, 'mutation', null, oldMutation, value));
break;
default:
@@ -568,6 +568,6 @@ Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.CREATE,
Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.DELETE,
Blockly.Events.Delete);
Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.CHANGE,
Blockly.Events.Change);
Blockly.Events.BlockChange);
Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.MOVE,
Blockly.Events.Move);