OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library template_binding.test.template_binding_test; | 5 library template_binding.test.template_binding_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:js' show JsObject; | 9 import 'dart:js' show JsObject; |
10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 '<template ref=A repeat></template>'); | 1362 '<template ref=A repeat></template>'); |
1363 | 1363 |
1364 var template = div.nodes[2]; | 1364 var template = div.nodes[2]; |
1365 var model = new ObservableList.from(['Fry']); | 1365 var model = new ObservableList.from(['Fry']); |
1366 templateBind(template).model = model; | 1366 templateBind(template).model = model; |
1367 | 1367 |
1368 return new Future(() { | 1368 return new Future(() { |
1369 expect(div.nodes.length, 4); | 1369 expect(div.nodes.length, 4); |
1370 expect('Hi, Fry', div.nodes[3].text); | 1370 expect('Hi, Fry', div.nodes[3].text); |
1371 | 1371 |
1372 div.nodes[2].attributes['ref'] = 'B'; | 1372 // In IE 11, MutationObservers do not fire before setTimeout. |
| 1373 // So rather than using "then" to queue up the next test, we use a |
| 1374 // MutationObserver here to detect the change to "ref". |
| 1375 var done = new Completer(); |
| 1376 new MutationObserver((mutations, observer) { |
| 1377 expect(div.nodes.length, 5); |
| 1378 |
| 1379 expect('Hola, Fry', div.nodes[3].text); |
| 1380 expect('Hola, Leela', div.nodes[4].text); |
| 1381 done.complete(); |
| 1382 }).observe(template, attributes: true, attributeFilter: ['ref']); |
| 1383 |
| 1384 template.setAttribute('ref', 'B'); |
1373 model.add('Leela'); | 1385 model.add('Leela'); |
1374 | 1386 |
1375 }).then(nextMicrotask).then((x) { | 1387 return done.future; |
1376 expect(div.nodes.length, 5); | |
1377 | |
1378 expect('Hola, Fry', div.nodes[3].text); | |
1379 expect('Hola, Leela', div.nodes[4].text); | |
1380 }); | 1388 }); |
1381 }); | 1389 }); |
1382 | 1390 |
1383 test('Bound Ref', () { | 1391 test('Bound Ref', () { |
1384 var div = createTestHtml( | 1392 var div = createTestHtml( |
1385 '<template id=A>Hi, {{}}</template>' | 1393 '<template id=A>Hi, {{}}</template>' |
1386 '<template id=B>Hola, {{}}</template>' | 1394 '<template id=B>Hola, {{}}</template>' |
1387 '<template ref="{{ ref }}" repeat="{{ people }}"></template>'); | 1395 '<template ref="{{ ref }}" repeat="{{ people }}"></template>'); |
1388 | 1396 |
1389 var template = div.nodes[2]; | 1397 var template = div.nodes[2]; |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 class TestAccessorModel extends Observable { | 2730 class TestAccessorModel extends Observable { |
2723 @observable var value = 1; | 2731 @observable var value = 1; |
2724 var count = 0; | 2732 var count = 0; |
2725 | 2733 |
2726 @reflectable | 2734 @reflectable |
2727 get prop { | 2735 get prop { |
2728 count++; | 2736 count++; |
2729 return value; | 2737 return value; |
2730 } | 2738 } |
2731 } | 2739 } |
OLD | NEW |