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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 1402693002: Fixed JS custom elements and temporarily mark polymer test as failing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | tests/co19/co19-dartium.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 39b48173fedc3258e1cacfe8c9b5a01c592b3e83..62c902c63a633c628b95b2405f66b4749386dc14 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -1110,6 +1110,12 @@ Function _getSvgFunction(String key) {
// List of known tagName to DartClass for custom elements, used for upgrade.
var _knownCustomElements = new Map<String, Type>();
+void _addCustomElementType(String tagName, Type dartClass) {
+ _knownCustomElements[tagName] = dartClass;
+}
+
+Type _getCustomElementType(object) => _knownCustomElements[_getCustomElementName(object)];
+
// Return the tag name or is attribute of the custom element or data binding.
String _getCustomElementName(element) {
var jsObject;
@@ -1185,8 +1191,7 @@ wrap_jso(jsObject) {
if (wrapper != null) {
if (wrapper.runtimeType == HtmlElement && !wrapper._isBadUpgrade) {
// We're a Dart instance but we need to upgrade.
- var tagName = _getCustomElementName(wrapper);
- var customElementClass = _knownCustomElements[tagName];
+ var customElementClass = _getCustomElementType(wrapper);
if (customElementClass != null) {
var dartClass_instance;
try {
@@ -1238,8 +1243,7 @@ wrap_jso(jsObject) {
// make sure it's upgraded.
dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']);
} else {
- var tagName = _getCustomElementName(jsObject);
- var customElementClass = _knownCustomElements[tagName];
+ var customElementClass = _getCustomElementType(jsObject);
// Custom Element to upgrade.
if (jsTypeName == 'HTMLElement' && customElementClass != null) {
try {
@@ -1258,6 +1262,12 @@ wrap_jso(jsObject) {
}
var func = getHtmlCreateFunction(jsTypeName);
+ if (func == null) {
+ // One last ditch effort could be a JS custom element.
+ if (jsObject.toString() == "[object HTMLElement]") {
+ func = getHtmlCreateFunction("HTMLElement");
+ }
+ }
if (func != null) {
dartClass_instance = func();
dartClass_instance.blink_jsObject = jsObject;
@@ -1384,11 +1394,12 @@ _upgradeHtmlElement(dartInstance) {
// don't try it again - one failure is enough.
if (dartInstance.runtimeType == HtmlElement && !dartInstance._isBadUpgrade) {
// Must be exactly HtmlElement not something derived from it.
- var jsObject = dartInstance.blink_jsObject;
- var tagName = _getCustomElementName(dartInstance);
- var customElementClass = _knownCustomElements[tagName];
+
+ var customElementClass = _getCustomElementType(dartInstance);
+
// Custom Element to upgrade.
if (customElementClass != null) {
+ var jsObject = dartInstance.blink_jsObject;
try {
dartInstance = _blink.Blink_Utils.constructElement(customElementClass, jsObject);
} catch (e) {
@@ -20438,7 +20449,7 @@ class HtmlDocument extends Document {
var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]);
// Remember for any upgrading done in wrap_jso.
- _knownCustomElements[tag] = customElementClass;
+ _addCustomElementType(tag, customElementClass);
// TODO(terry): Hack to stop recursion re-creating custom element when the
// created() constructor of the custom element does e.g.,
@@ -47154,7 +47165,7 @@ class _VMElementUpgrader implements ElementUpgrader {
}
// Remember Dart class to tagName for any upgrading done in wrap_jso.
- _knownCustomElements[tag] = _type;
+ _addCustomElementType(tag, _type);
return createCustomUpgrader(_nativeType, jsObject);
}
« no previous file with comments | « no previous file | tests/co19/co19-dartium.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698