Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 22967006: Adding polyfill support for custom elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removing mutation observer polyfill from test. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 15b960c69f612978d9e787542fee901c28a53222..7f189a6a4dc08bccc5b3b4b3c19939fb37768bd0 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -7621,6 +7621,11 @@ class Document extends Node native "Document"
ElementList queryAll(String selectors) {
return new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
}
+
+ /// Checks if [register] is supported on the current platform.
+ bool get supportsRegister {
+ return JS('bool', '("register" in #)', this);
+ }
}
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -8478,7 +8483,7 @@ abstract class ElementList<T extends Element> extends ListBase<T> {
// https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
@Experimental()
ElementStream<Event> get onFullscreenError;
-
+
}
// TODO(jacobr): this is an inefficient implementation but it is hard to see
@@ -9619,6 +9624,16 @@ abstract class Element extends Node implements ParentNode, ChildNode native "Ele
Point p = Element._offsetToHelper(parentOffset, parent);
return new Point(p.x + current.offsetLeft, p.y + current.offsetTop);
}
+
+ @JSName('innerHTML')
+ @DomName('HTMLElement.innerHTML')
+ String get innerHtml;
+
+ void set innerHtml(String value) {
+ JS('', '#.innerHTML = #', this, value);
+ Platform.upgradeCustomElements(this);
+ }
+
// To suppress missing implicit constructor warnings.
factory Element._() { throw new UnsupportedError("Not supported"); }
@@ -9859,11 +9874,6 @@ abstract class Element extends Node implements ParentNode, ChildNode native "Ele
@DocsEditable()
String id;
- @JSName('innerHTML')
- @DomName('Element.innerHTML')
- @DocsEditable()
- String innerHtml;
-
@DomName('Element.isContentEditable')
@DocsEditable()
final bool isContentEditable;
@@ -30860,9 +30870,9 @@ void _registerCustomElement(context, document, String tag, Type type) {
if (baseClassName == 'Element') baseClassName = 'HTMLElement';
var baseConstructor = JS('=Object', '#[#]', context, baseClassName);
- if (JS('bool', "typeof(#) != 'function'", baseConstructor)) {
- throw new ArgumentError(type);
- }
+ // if (JS('bool', "typeof(#) != 'function'", baseConstructor)) {
+ // throw new ArgumentError(type);
+ // }
var properties = JS('=Object', '{}');
@@ -31193,6 +31203,19 @@ class Platform {
* error.
*/
static final supportsSimd = false;
+
+ /**
+ * Upgrade all custom elements in the subtree which have not been upgraded.
+ *
+ * This is needed to cover timing scenarios which the custom element polyfill
+ * does not cover.
+ */
+ static void upgradeCustomElements(Node node) {
+ if (JS('bool', '(#.CustomElements && #.CustomElements.upgradeAll)',
+ window, window)) {
+ JS('', '#.CustomElements.upgradeAll(#)', window, node);
+ }
+ }
}
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a

Powered by Google App Engine
This is Rietveld 408576698