refactor(elements): remove code to support IE9/10 (#39090)

Since support for IE 9 and IE 10 browsers is removed in v11, the code that was added to support
these browsers is no longer needed.

PR Close #39090
This commit is contained in:
Andrew Kushnir 2020-10-01 19:14:38 -07:00 committed by atscott
parent db37c17e02
commit cbef410e3f
1 changed files with 3 additions and 22 deletions

View File

@ -157,18 +157,9 @@ export function createCustomElement<P>(
string, any
] => [propName, (this as any)[propName]]);
// In some browsers (e.g. IE10), `Object.setPrototypeOf()` (which is required by some Custom
// Elements polyfills) is not defined and is thus polyfilled in a way that does not preserve
// the prototype chain. In such cases, `this` will not be an instance of `NgElementImpl` and
// thus not have the component input getters/setters defined on `NgElementImpl.prototype`.
if (!(this instanceof NgElementImpl)) {
// Add getters and setters to the instance itself for each property input.
defineInputGettersSetters(inputs, this);
} else {
// Delete the property from the instance, so that it can go through the getters/setters
// set on `NgElementImpl.prototype`.
preExistingValues.forEach(([propName]) => delete (this as any)[propName]);
}
// Re-apply pre-existing values through the strategy.
preExistingValues.forEach(([propName, value]) => strategy.setInputValue(propName, value));
@ -237,16 +228,6 @@ export function createCustomElement<P>(
}
}
// TypeScript 3.9+ defines getters/setters as configurable but non-enumerable properties (in
// compliance with the spec). This breaks emulated inheritance in ES5 on environments that do not
// natively support `Object.setPrototypeOf()` (such as IE 9-10).
// Update the property descriptor of `NgElementImpl#ngElementStrategy` to make it enumerable.
// The below 'const', shouldn't be needed but currently this breaks build-optimizer
// Build-optimizer currently uses TypeScript 3.6 which is unable to resolve an 'accessor'
// in 'getTypeOfVariableOrParameterOrPropertyWorker'.
const getterName = 'ngElementStrategy';
Object.defineProperty(NgElementImpl.prototype, getterName, {enumerable: true});
// Add getters and setters to the prototype for each property input.
defineInputGettersSetters(inputs, NgElementImpl.prototype);