| 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 /** | 5 /** |
| 6 * Custom DOM elements. | 6 * Custom DOM elements. |
| 7 * | 7 * |
| 8 * This library provides access to the Polymer project's | 8 * This library provides access to the Polymer project's |
| 9 * [Custom Elements] | 9 * [Custom Elements] |
| 10 * (http://www.polymer-project.org/platform/custom-elements.html) | 10 * (http://www.polymer-project.org/platform/custom-elements.html) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * | 28 * |
| 29 * <script src="packages/custom_element/custom-elements.debug.js"></script> | 29 * <script src="packages/custom_element/custom-elements.debug.js"></script> |
| 30 * | 30 * |
| 31 * You can also use "custom-elements.min.js" for the minified version. | 31 * You can also use "custom-elements.min.js" for the minified version. |
| 32 */ | 32 */ |
| 33 // This is only used by Dart Web UI. | 33 // This is only used by Dart Web UI. |
| 34 class CustomElement implements Element { | 34 class CustomElement implements Element { |
| 35 /** The web component element wrapped by this class. */ | 35 /** The web component element wrapped by this class. */ |
| 36 Element _host; | 36 Element _host; |
| 37 List _shadowRoots; | 37 List _shadowRoots; |
| 38 _AttributeMap _attributes; | |
| 39 | 38 |
| 40 /** | 39 /** |
| 41 * Shadow roots generated by dwc for each custom element, indexed by the | 40 * Shadow roots generated by dwc for each custom element, indexed by the |
| 42 * custom element tag name. | 41 * custom element tag name. |
| 43 */ | 42 */ |
| 44 Map<String, dynamic> _generatedRoots = {}; | 43 Map<String, dynamic> _generatedRoots = {}; |
| 45 | 44 |
| 46 /** | 45 /** |
| 47 * Temporary property until components extend [Element]. An element can | 46 * Temporary property until components extend [Element]. An element can |
| 48 * only be associated with one host, and it is an error to use a web component | 47 * only be associated with one host, and it is an error to use a web component |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void inserted() {} | 99 void inserted() {} |
| 101 @deprecated | 100 @deprecated |
| 102 void enteredView() {} | 101 void enteredView() {} |
| 103 | 102 |
| 104 /** Invoked when this component is removed from the DOM tree. */ | 103 /** Invoked when this component is removed from the DOM tree. */ |
| 105 void removed() {} | 104 void removed() {} |
| 106 @deprecated | 105 @deprecated |
| 107 void leftView() {} | 106 void leftView() {} |
| 108 | 107 |
| 109 /** Invoked when any attribute of the component is modified. */ | 108 /** Invoked when any attribute of the component is modified. */ |
| 110 void attributeChanged(String name, String oldValue) {} | 109 void attributeChanged(String name, String oldValue, String newValue) => |
| 110 host.attributeChanged(name, oldValue, newValue); |
| 111 | 111 |
| 112 // TODO(efortuna): Update these when we decide what to do with these | 112 // TODO(efortuna): Update these when we decide what to do with these |
| 113 // properties. | 113 // properties. |
| 114 @deprecated | 114 @deprecated |
| 115 String getAttribute(String name) => | 115 String getAttribute(String name) => |
| 116 host.getAttribute(name); | 116 host.getAttribute(name); |
| 117 | 117 |
| 118 @deprecated | 118 @deprecated |
| 119 String getAttributeNS(String namespaceUri, String localName) => | 119 String getAttributeNS(String namespaceUri, String localName) => |
| 120 host.getAttributeNS(namespaceUri, localName); | 120 host.getAttributeNS(namespaceUri, localName); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Removes this node from the DOM. | 150 * Removes this node from the DOM. |
| 151 */ | 151 */ |
| 152 void remove() => host.remove(); | 152 void remove() => host.remove(); |
| 153 | 153 |
| 154 Node get nextNode => host.nextNode; | 154 Node get nextNode => host.nextNode; |
| 155 | 155 |
| 156 String get nodeName => host.nodeName; | 156 String get nodeName => host.nodeName; |
| 157 | 157 |
| 158 Document get document => host.document; | 158 Document get ownerDocument => host.ownerDocument; |
| 159 | 159 |
| 160 Node get previousNode => host.previousNode; | 160 Node get previousNode => host.previousNode; |
| 161 | 161 |
| 162 String get text => host.text; | 162 String get text => host.text; |
| 163 | 163 |
| 164 set text(String v) { host.text = v; } | 164 set text(String v) { host.text = v; } |
| 165 | 165 |
| 166 bool contains(Node other) => host.contains(other); | 166 bool contains(Node other) => host.contains(other); |
| 167 | 167 |
| 168 bool hasChildNodes() => host.hasChildNodes(); | 168 bool hasChildNodes() => host.hasChildNodes(); |
| 169 | 169 |
| 170 Node insertBefore(Node newChild, Node refChild) => | 170 Node insertBefore(Node newChild, Node refChild) => |
| 171 host.insertBefore(newChild, refChild); | 171 host.insertBefore(newChild, refChild); |
| 172 | 172 |
| 173 Node insertAllBefore(Iterable<Node> newChild, Node refChild) => | 173 Node insertAllBefore(Iterable<Node> newChild, Node refChild) => |
| 174 host.insertAllBefore(newChild, refChild); | 174 host.insertAllBefore(newChild, refChild); |
| 175 | 175 |
| 176 Map<String, String> get attributes { | 176 Map<String, String> get attributes => host.attributes; |
| 177 if (_attributes == null) _attributes = new _AttributeMap(this); | |
| 178 return _attributes; | |
| 179 } | |
| 180 set attributes(Map<String, String> value) { | 177 set attributes(Map<String, String> value) { |
| 181 (attributes as _AttributeMap)._replaceAll(value); | 178 host.attributes = value; |
| 182 } | 179 } |
| 183 | 180 |
| 184 List<Element> get elements => host.children; | 181 List<Element> get elements => host.children; |
| 185 | 182 |
| 186 set elements(List<Element> value) { | 183 set elements(List<Element> value) { |
| 187 host.children = value; | 184 host.children = value; |
| 188 } | 185 } |
| 189 | 186 |
| 190 List<Element> get children => host.children; | 187 List<Element> get children => host.children; |
| 191 | 188 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 227 |
| 231 bool get draggable => host.draggable; | 228 bool get draggable => host.draggable; |
| 232 set draggable(bool v) { host.draggable = v; } | 229 set draggable(bool v) { host.draggable = v; } |
| 233 | 230 |
| 234 bool get hidden => host.hidden; | 231 bool get hidden => host.hidden; |
| 235 set hidden(bool v) { host.hidden = v; } | 232 set hidden(bool v) { host.hidden = v; } |
| 236 | 233 |
| 237 String get id => host.id; | 234 String get id => host.id; |
| 238 set id(String v) { host.id = v; } | 235 set id(String v) { host.id = v; } |
| 239 | 236 |
| 240 String get innerHTML => host.innerHtml; | |
| 241 | |
| 242 void set innerHTML(String v) { | |
| 243 host.innerHtml = v; | |
| 244 } | |
| 245 | |
| 246 String get innerHtml => host.innerHtml; | 237 String get innerHtml => host.innerHtml; |
| 247 void set innerHtml(String v) { | 238 void set innerHtml(String v) { |
| 248 host.innerHtml = v; | 239 host.innerHtml = v; |
| 249 } | 240 } |
| 250 | 241 |
| 251 void setInnerHtml(String html, | 242 void setInnerHtml(String html, |
| 252 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 243 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
| 253 host.setInnerHtml(html, validator: validator, treeSanitizer: treeSanitizer); | 244 host.setInnerHtml(html, validator: validator, treeSanitizer: treeSanitizer); |
| 254 } | 245 } |
| 255 | 246 |
| 256 void set unsafeInnerHtml(String html) { | |
| 257 host.unsafeInnerHtml = html; | |
| 258 } | |
| 259 | |
| 260 DocumentFragment createFragment(String html, | 247 DocumentFragment createFragment(String html, |
| 261 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) => | 248 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) => |
| 262 host.createFragment(html, | 249 host.createFragment(html, |
| 263 validator: validator, treeSanitizer: treeSanitizer); | 250 validator: validator, treeSanitizer: treeSanitizer); |
| 264 | 251 |
| 265 InputMethodContext get inputMethodContext => host.inputMethodContext; | 252 InputMethodContext get inputMethodContext => host.inputMethodContext; |
| 266 | 253 |
| 267 bool get isContentEditable => host.isContentEditable; | 254 bool get isContentEditable => host.isContentEditable; |
| 268 | 255 |
| 269 String get lang => host.lang; | 256 String get lang => host.lang; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 bool matchesWithAncestors(String selectors) => | 339 bool matchesWithAncestors(String selectors) => |
| 353 host.matchesWithAncestors(selectors); | 340 host.matchesWithAncestors(selectors); |
| 354 | 341 |
| 355 @deprecated | 342 @deprecated |
| 356 void requestFullScreen(int flags) { requestFullscreen(); } | 343 void requestFullScreen(int flags) { requestFullscreen(); } |
| 357 | 344 |
| 358 void requestFullscreen() { host.requestFullscreen(); } | 345 void requestFullscreen() { host.requestFullscreen(); } |
| 359 | 346 |
| 360 void requestPointerLock() { host.requestPointerLock(); } | 347 void requestPointerLock() { host.requestPointerLock(); } |
| 361 | 348 |
| 362 Element query(String selectors) => host.query(selectors); | 349 Element querySelector(String selectors) => host.querySelector(selectors); |
| 363 | 350 |
| 364 ElementList queryAll(String selectors) => host.queryAll(selectors); | 351 ElementList querySelectorAll(String selectors) => |
| 352 host.querySelectorAll(selectors); |
| 353 |
| 354 @deprecated |
| 355 Element query(String selectors) => host.querySelector(selectors); |
| 356 |
| 357 @deprecated |
| 358 ElementList queryAll(String selectors) => host.querySelectorAll(selectors); |
| 365 | 359 |
| 366 String get className => host.className; | 360 String get className => host.className; |
| 367 set className(String value) { host.className = value; } | 361 set className(String value) { host.className = value; } |
| 368 | 362 |
| 369 @deprecated | 363 @deprecated |
| 370 int get clientHeight => client.height; | 364 int get clientHeight => client.height; |
| 371 | 365 |
| 372 @deprecated | 366 @deprecated |
| 373 int get clientLeft => client.left; | 367 int get clientLeft => client.left; |
| 374 | 368 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 Node get firstChild => host.firstChild; | 410 Node get firstChild => host.firstChild; |
| 417 | 411 |
| 418 Node get lastChild => host.lastChild; | 412 Node get lastChild => host.lastChild; |
| 419 | 413 |
| 420 String get localName => host.localName; | 414 String get localName => host.localName; |
| 421 | 415 |
| 422 String get namespaceUri => host.namespaceUri; | 416 String get namespaceUri => host.namespaceUri; |
| 423 | 417 |
| 424 int get nodeType => host.nodeType; | 418 int get nodeType => host.nodeType; |
| 425 | 419 |
| 426 void $dom_addEventListener(String type, EventListener listener, | 420 void addEventListener(String type, EventListener listener, |
| 427 [bool useCapture]) { | 421 [bool useCapture]) { |
| 428 host.$dom_addEventListener(type, listener, useCapture); | 422 host.addEventListener(type, listener, useCapture); |
| 429 } | 423 } |
| 430 | 424 |
| 431 bool dispatchEvent(Event event) => host.dispatchEvent(event); | 425 bool dispatchEvent(Event event) => host.dispatchEvent(event); |
| 432 | 426 |
| 433 void $dom_removeEventListener(String type, EventListener listener, | 427 void removeEventListener(String type, EventListener listener, |
| 434 [bool useCapture]) { | 428 [bool useCapture]) { |
| 435 host.$dom_removeEventListener(type, listener, useCapture); | 429 host.removeEventListener(type, listener, useCapture); |
| 436 } | 430 } |
| 437 | 431 |
| 438 get xtag => host.xtag; | 432 get xtag => host.xtag; |
| 439 | 433 |
| 440 set xtag(value) { host.xtag = value; } | 434 set xtag(value) { host.xtag = value; } |
| 441 | 435 |
| 442 Node append(Node e) => host.append(e); | 436 Node append(Node e) => host.append(e); |
| 443 | 437 |
| 444 void appendText(String text) => host.appendText(text); | 438 void appendText(String text) => host.appendText(text); |
| 445 | 439 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 Stream<TouchEvent> get onTouchLeave => host.onTouchLeave; | 494 Stream<TouchEvent> get onTouchLeave => host.onTouchLeave; |
| 501 Stream<TouchEvent> get onTouchMove => host.onTouchMove; | 495 Stream<TouchEvent> get onTouchMove => host.onTouchMove; |
| 502 Stream<TouchEvent> get onTouchStart => host.onTouchStart; | 496 Stream<TouchEvent> get onTouchStart => host.onTouchStart; |
| 503 Stream<TransitionEvent> get onTransitionEnd => host.onTransitionEnd; | 497 Stream<TransitionEvent> get onTransitionEnd => host.onTransitionEnd; |
| 504 | 498 |
| 505 // TODO(sigmund): do the normal forwarding when dartbug.com/7919 is fixed. | 499 // TODO(sigmund): do the normal forwarding when dartbug.com/7919 is fixed. |
| 506 Stream<WheelEvent> get onMouseWheel { | 500 Stream<WheelEvent> get onMouseWheel { |
| 507 throw new UnsupportedError('onMouseWheel is not supported'); | 501 throw new UnsupportedError('onMouseWheel is not supported'); |
| 508 } | 502 } |
| 509 } | 503 } |
| OLD | NEW |