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 2912a2efbaed10aca8810cfdfcecc94eff7291f6..19824cf840c6c1172deda42ff1263dddb37cbbec 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 |
@@ -185,10 +188,8 @@ class CustomElement implements Element { |
@deprecated |
void leftView() {} |
- // 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; |
@@ -275,9 +276,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; |
@@ -319,10 +323,7 @@ class CustomElement implements Element { |
String get nodeValue => host.nodeValue; |
- @deprecated |
- // TODO(sigmund): restore the old return type and call host.on when |
- // dartbug.com/8131 is fixed. |
- dynamic get on { throw new UnsupportedError('on is deprecated'); } |
+ Events get on => host.on; |
String get contentEditable => host.contentEditable; |
set contentEditable(String v) { host.contentEditable = v; } |