Skip to content

Commit

Permalink
Fixes: #1907
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Jun 24, 2015
1 parent ab8c285 commit 9dd38f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/dom-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@
toggle: function() {
this.node.classList.toggle.apply(this.node.classList, arguments);
this.domApi._distributeParent();
},
contains: function() {
return this.node.classList.contains.apply(this.node.classList,
arguments);
}
}

Expand Down
12 changes: 11 additions & 1 deletion test/unit/polymer-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ suite('Polymer.dom', function() {
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), []);
});

test('Polymer.dom.classListAdd/Remove/Toggle (reproject)', function() {
test('Polymer.dom.classListAdd/Remove/Toggle/Contains (reproject)', function() {
var select = document.querySelector('x-select-class1');
var child = Polymer.dom(select).firstElementChild;
var c1 = Polymer.dom(select.root).querySelector('content');
Expand All @@ -203,31 +203,41 @@ suite('Polymer.dom', function() {
var ip$ = [c1, c2, c3];
assert.equal(Polymer.dom(child).getDestinationInsertionPoints().length, 0);
Polymer.dom(child).classList.add('s1');
assert.isTrue(Polymer.dom(child).classList.contains('s1'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1]);
Polymer.dom(child).classList.add('s2');
assert.isTrue(Polymer.dom(child).classList.contains('s2'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1, c2]);
Polymer.dom(child).classList.add('s3');
assert.isTrue(Polymer.dom(child).classList.contains('s3'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1, c2, c3]);
Polymer.dom(child).classList.toggle('s1');
assert.isFalse(Polymer.dom(child).classList.contains('s1'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), []);
Polymer.dom(child).classList.toggle('s1');
assert.isTrue(Polymer.dom(child).classList.contains('s1'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1, c2, c3]);
Polymer.dom(child).classList.remove('s2');
assert.isFalse(Polymer.dom(child).classList.contains('s2'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1]);
Polymer.dom(child).classList.toggle('s2');
assert.isTrue(Polymer.dom(child).classList.contains('s2'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1, c2, c3]);
Polymer.dom(child).classList.remove('s3');
assert.isFalse(Polymer.dom(child).classList.contains('s3'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), [c1, c2]);
Polymer.dom(child).classList.remove('s2');
Polymer.dom(child).classList.remove('s1');
assert.isFalse(Polymer.dom(child).classList.contains('s2'));
assert.isFalse(Polymer.dom(child).classList.contains('s1'));
Polymer.dom.flush();
assert.deepEqual(Polymer.dom(child).getDestinationInsertionPoints(), []);
});
Expand Down

0 comments on commit 9dd38f6

Please sign in to comment.