Skip to content

Commit

Permalink
Add shadow root support. (tests broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jan 23, 2016
1 parent 6c4f5d5 commit 4b7da35
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/lib/template/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
},

detached: function() {
if (!this.parentNode || this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
if (!this.parentNode ||
(this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE &&
(!Polymer.Settings.hasShadow ||
!(this.parentNode instanceof ShadowRoot)))) {
this._teardownInstance();
}
},
Expand Down
28 changes: 27 additions & 1 deletion test/unit/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,40 @@

test('move into doc fragment', function(done) {
var el = shouldBeRemoved;
assert.equal(el.parentNode, removalContainer);
var frag = document.createDocumentFragment();
Polymer.dom(frag).appendChild(toBeRemoved);
setTimeout(function() {
assert.equal(el.parentNode, null);
done();
Polymer.dom(removalContainer).appendChild(frag);
setTimeout(function() {
assert.equal(shouldBeRemoved.parentNode, removalContainer);
done();
});
});
});

test('move into shadow root', function(done) {
if (Polymer.Settings.hasShadow) {
var el = shouldBeRemoved;
assert.equal(el.parentNode, removalContainer);
var div = document.createElement('div');
document.body.appendChild(div);
var frag = div.createShadowRoot();
Polymer.dom(frag).appendChild(toBeRemoved);
setTimeout(function() {
assert.equal(el.parentNode, null);
Polymer.dom(removalContainer).appendChild(frag);
setTimeout(function() {
assert.equal(shouldBeRemoved.parentNode, removalContainer);
done();
});
});
} else {
done();
}
});

});


Expand Down

0 comments on commit 4b7da35

Please sign in to comment.