| 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 'dart:collection' show MapView; |
| 9 import 'package:template_binding/template_binding.dart'; | 10 import 'package:template_binding/template_binding.dart'; |
| 10 import 'package:observe/observe.dart'; | 11 import 'package:observe/observe.dart'; |
| 11 import 'package:unittest/html_config.dart'; | 12 import 'package:unittest/html_config.dart'; |
| 12 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 13 import 'package:web_components/polyfill.dart'; | 14 import 'package:web_components/polyfill.dart'; |
| 14 import 'utils.dart'; | 15 import 'utils.dart'; |
| 15 | 16 |
| 16 Future _registered; | 17 Future _registered; |
| 17 | 18 |
| 18 main() => dirtyCheckZone().run(() { | 19 main() => dirtyCheckZone().run(() { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 new Element.tag('with-attrs-custom-element'); | 209 new Element.tag('with-attrs-custom-element'); |
| 209 | 210 |
| 210 WithAttrsCustomElement.created() : super.created() { | 211 WithAttrsCustomElement.created() : super.created() { |
| 211 _attributes = new AttributeMapWrapper(super.attributes); | 212 _attributes = new AttributeMapWrapper(super.attributes); |
| 212 } | 213 } |
| 213 | 214 |
| 214 get attributes => _attributes; | 215 get attributes => _attributes; |
| 215 } | 216 } |
| 216 | 217 |
| 217 // TODO(jmesserly): would be nice to use mocks when mirrors work on dart2js. | 218 // TODO(jmesserly): would be nice to use mocks when mirrors work on dart2js. |
| 218 class AttributeMapWrapper<K, V> implements Map<K, V> { | 219 class AttributeMapWrapper<K, V> extends MapView<K, V> { |
| 219 final List log = []; | 220 final List log = []; |
| 220 Map<K, V> _map; | |
| 221 | 221 |
| 222 AttributeMapWrapper(this._map); | 222 AttributeMapWrapper(Map map) : super(map); |
| 223 | |
| 224 bool containsValue(Object value) => _map.containsValue(value); | |
| 225 bool containsKey(Object key) => _map.containsKey(key); | |
| 226 V operator [](Object key) => _map[key]; | |
| 227 | 223 |
| 228 void operator []=(K key, V value) { | 224 void operator []=(K key, V value) { |
| 229 log.add(['[]=', key, value]); | 225 log.add(['[]=', key, value]); |
| 230 _map[key] = value; | 226 super[key] = value; |
| 231 } | 227 } |
| 232 | 228 |
| 233 V putIfAbsent(K key, V ifAbsent()) => _map.putIfAbsent(key, ifAbsent); | |
| 234 | |
| 235 V remove(Object key) { | 229 V remove(Object key) { |
| 236 log.add(['remove', key]); | 230 log.add(['remove', key]); |
| 237 _map.remove(key); | 231 super.remove(key); |
| 238 } | 232 } |
| 239 | |
| 240 void addAll(Map<K, V> other) => _map.addAll(other); | |
| 241 void clear() => _map.clear(); | |
| 242 void forEach(void f(K key, V value)) => _map.forEach(f); | |
| 243 Iterable<K> get keys => _map.keys; | |
| 244 Iterable<V> get values => _map.values; | |
| 245 int get length => _map.length; | |
| 246 bool get isEmpty => _map.isEmpty; | |
| 247 bool get isNotEmpty => _map.isNotEmpty; | |
| 248 } | 233 } |
| OLD | NEW |