Added disposed = false properties to fields, connections, and blocks. Changed applicable unit tests from isNotOk -> isFalse.

This commit is contained in:
Beka Westberg
2019-08-07 07:17:41 -07:00
parent 6f03634730
commit 654467e9ac
5 changed files with 27 additions and 6 deletions

View File

@@ -226,6 +226,13 @@ Blockly.Block.obtain = function(workspace, prototypeName) {
*/
Blockly.Block.prototype.data = null;
/**
* Has this block been disposed of?
* @type {boolean}
* @package
*/
Blockly.Block.prototype.disposed = false;
/**
* Colour of the block as HSV hue value (0-360)
* This may be null if the block colour was not set via a hue number.

View File

@@ -71,6 +71,13 @@ Blockly.Connection.REASON_SHADOW_PARENT = 6;
*/
Blockly.Connection.prototype.targetConnection = null;
/**
* Has this connection been disposed of?
* @type {boolean}
* @package
*/
Blockly.Connection.prototype.disposed = false;
/**
* List of compatible value types. Null if all types are compatible.
* @type {Array}

View File

@@ -149,6 +149,7 @@ Blockly.Field.X_PADDING = 10;
* @type {[type]}
*/
Blockly.Field.DEFAULT_TEXT_OFFSET = Blockly.Field.X_PADDING / 2;
/**
* Name of field. Unique within each block.
* Static labels are usually unnamed.
@@ -156,6 +157,13 @@ Blockly.Field.DEFAULT_TEXT_OFFSET = Blockly.Field.X_PADDING / 2;
*/
Blockly.Field.prototype.name = undefined;
/**
* Has this field been disposed of?
* @type {boolean}
* @package
*/
Blockly.Field.prototype.disposed = false;
/**
* Maximum characters of text to display before adding an ellipsis.
* @type {number}

View File

@@ -190,7 +190,7 @@ suite('Blocks', function() {
});
suite('Dispose', function() {
function assertDisposedNoheal(blocks) {
chai.assert.isNotOk(blocks.A.disposed);
chai.assert.isFalse(blocks.A.disposed);
// A has nothing connected to it.
chai.assert.equal(0, blocks.A.getChildren().length);
// B is disposed.
@@ -199,8 +199,8 @@ suite('Blocks', function() {
chai.assert.isTrue(blocks.C.disposed);
}
function assertDisposedHealed(blocks) {
chai.assert.isNotOk(blocks.A.disposed);
chai.assert.isNotOk(blocks.C.disposed);
chai.assert.isFalse(blocks.A.disposed);
chai.assert.isFalse(blocks.C.disposed);
// A and C are connected.
assertEquals(1, blocks.A.getChildren().length);
assertEquals(blocks.A, blocks.C.getParent());
@@ -371,7 +371,7 @@ suite('Blocks', function() {
.connect(blockB.outputConnection);
this.blockA.removeInput('VALUE');
chai.assert.isNotOk(blockB.disposed);
chai.assert.isFalse(blockB.disposed);
chai.assert.equal(this.blockA.getChildren().length, 0);
});
test('Shadow Connected', function() {
@@ -400,7 +400,7 @@ suite('Blocks', function() {
.connect(blockB.previousConnection);
this.blockA.removeInput('STATEMENT');
chai.assert.isNotOk(blockB.disposed);
chai.assert.isFalse(blockB.disposed);
chai.assert.equal(this.blockA.getChildren().length, 0);
});
test('Shadow Connected', function() {

View File

@@ -20,7 +20,6 @@
suite('Connections', function() {
suite.skip('Rendered', function() {
function assertAllConnectionsHiddenState(block, hidden) {
var connections = block.getConnections_(true);