|
168 | 168 | </script> |
169 | 169 | </dom-module> |
170 | 170 |
|
| 171 | +<dom-module id="x-dynamic-content-and-dynamic-no-content"> |
| 172 | + <template> |
| 173 | + <div id="container"> |
| 174 | + <template is="dom-if" id="staticIf" restamp> |
| 175 | + <div id="static">satatic</div> |
| 176 | + </template> |
| 177 | + <template is="dom-if" id="contentIf" restamp> |
| 178 | + <content select="*"></content> |
| 179 | + </template> |
| 180 | + </div> |
| 181 | + </template> |
| 182 | + <script> |
| 183 | + HTMLImports.whenReady(function() { |
| 184 | + Polymer({is: 'x-dynamic-content-and-dynamic-no-content'}); |
| 185 | + }); |
| 186 | + </script> |
| 187 | +</dom-module> |
| 188 | + |
171 | 189 | <dom-module id="x-multi-dist"> |
172 | 190 | <template> |
173 | 191 | <x-dist id="dist1"><content id="content1"></content></x-dist> |
|
204 | 222 | <div id="container1"> |
205 | 223 | <template id="foo" is="dom-if" if="{{foo}}" restamp> |
206 | 224 | <span>foo</span> |
207 | | - <content select="#one"></content> |
208 | | - <content select="#two"></content> |
| 225 | + <content id="1.1" select="#one"></content> |
| 226 | + <content id="1.2" select="#two"></content> |
209 | 227 | </template> |
210 | 228 | </div> |
211 | 229 | <div id="container2"> |
212 | 230 | <template id="notFoo" is="dom-if" if="{{!foo}}" restamp> |
213 | 231 | <span>Not foo</span> |
214 | | - <content select="#one"></content> |
215 | | - <content select="#two"></content> |
| 232 | + <content id="2.1" select="#one"></content> |
| 233 | + <content id="2.2" select="#two"></content> |
216 | 234 | </template> |
217 | 235 | </div> |
218 | 236 | </template> |
|
1647 | 1665 | assert.equal(c1.parentNode, el.$.container1); |
1648 | 1666 | assert.equal(c2.parentNode, el.$.container1); |
1649 | 1667 | } |
1650 | | - el.foo = !el.foo; |
| 1668 | + el.foo = false; |
1651 | 1669 | el.$.foo.render(); |
1652 | 1670 | el.$.notFoo.render(); |
1653 | 1671 | Polymer.dom.flush(); |
1654 | 1672 | if (usingShady) { |
1655 | 1673 | assert.equal(c1.parentNode, el.$.container2); |
1656 | 1674 | assert.equal(c2.parentNode, el.$.container2); |
1657 | 1675 | } |
1658 | | - el.foo = !el.foo; |
| 1676 | + el.foo = true; |
1659 | 1677 | el.$.foo.render(); |
1660 | 1678 | el.$.notFoo.render(); |
1661 | 1679 | Polymer.dom.flush(); |
1662 | 1680 | if (usingShady) { |
1663 | 1681 | assert.equal(c1.parentNode, el.$.container1); |
1664 | 1682 | assert.equal(c2.parentNode, el.$.container1); |
1665 | 1683 | } |
1666 | | - el.foo = !el.foo; |
| 1684 | + el.foo = false; |
1667 | 1685 | el.$.foo.render(); |
1668 | 1686 | el.$.notFoo.render(); |
1669 | 1687 | Polymer.dom.flush(); |
1670 | 1688 | if (usingShady) { |
1671 | 1689 | assert.equal(c1.parentNode, el.$.container2); |
1672 | 1690 | assert.equal(c2.parentNode, el.$.container2); |
1673 | 1691 | } |
1674 | | - el.foo = !el.foo; |
| 1692 | + el.foo = true; |
1675 | 1693 | el.$.foo.render(); |
1676 | 1694 | el.$.notFoo.render(); |
1677 | 1695 | Polymer.dom.flush(); |
|
1682 | 1700 | document.body.removeChild(el); |
1683 | 1701 | }); |
1684 | 1702 |
|
| 1703 | + test('x-dynamic-content-and-dynamic-no-content', function() { |
| 1704 | + var el = document.createElement('x-dynamic-content-and-dynamic-no-content'); |
| 1705 | + document.body.appendChild(el); |
| 1706 | + var c1 = document.createElement('div'); |
| 1707 | + c1.id = 'one'; |
| 1708 | + Polymer.dom(el).appendChild(c1); |
| 1709 | + Polymer.dom.flush(); |
| 1710 | + assert.equal(Polymer.dom(el).querySelector('#one'), c1); |
| 1711 | + assert.notOk(Polymer.dom(el.root).querySelector('#static')); |
| 1712 | + assert.notOk(Polymer.dom(el.root).querySelector('content')); |
| 1713 | + el.$.contentIf.if = true; |
| 1714 | + el.$.staticIf.if = true; |
| 1715 | + Polymer.dom.flush(); |
| 1716 | + assert.ok(Polymer.dom(el.root).querySelector('#static')); |
| 1717 | + var ip = Polymer.dom(el.root).querySelector('content'); |
| 1718 | + assert.ok(ip); |
| 1719 | + assert.equal(Polymer.dom(ip).getDistributedNodes()[0], c1); |
| 1720 | + if (el.shadyRoot) { |
| 1721 | + assert.ok(el.$.container.querySelector('#one')); |
| 1722 | + } |
| 1723 | + el.$.contentIf.if = false; |
| 1724 | + el.$.staticIf.if = false; |
| 1725 | + Polymer.dom.flush(); |
| 1726 | + assert.equal(Polymer.dom(el).querySelector('#one'), c1); |
| 1727 | + assert.notOk(Polymer.dom(el.root).querySelector('#static')); |
| 1728 | + assert.notOk(Polymer.dom(el.root).querySelector('content')); |
| 1729 | + el.$.contentIf.if = true; |
| 1730 | + el.$.staticIf.if = true; |
| 1731 | + Polymer.dom.flush(); |
| 1732 | + assert.ok(Polymer.dom(el.root).querySelector('#static')); |
| 1733 | + var ip = Polymer.dom(el.root).querySelector('content'); |
| 1734 | + assert.ok(ip); |
| 1735 | + assert.equal(Polymer.dom(ip).getDistributedNodes()[0], c1); |
| 1736 | + if (el.shadyRoot) { |
| 1737 | + assert.ok(el.$.container.querySelector('#one')); |
| 1738 | + } |
| 1739 | + document.body.removeChild(el); |
| 1740 | + |
| 1741 | + }); |
| 1742 | + |
1685 | 1743 | }); |
1686 | 1744 |
|
1687 | 1745 | </script> |
|
0 commit comments