mirror of
https://github.com/dart-lang/sdk
synced 2024-07-25 04:15:45 +00:00
Fix IE11 issue: this complements the CL I sent last week. It turns out that
there are two places where we do this check. This is why the test that I added appears to be failing in the bots. BUG= R=jakemac@google.com Review URL: https://codereview.chromium.org/2504883002 .
This commit is contained in:
parent
6f1efe295c
commit
d89dab56b5
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue