Add shadow root support. (tests broken)

This commit is contained in:
Kevin Schaaf 2016-01-22 19:55:52 -08:00
parent 6c4f5d5d65
commit 4b7da35738
2 changed files with 31 additions and 2 deletions

View File

@ -73,7 +73,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
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();
}
},

View File

@ -657,13 +657,39 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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);
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();
}
});
});