Skip to content

Commit 0001dbd

Browse files
AndrewKushniratscott
authored andcommitted
refactor(core): remove IE-sepcific logic from setClassMetadata function (angular#39090)
This commit simplifies the logic in the `setClassMetadata` function to avoid the code needed to support IE 9 and IE 10. PR Close angular#39090
1 parent cbef410 commit 0001dbd

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

goldens/size-tracking/integration-payloads.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"master": {
44
"uncompressed": {
55
"runtime-es2015": 1485,
6-
"main-es2015": 140709,
6+
"main-es2015": 140199,
77
"polyfills-es2015": 36571
88
}
99
}

packages/core/src/render3/metadata.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,8 @@ export function setClassMetadata(
3030
return noSideEffects(() => {
3131
const clazz = type as TypeWithMetadata;
3232

33-
// We determine whether a class has its own metadata by taking the metadata from the
34-
// parent constructor and checking whether it's the same as the subclass metadata below.
35-
// We can't use `hasOwnProperty` here because it doesn't work correctly in IE10 for
36-
// static fields that are defined by TS. See
37-
// https://github.com/angular/angular/pull/28439#issuecomment-459349218.
38-
const parentPrototype = clazz.prototype ? Object.getPrototypeOf(clazz.prototype) : null;
39-
const parentConstructor: TypeWithMetadata|null =
40-
parentPrototype && parentPrototype.constructor;
41-
4233
if (decorators !== null) {
43-
if (clazz.decorators !== undefined &&
44-
(!parentConstructor || parentConstructor.decorators !== clazz.decorators)) {
34+
if (clazz.hasOwnProperty('decorators') && clazz.decorators !== undefined) {
4535
clazz.decorators.push(...decorators);
4636
} else {
4737
clazz.decorators = decorators;
@@ -58,9 +48,7 @@ export function setClassMetadata(
5848
// different decorator types. Decorators on individual fields are not merged, as it's
5949
// also incredibly unlikely that a field will be decorated both with an Angular
6050
// decorator and a non-Angular decorator that's also been downleveled.
61-
if (clazz.propDecorators !== undefined &&
62-
(!parentConstructor ||
63-
parentConstructor.propDecorators !== clazz.propDecorators)) {
51+
if (clazz.hasOwnProperty('propDecorators') && clazz.propDecorators !== undefined) {
6452
clazz.propDecorators = {...clazz.propDecorators, ...propDecorators};
6553
} else {
6654
clazz.propDecorators = propDecorators;

0 commit comments

Comments
 (0)