| 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_element_test; | 5 library template_element_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 | 1361 |
| 1362 m.add(toSymbols({ 'foo': 'baz' })); | 1362 m.add(toSymbols({ 'foo': 'baz' })); |
| 1363 recursivelySetTemplateModel(div, m); | 1363 recursivelySetTemplateModel(div, m); |
| 1364 performMicrotaskCheckpoint(); | 1364 performMicrotaskCheckpoint(); |
| 1365 | 1365 |
| 1366 expect(div.nodes.length, 5); | 1366 expect(div.nodes.length, 5); |
| 1367 expect(div.nodes[1].text, 'bar'); | 1367 expect(div.nodes[1].text, 'bar'); |
| 1368 expect(div.nodes[3].text, 'baz'); | 1368 expect(div.nodes[3].text, 'baz'); |
| 1369 }); | 1369 }); |
| 1370 | 1370 |
| 1371 observeTest('Template - Same Contents, Different Array has no effect', () { |
| 1372 if (!MutationObserver.supported) return; |
| 1373 |
| 1374 var div = createTestHtml('<template repeat>{{ foo }}</template>'); |
| 1375 |
| 1376 var m = toSymbols([{ 'foo': 'bar' }, { 'foo': 'bat'}]); |
| 1377 recursivelySetTemplateModel(div, m); |
| 1378 performMicrotaskCheckpoint(); |
| 1379 |
| 1380 var observer = new MutationObserver((records, _) {}); |
| 1381 observer.observe(div, childList: true); |
| 1382 |
| 1383 var template = div.firstChild; |
| 1384 template.bind('repeat', toObservable(m.toList()), ''); |
| 1385 performMicrotaskCheckpoint(); |
| 1386 var records = observer.takeRecords(); |
| 1387 expect(records.length, 0); |
| 1388 }); |
| 1389 |
| 1371 observeTest('ChangeFromBindToRepeat', () { | 1390 observeTest('ChangeFromBindToRepeat', () { |
| 1372 var div = createTestHtml( | 1391 var div = createTestHtml( |
| 1373 '<template bind="{{a}}">' | 1392 '<template bind="{{a}}">' |
| 1374 '{{ length }}' | 1393 '{{ length }}' |
| 1375 '</template>'); | 1394 '</template>'); |
| 1376 var template = div.nodes.first; | 1395 var template = div.nodes.first; |
| 1377 | 1396 |
| 1378 // Note: this test data is a little different from the JS version, because | 1397 // Note: this test data is a little different from the JS version, because |
| 1379 // we allow binding to the "length" field of the Map in preference to | 1398 // we allow binding to the "length" field of the Map in preference to |
| 1380 // binding keys. | 1399 // binding keys. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 k = k is String ? sym(k) : _deepToSymbol(k); | 1720 k = k is String ? sym(k) : _deepToSymbol(k); |
| 1702 result[k] = _deepToSymbol(v); | 1721 result[k] = _deepToSymbol(v); |
| 1703 }); | 1722 }); |
| 1704 return result; | 1723 return result; |
| 1705 } | 1724 } |
| 1706 if (value is Iterable) { | 1725 if (value is Iterable) { |
| 1707 return value.map(_deepToSymbol).toList(); | 1726 return value.map(_deepToSymbol).toList(); |
| 1708 } | 1727 } |
| 1709 return value; | 1728 return value; |
| 1710 } | 1729 } |
| OLD | NEW |