Skip to content

Commit

Permalink
Ensure dom-if moved into doc fragment is torn down. Fixes #3324
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jan 23, 2016
1 parent 55b91b3 commit 6c4f5d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/template/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},

detached: function() {
if (!this.parentNode) {
if (!this.parentNode || this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
this._teardownInstance();
}
},
Expand Down
14 changes: 14 additions & 0 deletions test/unit/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
</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() {
Expand Down Expand Up @@ -651,6 +655,16 @@
});
});

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();
});
});

});


Expand Down

0 comments on commit 6c4f5d5

Please sign in to comment.