Chromium Code Reviews| 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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1342 deliverChanges(m); | 1342 deliverChanges(m); |
| 1343 expect(div.nodes.length, 7); | 1343 expect(div.nodes.length, 7); |
| 1344 expect(div.nodes[5].text, 'Name: Leela'); | 1344 expect(div.nodes[5].text, 'Name: Leela'); |
| 1345 | 1345 |
| 1346 m[sym('friend')] = toSymbols({'name': 'Leela'}); | 1346 m[sym('friend')] = toSymbols({'name': 'Leela'}); |
| 1347 deliverChanges(m); | 1347 deliverChanges(m); |
| 1348 expect(div.nodes.length, 5); | 1348 expect(div.nodes.length, 5); |
| 1349 expect(div.nodes[3].text, 'Name: Leela'); | 1349 expect(div.nodes[3].text, 'Name: Leela'); |
| 1350 }); | 1350 }); |
| 1351 | 1351 |
| 1352 observeTest('RecursiveRef', () { | |
| 1353 var div = createTestHtml( | |
| 1354 '<template bind>' + | |
|
justinfagnani
2013/07/19 22:11:09
no need for +s
Jennifer Messerly
2013/07/23 02:51:31
Done.
| |
| 1355 '<template id=src>{{ foo }}</template>' + | |
| 1356 '<template bind ref=src></template>' + | |
| 1357 '</template>'); | |
| 1358 | |
| 1359 var m = toSymbols({ 'foo': 'bar'}); | |
|
justinfagnani
2013/07/19 22:11:09
extra space before 'foo'
Jennifer Messerly
2013/07/23 02:51:31
Done.
| |
| 1360 recursivelySetTemplateModel(div, m); | |
| 1361 performMicrotaskCheckpoint(); | |
| 1362 | |
| 1363 expect(div.nodes.length, 4); | |
| 1364 expect(div.nodes[3].text, 'bar'); | |
| 1365 }); | |
| 1366 | |
| 1352 observeTest('ChangeFromBindToRepeat', () { | 1367 observeTest('ChangeFromBindToRepeat', () { |
| 1353 var div = createTestHtml( | 1368 var div = createTestHtml( |
| 1354 '<template bind="{{a}}">' | 1369 '<template bind="{{a}}">' |
| 1355 '{{ length }}' | 1370 '{{ length }}' |
| 1356 '</template>'); | 1371 '</template>'); |
| 1357 var template = div.nodes.first; | 1372 var template = div.nodes.first; |
| 1358 | 1373 |
| 1359 // Note: this test data is a little different from the JS version, because | 1374 // Note: this test data is a little different from the JS version, because |
| 1360 // we allow binding to the "length" field of the Map in preference to | 1375 // we allow binding to the "length" field of the Map in preference to |
| 1361 // binding keys. | 1376 // binding keys. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1682 k = k is String ? sym(k) : _deepToSymbol(k); | 1697 k = k is String ? sym(k) : _deepToSymbol(k); |
| 1683 result[k] = _deepToSymbol(v); | 1698 result[k] = _deepToSymbol(v); |
| 1684 }); | 1699 }); |
| 1685 return result; | 1700 return result; |
| 1686 } | 1701 } |
| 1687 if (value is Iterable) { | 1702 if (value is Iterable) { |
| 1688 return value.map(_deepToSymbol).toList(); | 1703 return value.map(_deepToSymbol).toList(); |
| 1689 } | 1704 } |
| 1690 return value; | 1705 return value; |
| 1691 } | 1706 } |
| OLD | NEW |