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

Unified Diff: tools/dom/templates/html/dartium/html_dartium.darttemplate

Issue 1382383003: Fixed element upgrading for polymer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged 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:
View side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698