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

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

Side-by-side diff isn't available for this file because of its large size.
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:
Download patch
« no previous file with comments | « no previous file | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('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 76d21ba88cde2d38a035968f14e8ee9e9d771c57..14fc413c973617e5c6b3cf992fb8f7e13e3e1fb8 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -1106,6 +1106,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']);
@@ -1175,11 +1178,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;
@@ -20365,6 +20381,9 @@ class HtmlDocument extends Document {
}
var elemProto = js.context['Object'].callMethod("create", [baseElement['prototype']]);
+ // Remember for any upgrading done in wrap_jso.
+ _knownCustomeElements[tag] = customElementClass;
+
// TODO(terry): Hack to stop recursion re-creating custom element when the
// created() constructor of the custom element does e.g.,
//
« no previous file with comments | « no previous file | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698