| 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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 i = 1; | 1043 i = 1; |
| 1044 deliverChanges(m); | 1044 deliverChanges(m); |
| 1045 expect(div.nodes[i++].text, 'Item 1 changed'); | 1045 expect(div.nodes[i++].text, 'Item 1 changed'); |
| 1046 expect(div.nodes[i++].tagName, 'TEMPLATE'); | 1046 expect(div.nodes[i++].tagName, 'TEMPLATE'); |
| 1047 expect(div.nodes[i++].text, 'Item 2'); | 1047 expect(div.nodes[i++].text, 'Item 2'); |
| 1048 }); | 1048 }); |
| 1049 | 1049 |
| 1050 test('Attribute Template Option/Optgroup', () { | 1050 test('Attribute Template Option/Optgroup', () { |
| 1051 var div = createTestHtml( | 1051 var div = createTestHtml( |
| 1052 '<template bind>' | 1052 '<template bind>' |
| 1053 '<select>' | 1053 '<select selectedIndex="{{ selected }}">' |
| 1054 '<optgroup template repeat="{{ groups }}" label="{{ name }}">' | 1054 '<optgroup template repeat="{{ groups }}" label="{{ name }}">' |
| 1055 '<option template repeat="{{ items }}">{{ val }}</option>' | 1055 '<option template repeat="{{ items }}">{{ val }}</option>' |
| 1056 '</optgroup>' | 1056 '</optgroup>' |
| 1057 '</select>' | 1057 '</select>' |
| 1058 '</template>'); | 1058 '</template>'); |
| 1059 | 1059 |
| 1060 var m = toSymbols({ | 1060 var m = toSymbols({ |
| 1061 'selected': 1, | 1061 'selected': 1, |
| 1062 'groups': [{ | 1062 'groups': [{ |
| 1063 'name': 'one', 'items': [{ 'val': 0 }, { 'val': 1 }] | 1063 'name': 'one', 'items': [{ 'val': 0 }, { 'val': 1 }] |
| 1064 }], | 1064 }], |
| 1065 }); | 1065 }); |
| 1066 | 1066 |
| 1067 recursivelySetTemplateModel(div, m); | 1067 recursivelySetTemplateModel(div, m); |
| 1068 deliverChanges(m); | 1068 deliverChanges(m); |
| 1069 | 1069 |
| 1070 var select = div.nodes[0].nextNode; | 1070 var select = div.nodes[0].nextNode; |
| 1071 expect(select.nodes.length, 2); | 1071 expect(select.nodes.length, 2); |
| 1072 |
| 1073 runAsync(expectAsync0(() { |
| 1074 runAsync(expectAsync0(() { |
| 1075 // TODO(jmesserly): this should be called sooner. |
| 1076 expect(select.selectedIndex, 1); |
| 1077 })); |
| 1078 })); |
| 1072 expect(select.nodes[0].tagName, 'TEMPLATE'); | 1079 expect(select.nodes[0].tagName, 'TEMPLATE'); |
| 1073 expect(select.nodes[0].ref.content.nodes[0].tagName, 'OPTGROUP'); | 1080 expect(select.nodes[0].ref.content.nodes[0].tagName, 'OPTGROUP'); |
| 1074 | 1081 |
| 1075 var optgroup = select.nodes[1]; | 1082 var optgroup = select.nodes[1]; |
| 1076 expect(optgroup.nodes[0].tagName, 'TEMPLATE'); | 1083 expect(optgroup.nodes[0].tagName, 'TEMPLATE'); |
| 1077 expect(optgroup.nodes[1].tagName, 'OPTION'); | 1084 expect(optgroup.nodes[1].tagName, 'OPTION'); |
| 1078 expect(optgroup.nodes[1].text, '0'); | 1085 expect(optgroup.nodes[1].text, '0'); |
| 1079 expect(optgroup.nodes[2].tagName, 'OPTION'); | 1086 expect(optgroup.nodes[2].tagName, 'OPTION'); |
| 1080 expect(optgroup.nodes[2].text, '1'); | 1087 expect(optgroup.nodes[2].text, '1'); |
| 1081 }); | 1088 }); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 k = k is String ? sym(k) : _deepToSymbol(k); | 1682 k = k is String ? sym(k) : _deepToSymbol(k); |
| 1676 result[k] = _deepToSymbol(v); | 1683 result[k] = _deepToSymbol(v); |
| 1677 }); | 1684 }); |
| 1678 return result; | 1685 return result; |
| 1679 } | 1686 } |
| 1680 if (value is Iterable) { | 1687 if (value is Iterable) { |
| 1681 return value.map(_deepToSymbol).toList(); | 1688 return value.map(_deepToSymbol).toList(); |
| 1682 } | 1689 } |
| 1683 return value; | 1690 return value; |
| 1684 } | 1691 } |
| OLD | NEW |