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

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

Issue 1391273002: Fixed few more issues with upgrader and custom event identitiy (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 25336a7e730db2f92f84b8e941f7189d3943a0de..222865b43a178372775c7fc42d88be8f5e4847e7 100644
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate
@@ -420,8 +420,9 @@ wrap_jso(jsObject) {
var dartClass_instance;
if (jsObject.hasProperty('dart_class')) {
- // Got a dart_class (it's a custom element) use it it's already set up.
- dartClass_instance = jsObject['dart_class'];
+ // Got a dart_class (it's a custom element) use it it's already set up
+ // make sure it's upgraded.
+ dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']);
} else {
var localName = jsObject['localName'];
var customElementClass = _knownCustomeElements[localName];
@@ -495,6 +496,29 @@ 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) {
Alan Knight 2015/10/07 16:21:29 Could you do this with dartInstance.runtimeType ==
+ // Must be exactly HtmlElement not something derived from it.
+ var jsObject = dartInstance.blink_jsObject;
+ var localName = dartInstance.localName;
+ var customElementClass = _knownCustomeElements[localName];
+ // Custom Element to upgrade.
+ if (customElementClass != null) {
+ try {
+ dartInstance = _blink.Blink_Utils.constructElement(customElementClass, jsObject);
+ } finally {
+ dartInstance.blink_jsObject = jsObject;
+ jsObject['dart_class'] = dartInstance;
+ js.setDartHtmlWrapperFor(jsObject, dartInstance);
+ }
+ }
+ }
+
+ return dartInstance;
+}
+
class DebugAssertException implements Exception {
String message;
DebugAssertException(this.message);
« no previous file with comments | « tools/dom/src/dartium_CustomElementSupport.dart ('k') | tools/dom/templates/html/impl/impl_CustomEvent.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698