Skip to content

Commit

Permalink
Add dom-if test for add/remove.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Apr 15, 2017
1 parent 4c87e1d commit a282565
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/unit/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@
</div>

<!-- 2.x hybrid test -->
<dom-if>
<dom-if id="hybridDomIfWrapper">
<template is="dom-if" id="hybridDomIf" if restamp>
<div hybrid-stamped>[[prop]]</div>
</template>
</dom-if>

<script>
/* global configured individual unconfigured1 unconfigured2 inDocumentContainer inDocumentIf structuredContainer structuredDomIf structuredDomBind outerContainer innerContainer shouldBeRemoved toBeRemoved removalContainer hybridDomIf*/
/* global configured individual unconfigured1 unconfigured2 inDocumentContainer inDocumentIf structuredContainer structuredDomIf structuredDomBind outerContainer innerContainer shouldBeRemoved toBeRemoved removalContainer hybridDomIf hybridDomIfWrapper*/

suite('hybrid dom-if', function() {

Expand All @@ -89,6 +89,17 @@
assert.equal(stamped[0].parentNode, document.body);
});

test('remove & re-add works correctly', function() {
var wrapper = hybridDomIfWrapper;
Polymer.dom(document.body).removeChild(wrapper);
Polymer.dom(document.body).appendChild(wrapper);
CustomElements.takeRecords();
hybridDomIf.render();
var stamped = Array.from(document.querySelectorAll('[hybrid-stamped]'));
assert.equal(stamped.length, 1);
assert.equal(stamped[0].parentNode, document.body);
});

test('children removed correctly', function() {
hybridDomIf.if = false;
hybridDomIf.render();
Expand Down

0 comments on commit a282565

Please sign in to comment.