From 1efa0ca4d0422f77faa1b8972b28c3b4fb8bab73 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Wed, 11 Dec 2019 22:06:32 +0100 Subject: [PATCH] fix(ivy): avoid using __proto__ when reading metadata in JIT mode (#34305) In JIT mode we use `__proto__` when reading constructor parameter metadata, however it's not supported on IE10. These changes switch to using `Object.getPrototypeOf` instead. PR Close #34305 --- packages/core/src/di/jit/util.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/src/di/jit/util.ts b/packages/core/src/di/jit/util.ts index 6ba1920d17..ae81dcb89b 100644 --- a/packages/core/src/di/jit/util.ts +++ b/packages/core/src/di/jit/util.ts @@ -48,13 +48,17 @@ function reflectDependency(compiler: CompilerFacade, dep: any | any[]): R3Depend if (param === undefined) { // param may be undefined if type of dep is not set by ngtsc continue; - } else if (param instanceof Optional || param.__proto__.ngMetadataName === 'Optional') { + } + + const proto = Object.getPrototypeOf(param); + + if (param instanceof Optional || proto.ngMetadataName === 'Optional') { meta.optional = true; - } else if (param instanceof SkipSelf || param.__proto__.ngMetadataName === 'SkipSelf') { + } else if (param instanceof SkipSelf || proto.ngMetadataName === 'SkipSelf') { meta.skipSelf = true; - } else if (param instanceof Self || param.__proto__.ngMetadataName === 'Self') { + } else if (param instanceof Self || proto.ngMetadataName === 'Self') { meta.self = true; - } else if (param instanceof Host || param.__proto__.ngMetadataName === 'Host') { + } else if (param instanceof Host || proto.ngMetadataName === 'Host') { meta.host = true; } else if (param instanceof Inject) { meta.token = param.token;