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 5885320896551b07e3c08c3ba6a6c0132330c8fe..22158c9357e793f980d374dd881b5ef94a779159 100644 |
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate |
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate |
@@ -451,6 +451,22 @@ wrap_jso(jsObject) { |
var wrapper = js.getDartHtmlWrapperFor(jsObject); |
// if we have a wrapper return the Dart instance. |
if (wrapper != null) { |
+ if (wrapper.runtimeType == HtmlElement && !wrapper._isBadUpgrade) { |
+ // We're a Dart instance but we need to upgrade. |
+ var customElementClass = _getCustomElementType(wrapper); |
+ if (customElementClass != null) { |
+ var dartClass_instance; |
+ try { |
+ dartClass_instance = _blink.Blink_Utils.constructElement(customElementClass, jsObject); |
+ } finally { |
+ dartClass_instance.blink_jsObject = jsObject; |
+ jsObject['dart_class'] = dartClass_instance; |
+ js.setDartHtmlWrapperFor(jsObject, dartClass_instance); |
+ return dartClass_instance; |
+ } |
+ } |
+ } |
+ |
return wrapper; |
} |