refactor(core): remove IE-sepcific logic from setClassMetadata function (#39090)

This commit simplifies the logic in the `setClassMetadata` function to avoid the code needed to
support IE 9 and IE 10.

PR Close #39090
This commit is contained in:
Andrew Kushnir 2020-10-02 10:27:39 -07:00 committed by atscott
parent cbef410e3f
commit 0001dbdede
2 changed files with 3 additions and 15 deletions

View File

@ -3,7 +3,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 140709,
"main-es2015": 140199,
"polyfills-es2015": 36571
}
}

View File

@ -30,18 +30,8 @@ export function setClassMetadata(
return noSideEffects(() => {
const clazz = type as TypeWithMetadata;
// We determine whether a class has its own metadata by taking the metadata from the
// parent constructor and checking whether it's the same as the subclass metadata below.
// We can't use `hasOwnProperty` here because it doesn't work correctly in IE10 for
// static fields that are defined by TS. See
// https://github.com/angular/angular/pull/28439#issuecomment-459349218.
const parentPrototype = clazz.prototype ? Object.getPrototypeOf(clazz.prototype) : null;
const parentConstructor: TypeWithMetadata|null =
parentPrototype && parentPrototype.constructor;
if (decorators !== null) {
if (clazz.decorators !== undefined &&
(!parentConstructor || parentConstructor.decorators !== clazz.decorators)) {
if (clazz.hasOwnProperty('decorators') && clazz.decorators !== undefined) {
clazz.decorators.push(...decorators);
} else {
clazz.decorators = decorators;
@ -58,9 +48,7 @@ export function setClassMetadata(
// different decorator types. Decorators on individual fields are not merged, as it's
// also incredibly unlikely that a field will be decorated both with an Angular
// decorator and a non-Angular decorator that's also been downleveled.
if (clazz.propDecorators !== undefined &&
(!parentConstructor ||
parentConstructor.propDecorators !== clazz.propDecorators)) {
if (clazz.hasOwnProperty('propDecorators') && clazz.propDecorators !== undefined) {
clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
} else {
clazz.propDecorators = propDecorators;