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 3b70ccf173341d70f2c78d7bea59e26c7023eb76..25336a7e730db2f92f84b8e941f7189d3943a0de 100644 |
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate |
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate |
@@ -351,6 +351,9 @@ Function _getSvgFunction(String key) { |
********** ********** |
******************************************************************************/ |
+// List of known tagName to DartClass for custom elements, used for upgrade. |
+var _knownCustomeElements = new Map<String, Type>(); |
+ |
Rectangle make_dart_rectangle(r) => |
r == null ? null : new Rectangle(r['left'], r['top'], r['width'], r['height']); |
@@ -420,11 +423,24 @@ wrap_jso(jsObject) { |
// Got a dart_class (it's a custom element) use it it's already set up. |
dartClass_instance = jsObject['dart_class']; |
} else { |
- var func = getHtmlCreateFunction(jsTypeName); |
- if (func != null) { |
- dartClass_instance = func(); |
- dartClass_instance.blink_jsObject = jsObject; |
- js.setDartHtmlWrapperFor(jsObject, dartClass_instance); |
+ var localName = jsObject['localName']; |
+ var customElementClass = _knownCustomeElements[localName]; |
+ // Custom Element to upgrade. |
+ if (jsTypeName == 'HTMLElement' && customElementClass != null) { |
+ 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); |
+ } |
+ } else { |
+ var func = getHtmlCreateFunction(jsTypeName); |
+ if (func != null) { |
+ dartClass_instance = func(); |
+ dartClass_instance.blink_jsObject = jsObject; |
+ js.setDartHtmlWrapperFor(jsObject, dartClass_instance); |
+ } |
} |
} |
return dartClass_instance; |