| 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:template_binding/template_binding.dart'; | 9 import 'package:template_binding/template_binding.dart'; |
| 10 import 'package:observe/observe.dart'; | 10 import 'package:observe/observe.dart'; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 new Element.tag('with-attrs-custom-element'); | 208 new Element.tag('with-attrs-custom-element'); |
| 209 | 209 |
| 210 WithAttrsCustomElement.created() : super.created() { | 210 WithAttrsCustomElement.created() : super.created() { |
| 211 _attributes = new AttributeMapWrapper(super.attributes); | 211 _attributes = new AttributeMapWrapper(super.attributes); |
| 212 } | 212 } |
| 213 | 213 |
| 214 get attributes => _attributes; | 214 get attributes => _attributes; |
| 215 } | 215 } |
| 216 | 216 |
| 217 // TODO(jmesserly): would be nice to use mocks when mirrors work on dart2js. | 217 // TODO(jmesserly): would be nice to use mocks when mirrors work on dart2js. |
| 218 class AttributeMapWrapper<K, V> extends MapView<K, V> { | 218 class AttributeMapWrapper<K, V> implements Map<K, V> { |
| 219 final List log = []; | 219 final List log = []; |
| 220 Map<K, V> _map; |
| 220 | 221 |
| 221 AttributeMapWrapper(Map map) : super(map); | 222 AttributeMapWrapper(this._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]; |
| 222 | 227 |
| 223 void operator []=(K key, V value) { | 228 void operator []=(K key, V value) { |
| 224 log.add(['[]=', key, value]); | 229 log.add(['[]=', key, value]); |
| 225 super[key] = value; | 230 _map[key] = value; |
| 226 } | 231 } |
| 227 | 232 |
| 233 V putIfAbsent(K key, V ifAbsent()) => _map.putIfAbsent(key, ifAbsent); |
| 234 |
| 228 V remove(Object key) { | 235 V remove(Object key) { |
| 229 log.add(['remove', key]); | 236 log.add(['remove', key]); |
| 230 super.remove(key); | 237 _map.remove(key); |
| 231 } | 238 } |
| 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; |
| 232 } | 248 } |
| OLD | NEW |