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

Unified Diff: tools/dom/src/dart2js_CustomElementSupport.dart

Issue 2504883002: Fix IE11 issue: this complements the CL I sent last week. It turns out that (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/dart2js_CustomElementSupport.dart
diff --git a/tools/dom/src/dart2js_CustomElementSupport.dart b/tools/dom/src/dart2js_CustomElementSupport.dart
index 5f81b1869bb6483ef4494f5f8dbfb5efcbe0fdb7..e82d3fd3a9acf993c59e951b3a97b927afaa6486 100644
--- a/tools/dom/src/dart2js_CustomElementSupport.dart
+++ b/tools/dom/src/dart2js_CustomElementSupport.dart
@@ -47,6 +47,21 @@ _makeCallbackMethod3(callback) {
convertDartClosureToJS(callback, 4));
}
+/// Checks whether the given [element] correctly extends from the native class
+/// with the given [baseClassName]. This method will throw if the base class
+/// doesn't match, except when the element extends from `template` and it's base
+/// class is `HTMLUnknownElement`. This exclusion is needed to support extension
+/// of template elements (used heavily in Polymer 1.0) on IE11 when using the
+/// webcomponents-lite.js polyfill.
+void _checkExtendsNativeClassOrTemplate(
+ Element element, String extendsTag, String baseClassName) {
+ if (!JS('bool', '(# instanceof window[#])', element, baseClassName) &&
+ !((extendsTag == 'template' &&
+ JS('bool', '(# instanceof window["HTMLUnknownElement"])', element)))) {
+ throw new UnsupportedError('extendsTag does not match base native class');
+ }
+}
+
void _registerCustomElement(context, document, String tag, Type type,
String extendsTagName) {
// Function follows the same pattern as the following JavaScript code for
@@ -90,10 +105,8 @@ void _registerCustomElement(context, document, String tag, Type type,
'native class is not HtmlElement');
}
} else {
- if (!JS('bool', '(#.createElement(#) instanceof window[#])',
- document, extendsTagName, baseClassName)) {
- throw new UnsupportedError('extendsTag does not match base native class');
- }
+ var element = document.createElement(extendsTagName);
+ _checkExtendsNativeClassOrTemplate(element, extendsTagName, baseClassName);
}
var baseConstructor = JS('=Object', '#[#]', context, baseClassName);
@@ -163,14 +176,7 @@ class _JSElementUpgrader implements ElementUpgrader {
_nativeType = HtmlElement;
} else {
var element = document.createElement(extendsTag);
- if (!JS('bool', '(# instanceof window[#])', element, baseClassName) &&
- // Exception to support template elements (extended for core pieces of
- // Polymer 1.0) when using the webcomponents-lite.js polyfill on IE11:
- !((extendsTag == 'template' &&
- JS('bool', '(# instanceof window["HTMLUnknownElement"])', element)))) {
- throw new UnsupportedError(
- 'extendsTag does not match base native class');
- }
+ _checkExtendsNativeClassOrTemplate(element, extendsTag, baseClassName);
_nativeType = element.runtimeType;
}
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698