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

Unified Diff: sdk/lib/html/html_common/conversions_dartium.dart

Issue 1417363003: Fixed improper construction of custom elements. (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: sdk/lib/html/html_common/conversions_dartium.dart
diff --git a/sdk/lib/html/html_common/conversions_dartium.dart b/sdk/lib/html/html_common/conversions_dartium.dart
index 1ed1e1348bc7e99415693b7b4965eae05555d696..bdf8e9c17dfa7aa0ae02a71381af48610ac225b3 100644
--- a/sdk/lib/html/html_common/conversions_dartium.dart
+++ b/sdk/lib/html/html_common/conversions_dartium.dart
@@ -122,23 +122,6 @@ wrap_jso(jsObject) {
var wrapper = js.getDartHtmlWrapperFor(jsObject);
// if we have a wrapper return the Dart instance.
if (wrapper != null) {
- var customElementClass = getCustomElementType(wrapper.blink_jsObject);
- if (wrapper.runtimeType != customElementClass && customElementClass != null) {
- if (wrapper.runtimeType == HtmlElement && !wrapper.isBadUpgrade) {
- // We're a Dart instance if it's HtmlElement and we have a customElement
- // class then we need to upgrade.
- if (customElementClass != null) {
- var dartClass_instance;
- try {
- dartClass_instance = _blink.Blink_Utils.constructElement(customElementClass, jsObject);
- } finally {
- dartClass_instance.blink_jsObject = jsObject;
- return dartClass_instance;
- }
- }
- }
- }
-
return wrapper;
}
@@ -180,33 +163,35 @@ wrap_jso(jsObject) {
extendsTag = custom['extends'];
}
- // Custom Element to upgrade.
- // Only allow custome elements to be created in the html or svg default
+ // Only allow custom elements to be created in the html or svg default
// namespace.
+ var func;
var defaultNS = jsObject['namespaceURI'] == 'http://www.w3.org/1999/xhtml' ||
jsObject['namespaceURI'] == 'http://www.w3.org/2000/svg';
if (customElementClass != null && extendsTag == "" && defaultNS) {
- try {
- dartClass_instance = _blink.Blink_Utils.constructElement(customElementClass, jsObject);
- } finally {
- dartClass_instance.blink_jsObject = jsObject;
- js.setDartHtmlWrapperFor(jsObject, dartClass_instance);
- }
+ // The customElementClass is known but we can't create the real class so
+ // create the HtmlElement and it will get upgraded when registerElement's
+ // createdCallback is called.
+ func = getHtmlCreateFunction('HTMLElement');
} else {
- var func = getHtmlCreateFunction(jsTypeName);
+ func = getHtmlCreateFunction(jsTypeName);
if (func == null) {
if (jsTypeName == 'auto-binding') {
- func = getHtmlCreateFunction("HTMLTemplateElement");
+ func = getHtmlCreateFunction('HTMLTemplateElement');
} else if (jsObject.toString() == "[object HTMLElement]") {
// One last ditch effort could be a JS custom element.
- func = getHtmlCreateFunction("HTMLElement");
+ func = getHtmlCreateFunction('HTMLElement');
}
}
- if (func != null) {
- dartClass_instance = func();
- dartClass_instance.blink_jsObject = jsObject;
- js.setDartHtmlWrapperFor(jsObject, dartClass_instance);
- }
+ }
+
+ // Can we construct a Dart class?
+ if (func != null) {
+ dartClass_instance = func();
+
+ // Wrap our Dart instance in both directions.
+ dartClass_instance.blink_jsObject = jsObject;
+ js.setDartHtmlWrapperFor(jsObject, dartClass_instance);
}
// TODO(jacobr): cache that this is not a dart:html JS class.
« 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