Ensure dom-if moved into doc fragment is torn down. Fixes #3324

This commit is contained in:
Kevin Schaaf 2016-01-22 19:31:13 -08:00
parent 55b91b3db7
commit 6c4f5d5d65
2 changed files with 15 additions and 1 deletions

View File

@ -73,7 +73,7 @@ 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) {
this._teardownInstance();
}
},

View File

@ -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,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
});
});
test('move into doc fragment', function(done) {
var el = shouldBeRemoved;
var frag = document.createDocumentFragment();
Polymer.dom(frag).appendChild(toBeRemoved);
setTimeout(function() {
assert.equal(el.parentNode, null);
done();
});
});
});