|
32 | 32 | </script>
|
33 | 33 | </dom-module>
|
34 | 34 |
|
| 35 | +<dom-module id="x-attach"> |
| 36 | + <template> |
| 37 | + <style> |
| 38 | + :host { |
| 39 | + display: block; |
| 40 | + } |
| 41 | + </style> |
| 42 | + <div id="child">Live!</div> |
| 43 | + </template> |
| 44 | + <script> |
| 45 | + HTMLImports.whenReady(function() { |
| 46 | + Polymer({ |
| 47 | + is: 'x-attach', |
| 48 | + attached: function() { |
| 49 | + this._wasAttached = true; |
| 50 | + }, |
| 51 | + detached: function() { |
| 52 | + this._wasDetached = true; |
| 53 | + } |
| 54 | + }); |
| 55 | + }); |
| 56 | + </script> |
| 57 | +</dom-module> |
| 58 | + |
35 | 59 | <test-fixture id="simple">
|
36 | 60 | <template>
|
37 | 61 | <x-lazy disable-upgrade></x-lazy>
|
38 | 62 | </template>
|
39 | 63 | </test-fixture>
|
40 | 64 |
|
| 65 | +<test-fixture id="attach"> |
| 66 | + <template> |
| 67 | + <x-attach disable-upgrade></x-attach> |
| 68 | + </template> |
| 69 | +</test-fixture> |
| 70 | + |
41 | 71 | <dom-module id="x-complicated-child">
|
42 | 72 | <script>
|
43 | 73 | HTMLImports.whenReady(function() {
|
|
141 | 171 | assert.ok(el.$.child);
|
142 | 172 | });
|
143 | 173 | });
|
| 174 | + suite('disableUpgrade attach/detach', function() { |
| 175 | + var el; |
| 176 | + setup(function() { |
| 177 | + el = fixture('attach'); |
| 178 | + }); |
| 179 | + test('attached does not fire when element is not yet enabled', function() { |
| 180 | + assert.notOk(el._wasAttached); |
| 181 | + el.removeAttribute('disable-upgrade'); |
| 182 | + assert.ok(el._wasAttached); |
| 183 | + }); |
| 184 | + test('detached does not fire when element is not yet enabled', function() { |
| 185 | + el.parentNode.removeChild(el); |
| 186 | + Polymer.dom.flush(); |
| 187 | + assert.notOk(el._wasAttached); |
| 188 | + assert.notOk(el._wasDetached); |
| 189 | + el.removeAttribute('disable-upgrade'); |
| 190 | + assert.ok(el._wasAttached); |
| 191 | + assert.ok(el._wasDetached); |
| 192 | + }); |
| 193 | + test('detached does not fire when element is detached/attached when not yet enabled', function() { |
| 194 | + var parent = el.parentNode; |
| 195 | + parent.removeChild(el); |
| 196 | + Polymer.dom.flush(); |
| 197 | + assert.notOk(el._wasAttached); |
| 198 | + assert.notOk(el._wasDetached); |
| 199 | + parent.appendChild(el); |
| 200 | + Polymer.dom.flush(); |
| 201 | + assert.notOk(el._wasAttached); |
| 202 | + assert.notOk(el._wasDetached); |
| 203 | + el.removeAttribute('disable-upgrade'); |
| 204 | + assert.ok(el._wasAttached); |
| 205 | + assert.notOk(el._wasDetached); |
| 206 | + }); |
| 207 | + }); |
144 | 208 | suite('disableUpgrade and Databinding', function() {
|
145 | 209 | test('binding to disable-upgrade with true', function() {
|
146 | 210 | var el = fixture('databind-lazy');
|
|
0 commit comments