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:
parent
cbef410e3f
commit
0001dbdede
|
@ -3,7 +3,7 @@
|
||||||
"master": {
|
"master": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime-es2015": 1485,
|
"runtime-es2015": 1485,
|
||||||
"main-es2015": 140709,
|
"main-es2015": 140199,
|
||||||
"polyfills-es2015": 36571
|
"polyfills-es2015": 36571
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,18 +30,8 @@ export function setClassMetadata(
|
||||||
return noSideEffects(() => {
|
return noSideEffects(() => {
|
||||||
const clazz = type as TypeWithMetadata;
|
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 (decorators !== null) {
|
||||||
if (clazz.decorators !== undefined &&
|
if (clazz.hasOwnProperty('decorators') && clazz.decorators !== undefined) {
|
||||||
(!parentConstructor || parentConstructor.decorators !== clazz.decorators)) {
|
|
||||||
clazz.decorators.push(...decorators);
|
clazz.decorators.push(...decorators);
|
||||||
} else {
|
} else {
|
||||||
clazz.decorators = decorators;
|
clazz.decorators = decorators;
|
||||||
|
@ -58,9 +48,7 @@ export function setClassMetadata(
|
||||||
// different decorator types. Decorators on individual fields are not merged, as it's
|
// 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
|
// also incredibly unlikely that a field will be decorated both with an Angular
|
||||||
// decorator and a non-Angular decorator that's also been downleveled.
|
// decorator and a non-Angular decorator that's also been downleveled.
|
||||||
if (clazz.propDecorators !== undefined &&
|
if (clazz.hasOwnProperty('propDecorators') && clazz.propDecorators !== undefined) {
|
||||||
(!parentConstructor ||
|
|
||||||
parentConstructor.propDecorators !== clazz.propDecorators)) {
|
|
||||||
clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
|
clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
|
||||||
} else {
|
} else {
|
||||||
clazz.propDecorators = propDecorators;
|
clazz.propDecorators = propDecorators;
|
||||||
|
|
Loading…
Reference in New Issue