mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3325 from Polymer/3324-kschaaf-domif-detach
Ensure dom-if moved into doc fragment is torn down. Fixes #3324
This commit is contained in:
commit
c5ed4706ab
@ -73,7 +73,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
if (!this.parentNode) {
|
||||
if (!this.parentNode ||
|
||||
(this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE &&
|
||||
(!Polymer.Settings.hasShadow ||
|
||||
!(this.parentNode instanceof ShadowRoot)))) {
|
||||
this._teardownInstance();
|
||||
}
|
||||
},
|
||||
|
@ -67,6 +67,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="removalContainer">
|
||||
<template is="dom-if" if id="toBeRemoved"><div id="shouldBeRemoved"></div></template>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
suite('nested pre-configured dom-if', function() {
|
||||
@ -651,6 +655,38 @@ 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, frag);
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user