Fixed comments in trashcan.

This commit is contained in:
Beka Westberg
2019-10-15 07:22:57 -07:00
committed by Neil Fraser
parent b2a8172720
commit 8f73fdb512
2 changed files with 12 additions and 7 deletions

View File

@@ -497,6 +497,11 @@ Blockly.Trashcan.prototype.cleanBlockXML_ = function(xml) {
node.removeAttribute('y');
node.removeAttribute('id');
node.removeAttribute('disabled');
if (node.nodeName == 'comment') { // Future proof just in case.
node.removeAttribute('h');
node.removeAttribute('w');
node.removeAttribute('pinned');
}
}
// Try to go down the tree

View File

@@ -102,7 +102,9 @@ suite("Trashcan", function() {
test("No Disabled - Disabled True", function() {
sendDeleteEvent('<block type="dummy_type"/>');
sendDeleteEvent('<block type="dummy_type" disabled="true"/>');
chai.assert.equal(this.trashcan.contents_.length, 2);
// Disabled tags get removed because disabled blocks aren't allowed to
// be dragged from flyouts. See #2239 and #3243.
chai.assert.equal(this.trashcan.contents_.length, 1);
});
test("No Editable - Editable False", function() {
sendDeleteEvent('<block type="dummy_type"/>');
@@ -244,9 +246,8 @@ suite("Trashcan", function() {
' <comment h="20" w="20">comment_text</comment>' +
'</block>'
);
// TODO (#2574): These blocks are treated as different, but appear
// identical when the trashcan is opened.
chai.assert.equal(this.trashcan.contents_.length, 2);
// h & w tags are removed b/c the blocks appear the same.
chai.assert.equal(this.trashcan.contents_.length, 1);
});
test("Different Comment Pinned", function() {
sendDeleteEvent(
@@ -259,9 +260,8 @@ suite("Trashcan", function() {
' <comment pinned="true">comment_text</comment>' +
'</block>'
);
// TODO (#2574): These blocks are treated as different, but appear
// identical when the trashcan is opened.
chai.assert.equal(this.trashcan.contents_.length, 2);
// pinned tags are removed b/c the blocks appear the same.
chai.assert.equal(this.trashcan.contents_.length, 1);
});
test("No Mutator - Mutator", function() {
sendDeleteEvent('<block type="dummy_type"/>');