Index: pkg/custom_element/lib/custom_element.dart |
diff --git a/pkg/custom_element/lib/custom_element.dart b/pkg/custom_element/lib/custom_element.dart |
index d3bf02f1d27104b8e5c4de0a35aad79934aa4d8f..da705895fb5d7639be137543f705db34da7b3327 100644 |
--- a/pkg/custom_element/lib/custom_element.dart |
+++ b/pkg/custom_element/lib/custom_element.dart |
@@ -23,6 +23,8 @@ import 'package:mdv/mdv.dart' as mdv; |
import 'package:meta/meta.dart'; |
import 'src/custom_tag_name.dart'; |
+part 'src/attribute_map.dart'; |
+ |
// TODO(jmesserly): replace with a real custom element polyfill. |
// This is just something temporary. |
/** |
@@ -115,6 +117,7 @@ class CustomElement implements Element { |
/** The web component element wrapped by this class. */ |
Element _host; |
List _shadowRoots; |
+ _AttributeMap _attributes; |
/** |
* Shadow roots generated by dwc for each custom element, indexed by the |
@@ -178,10 +181,8 @@ class CustomElement implements Element { |
/** Invoked when this component is removed from the DOM tree. */ |
void removed() {} |
- // TODO(jmesserly): how do we implement this efficiently? |
- // See https://github.com/dart-lang/web-ui/issues/37 |
/** Invoked when any attribute of the component is modified. */ |
- void attributeChanged(String name, String oldValue, String newValue) {} |
+ void attributeChanged(String name, String oldValue) {} |
get model => host.model; |
@@ -268,9 +269,12 @@ class CustomElement implements Element { |
Node insertAllBefore(Iterable<Node> newChild, Node refChild) => |
host.insertAllBefore(newChild, refChild); |
- Map<String, String> get attributes => host.attributes; |
+ Map<String, String> get attributes { |
+ if (_attributes == null) _attributes = new _AttributeMap(this); |
+ return _attributes; |
+ } |
set attributes(Map<String, String> value) { |
- host.attributes = value; |
+ (attributes as _AttributeMap)._replaceAll(value); |
} |
List<Element> get elements => host.children; |