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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.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:
Download patch
« no previous file with comments | « no previous file | tools/dom/src/dart2js_CustomElementSupport.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 05fc09a5052ce3fc62606e0113185202a960e1f9..04ed9e673bb499a962ad704800b21fd580044e71 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -42766,6 +42766,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
@@ -42809,10 +42824,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);
@@ -42882,14 +42895,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 | « no previous file | tools/dom/src/dart2js_CustomElementSupport.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698