| 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.custom_element_bindings_test; | 5 library template_binding.test.custom_element_bindings_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:custom_element/polyfill.dart'; | 9 import 'package:custom_element/polyfill.dart'; |
| 10 import 'package:template_binding/template_binding.dart'; | 10 import 'package:template_binding/template_binding.dart'; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 '<my-custom-element my-point="{{a}}" scary-monster="{{b}}">' | 117 '<my-custom-element my-point="{{a}}" scary-monster="{{b}}">' |
| 118 '</my-custom-element>' | 118 '</my-custom-element>' |
| 119 '</template>'); | 119 '</template>'); |
| 120 | 120 |
| 121 templateBind(div.query('template')).model = model; | 121 templateBind(div.query('template')).model = model; |
| 122 performMicrotaskCheckpoint(); | 122 performMicrotaskCheckpoint(); |
| 123 | 123 |
| 124 var element = div.nodes[1]; | 124 var element = div.nodes[1]; |
| 125 | 125 |
| 126 expect(element is MyCustomElement, true, | 126 expect(element is MyCustomElement, true, |
| 127 reason: '${element} should be a MyCustomElement'); | 127 reason: '$element should be a MyCustomElement'); |
| 128 | 128 |
| 129 expect(element.myPoint, model['a']); | 129 expect(element.myPoint, model['a']); |
| 130 expect(element.scaryMonster, model['b']); | 130 expect(element.scaryMonster, model['b']); |
| 131 | 131 |
| 132 expect(element.attributes, isNot(contains('my-point'))); | 132 expect(element.attributes, isNot(contains('my-point'))); |
| 133 expect(element.attributes, isNot(contains('scary-monster'))); | 133 expect(element.attributes, isNot(contains('scary-monster'))); |
| 134 | 134 |
| 135 model['a'] = null; | 135 model['a'] = null; |
| 136 performMicrotaskCheckpoint(); | 136 performMicrotaskCheckpoint(); |
| 137 expect(element.myPoint, null); | 137 expect(element.myPoint, null); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 attributes.remove(name); | 172 attributes.remove(name); |
| 173 unbind(name); | 173 unbind(name); |
| 174 return bindings[name] = new _MyCustomBinding(this, name, model, path); | 174 return bindings[name] = new _MyCustomBinding(this, name, model, path); |
| 175 } | 175 } |
| 176 return nodeBindFallback(this).bind(name, model, path); | 176 return nodeBindFallback(this).bind(name, model, path); |
| 177 } | 177 } |
| 178 | 178 |
| 179 unbind(name) => nodeBindFallback(this).unbind(name); | 179 unbind(name) => nodeBindFallback(this).unbind(name); |
| 180 unbindAll() => nodeBindFallback(this).unbindAll(); | 180 unbindAll() => nodeBindFallback(this).unbindAll(); |
| 181 get bindings => nodeBindFallback(this).bindings; | 181 get bindings => nodeBindFallback(this).bindings; |
| 182 get templateInstance => nodeBindFallback(this).templateInstance; |
| 182 } | 183 } |
| 183 | 184 |
| 184 class _MyCustomBinding extends NodeBinding { | 185 class _MyCustomBinding extends NodeBinding { |
| 185 _MyCustomBinding(MyCustomElement node, property, model, path) | 186 _MyCustomBinding(MyCustomElement node, property, model, path) |
| 186 : super(node, property, model, path) { | 187 : super(node, property, model, path) { |
| 187 | 188 |
| 188 node.attributes.remove(property); | 189 node.attributes.remove(property); |
| 189 } | 190 } |
| 190 | 191 |
| 191 MyCustomElement get node => super.node; | 192 MyCustomElement get node => super.node; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 240 |
| 240 void addAll(Map<K, V> other) => _map.addAll(other); | 241 void addAll(Map<K, V> other) => _map.addAll(other); |
| 241 void clear() => _map.clear(); | 242 void clear() => _map.clear(); |
| 242 void forEach(void f(K key, V value)) => _map.forEach(f); | 243 void forEach(void f(K key, V value)) => _map.forEach(f); |
| 243 Iterable<K> get keys => _map.keys; | 244 Iterable<K> get keys => _map.keys; |
| 244 Iterable<V> get values => _map.values; | 245 Iterable<V> get values => _map.values; |
| 245 int get length => _map.length; | 246 int get length => _map.length; |
| 246 bool get isEmpty => _map.isEmpty; | 247 bool get isEmpty => _map.isEmpty; |
| 247 bool get isNotEmpty => _map.isNotEmpty; | 248 bool get isNotEmpty => _map.isNotEmpty; |
| 248 } | 249 } |
| OLD | NEW |