fix(ivy): inheritance in JIT mode not working correctly on IE10 (#34305)
Fixes the metadata and lifecycle hook inheritance not working properly in IE10, because we weren't accessing things correctly. PR Close #34305
This commit is contained in:
parent
1efa0ca4d0
commit
ded78e5688
|
@ -189,7 +189,8 @@ export function extendsDirectlyFromObject(type: Type<any>): boolean {
|
||||||
*/
|
*/
|
||||||
export function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMetadataFacade {
|
export function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMetadataFacade {
|
||||||
// Reflect inputs and outputs.
|
// Reflect inputs and outputs.
|
||||||
const propMetadata = getReflect().ownPropMetadata(type);
|
const reflect = getReflect();
|
||||||
|
const propMetadata = reflect.ownPropMetadata(type);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: type.name,
|
name: type.name,
|
||||||
|
@ -202,7 +203,7 @@ export function directiveMetadata(type: Type<any>, metadata: Directive): R3Direc
|
||||||
inputs: metadata.inputs || EMPTY_ARRAY,
|
inputs: metadata.inputs || EMPTY_ARRAY,
|
||||||
outputs: metadata.outputs || EMPTY_ARRAY,
|
outputs: metadata.outputs || EMPTY_ARRAY,
|
||||||
queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
|
queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
|
||||||
lifecycle: {usesOnChanges: usesLifecycleHook(type, 'ngOnChanges')},
|
lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
|
||||||
typeSourceSpan: null !,
|
typeSourceSpan: null !,
|
||||||
usesInheritance: !extendsDirectlyFromObject(type),
|
usesInheritance: !extendsDirectlyFromObject(type),
|
||||||
exportAs: extractExportAs(metadata.exportAs),
|
exportAs: extractExportAs(metadata.exportAs),
|
||||||
|
@ -216,7 +217,7 @@ export function directiveMetadata(type: Type<any>, metadata: Directive): R3Direc
|
||||||
*/
|
*/
|
||||||
function addDirectiveDefToUndecoratedParents(type: Type<any>) {
|
function addDirectiveDefToUndecoratedParents(type: Type<any>) {
|
||||||
const objPrototype = Object.prototype;
|
const objPrototype = Object.prototype;
|
||||||
let parent = Object.getPrototypeOf(type);
|
let parent = Object.getPrototypeOf(type.prototype).constructor;
|
||||||
|
|
||||||
// Go up the prototype until we hit `Object`.
|
// Go up the prototype until we hit `Object`.
|
||||||
while (parent && parent !== objPrototype) {
|
while (parent && parent !== objPrototype) {
|
||||||
|
@ -291,22 +292,19 @@ function splitByComma(value: string): string[] {
|
||||||
return value.split(',').map(piece => piece.trim());
|
return value.split(',').map(piece => piece.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
function usesLifecycleHook(type: Type<any>, name: string): boolean {
|
|
||||||
const prototype = type.prototype;
|
|
||||||
return prototype && prototype.hasOwnProperty(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
const LIFECYCLE_HOOKS = [
|
const LIFECYCLE_HOOKS = [
|
||||||
'ngOnChanges', 'ngOnInit', 'ngOnDestroy', 'ngDoCheck', 'ngAfterViewInit', 'ngAfterViewChecked',
|
'ngOnChanges', 'ngOnInit', 'ngOnDestroy', 'ngDoCheck', 'ngAfterViewInit', 'ngAfterViewChecked',
|
||||||
'ngAfterContentInit', 'ngAfterContentChecked'
|
'ngAfterContentInit', 'ngAfterContentChecked'
|
||||||
];
|
];
|
||||||
|
|
||||||
function shouldAddAbstractDirective(type: Type<any>): boolean {
|
function shouldAddAbstractDirective(type: Type<any>): boolean {
|
||||||
if (LIFECYCLE_HOOKS.some(hookName => usesLifecycleHook(type, hookName))) {
|
const reflect = getReflect();
|
||||||
|
|
||||||
|
if (LIFECYCLE_HOOKS.some(hookName => reflect.hasLifecycleHook(type, hookName))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const propMetadata = getReflect().ownPropMetadata(type);
|
const propMetadata = reflect.propMetadata(type);
|
||||||
|
|
||||||
for (const field in propMetadata) {
|
for (const field in propMetadata) {
|
||||||
const annotations = propMetadata[field];
|
const annotations = propMetadata[field];
|
||||||
|
|
Loading…
Reference in New Issue