|
46 | 46 | Polymer({
|
47 | 47 | is: 'x-attach',
|
48 | 48 | attached: function() {
|
49 |
| - this._wasAttached = true; |
| 49 | + this._connectLog = this._connectLog || []; |
| 50 | + this._connectLog.push('attached'); |
50 | 51 | },
|
51 | 52 | detached: function() {
|
52 |
| - this._wasDetached = true; |
| 53 | + this._connectLog = this._connectLog || []; |
| 54 | + this._connectLog.push('detached'); |
53 | 55 | }
|
54 | 56 | });
|
55 | 57 | });
|
|
177 | 179 | el = fixture('attach');
|
178 | 180 | });
|
179 | 181 | test('attached does not fire when element is not yet enabled', function() {
|
180 |
| - assert.notOk(el._wasAttached); |
| 182 | + assert.notOk(el._connectLog); |
181 | 183 | el.removeAttribute('disable-upgrade');
|
182 |
| - assert.ok(el._wasAttached); |
| 184 | + assert.equal(el._connectLog.length, 1); |
| 185 | + assert.equal(el._connectLog[0], 'attached'); |
183 | 186 | });
|
184 | 187 | test('attached/detached do not fire when element is not yet enabled', function() {
|
185 | 188 | el.parentNode.removeChild(el);
|
186 | 189 | Polymer.dom.flush();
|
187 |
| - assert.notOk(el._wasAttached); |
188 |
| - assert.notOk(el._wasDetached); |
| 190 | + assert.notOk(el._connectLog); |
189 | 191 | el.removeAttribute('disable-upgrade');
|
190 |
| - assert.notOk(el._wasAttached); |
191 |
| - assert.notOk(el._wasDetached); |
| 192 | + assert.notOk(el._connectLog); |
192 | 193 | });
|
193 | 194 | test('attached/detached do not fire when element is detached/attached when not yet enabled', function() {
|
194 | 195 | var parent = el.parentNode;
|
195 | 196 | parent.removeChild(el);
|
196 | 197 | Polymer.dom.flush();
|
197 |
| - assert.notOk(el._wasAttached); |
198 |
| - assert.notOk(el._wasDetached); |
| 198 | + assert.notOk(el._connectLog); |
199 | 199 | parent.appendChild(el);
|
200 | 200 | Polymer.dom.flush();
|
201 |
| - assert.notOk(el._wasAttached); |
202 |
| - assert.notOk(el._wasDetached); |
| 201 | + assert.notOk(el._connectLog); |
| 202 | + assert.notOk(el._connectLog); |
203 | 203 | el.removeAttribute('disable-upgrade');
|
204 |
| - assert.ok(el._wasAttached); |
205 |
| - assert.notOk(el._wasDetached); |
| 204 | + assert.equal(el._connectLog.length, 1); |
| 205 | + assert.equal(el._connectLog[0], 'attached'); |
| 206 | + }); |
| 207 | + |
| 208 | + test('attached/detached fire as expected after element is enabled', function() { |
| 209 | + var parent = el.parentNode; |
| 210 | + parent.removeChild(el); |
| 211 | + Polymer.dom.flush(); |
| 212 | + assert.notOk(el._connectLog); |
| 213 | + parent.appendChild(el); |
| 214 | + Polymer.dom.flush(); |
| 215 | + assert.notOk(el._connectLog); |
| 216 | + el.removeAttribute('disable-upgrade'); |
| 217 | + assert.equal(el._connectLog.length, 1); |
| 218 | + assert.equal(el._connectLog[0], 'attached'); |
| 219 | + parent.removeChild(el); |
| 220 | + Polymer.dom.flush(); |
| 221 | + assert.equal(el._connectLog.length, 2); |
| 222 | + assert.equal(el._connectLog[1], 'detached'); |
| 223 | + parent.appendChild(el); |
| 224 | + Polymer.dom.flush(); |
| 225 | + assert.equal(el._connectLog.length, 3); |
| 226 | + assert.equal(el._connectLog[2], 'attached'); |
206 | 227 | });
|
207 | 228 | });
|
208 | 229 | suite('disableUpgrade and Databinding', function() {
|
|
0 commit comments