| 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 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 | 1409 |
| 1410 m.add(toSymbols({ 'foo': 'baz' })); | 1410 m.add(toSymbols({ 'foo': 'baz' })); |
| 1411 recursivelySetTemplateModel(div, m); | 1411 recursivelySetTemplateModel(div, m); |
| 1412 performMicrotaskCheckpoint(); | 1412 performMicrotaskCheckpoint(); |
| 1413 | 1413 |
| 1414 expect(div.nodes.length, 5); | 1414 expect(div.nodes.length, 5); |
| 1415 expect(div.nodes[1].text, 'bar'); | 1415 expect(div.nodes[1].text, 'bar'); |
| 1416 expect(div.nodes[3].text, 'baz'); | 1416 expect(div.nodes[3].text, 'baz'); |
| 1417 }); | 1417 }); |
| 1418 | 1418 |
| 1419 observeTest('Template - Same Contents, Different Array has no effect', () { |
| 1420 if (!MutationObserver.supported) return; |
| 1421 |
| 1422 var div = createTestHtml('<template repeat>{{ foo }}</template>'); |
| 1423 |
| 1424 var m = toSymbols([{ 'foo': 'bar' }, { 'foo': 'bat'}]); |
| 1425 recursivelySetTemplateModel(div, m); |
| 1426 performMicrotaskCheckpoint(); |
| 1427 |
| 1428 var observer = new MutationObserver((records, _) {}); |
| 1429 observer.observe(div, childList: true); |
| 1430 |
| 1431 var template = div.firstChild; |
| 1432 template.bind('repeat', toObservable(m.toList()), ''); |
| 1433 performMicrotaskCheckpoint(); |
| 1434 var records = observer.takeRecords(); |
| 1435 expect(records.length, 0); |
| 1436 }); |
| 1437 |
| 1419 observeTest('RecursiveRef', () { | 1438 observeTest('RecursiveRef', () { |
| 1420 var div = createTestHtml( | 1439 var div = createTestHtml( |
| 1421 '<template bind>' | 1440 '<template bind>' |
| 1422 '<template id=src>{{ foo }}</template>' | 1441 '<template id=src>{{ foo }}</template>' |
| 1423 '<template bind ref=src></template>' | 1442 '<template bind ref=src></template>' |
| 1424 '</template>'); | 1443 '</template>'); |
| 1425 | 1444 |
| 1426 var m = toSymbols({'foo': 'bar'}); | 1445 var m = toSymbols({'foo': 'bar'}); |
| 1427 recursivelySetTemplateModel(div, m); | 1446 recursivelySetTemplateModel(div, m); |
| 1428 performMicrotaskCheckpoint(); | 1447 performMicrotaskCheckpoint(); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 k = k is String ? sym(k) : _deepToSymbol(k); | 1772 k = k is String ? sym(k) : _deepToSymbol(k); |
| 1754 result[k] = _deepToSymbol(v); | 1773 result[k] = _deepToSymbol(v); |
| 1755 }); | 1774 }); |
| 1756 return result; | 1775 return result; |
| 1757 } | 1776 } |
| 1758 if (value is Iterable) { | 1777 if (value is Iterable) { |
| 1759 return value.map(_deepToSymbol).toList(); | 1778 return value.map(_deepToSymbol).toList(); |
| 1760 } | 1779 } |
| 1761 return value; | 1780 return value; |
| 1762 } | 1781 } |
| OLD | NEW |