Index: tools/dom/templates/html/dartium/html_dartium.darttemplate |
diff --git a/tools/dom/templates/html/dartium/html_dartium.darttemplate b/tools/dom/templates/html/dartium/html_dartium.darttemplate |
index 7d6572c5d0275b1e731f580c5d5d84cca25a9180..cd9f49c4e7aead3e4d1169559f7c8bd79ee9679d 100644 |
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate |
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate |
@@ -569,8 +569,9 @@ wrap_jso_custom_element(jsObject) { |
// Upgrade a Dart HtmlElement to the user's Dart custom element class. |
_upgradeHtmlElement(dartInstance) { |
- var dartInstanceMirror = reflect(dartInstance); |
- if (dartInstanceMirror.type.qualifiedName == #dart.dom.html.HtmlElement) { |
+ // Only try upgrading HtmlElement (Dart class) if there is a failure then |
+ // 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 localName = dartInstance.localName; |
@@ -579,6 +580,8 @@ _upgradeHtmlElement(dartInstance) { |
if (customElementClass != null) { |
try { |
dartInstance = _blink.Blink_Utils.constructElement(customElementClass, jsObject); |
+ } catch (e) { |
+ dartInstance.badUpgrade(); |
} finally { |
dartInstance.blink_jsObject = jsObject; |
jsObject['dart_class'] = dartInstance; |
@@ -678,6 +681,7 @@ createCustomUpgrader(Type customElementClass, $this) { |
try { |
dartClass = _blink.Blink_Utils.constructElement(customElementClass, $this); |
} catch (e) { |
+ dartClass.badUpgrade(); |
throw e; |
} finally { |
// Need to remember the Dart class that was created for this custom so |