refactor(ivy): Add newer, smaller NgOnChangesFeature (#28187)
PR Close #28187
This commit is contained in:

committed by
Alex Rickabaugh

parent
5552661fd7
commit
a95e81978b
@ -276,6 +276,7 @@ export function defineComponent<T>(componentDefinition: {
|
||||
id: 'c',
|
||||
styles: componentDefinition.styles || EMPTY_ARRAY,
|
||||
_: null as never,
|
||||
setInput: null,
|
||||
};
|
||||
def._ = noSideEffects(() => {
|
||||
const directiveTypes = componentDefinition.directives !;
|
||||
@ -380,12 +381,14 @@ export function defineNgModule<T>(def: {type: T} & Partial<NgModuleDef<T>>): nev
|
||||
*
|
||||
|
||||
*/
|
||||
function invertObject(obj: any, secondary?: any): any {
|
||||
if (obj == null) return EMPTY_OBJ;
|
||||
function invertObject<T>(
|
||||
obj?: {[P in keyof T]?: string | [string, string]},
|
||||
secondary?: {[key: string]: string}): {[P in keyof T]: string} {
|
||||
if (obj == null) return EMPTY_OBJ as any;
|
||||
const newLookup: any = {};
|
||||
for (const minifiedKey in obj) {
|
||||
if (obj.hasOwnProperty(minifiedKey)) {
|
||||
let publicName: string = obj[minifiedKey];
|
||||
let publicName: string|[string, string] = obj[minifiedKey] !;
|
||||
let declaredName = publicName;
|
||||
if (Array.isArray(publicName)) {
|
||||
declaredName = publicName[1];
|
||||
@ -393,7 +396,7 @@ function invertObject(obj: any, secondary?: any): any {
|
||||
}
|
||||
newLookup[publicName] = minifiedKey;
|
||||
if (secondary) {
|
||||
(secondary[publicName] = declaredName);
|
||||
(secondary[publicName] = declaredName as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -470,11 +473,11 @@ export function defineBase<T>(baseDefinition: {
|
||||
*/
|
||||
outputs?: {[P in keyof T]?: string};
|
||||
}): BaseDef<T> {
|
||||
const declaredInputs: {[P in keyof T]: P} = {} as any;
|
||||
const declaredInputs: {[P in keyof T]: string} = {} as any;
|
||||
return {
|
||||
inputs: invertObject(baseDefinition.inputs, declaredInputs),
|
||||
inputs: invertObject<T>(baseDefinition.inputs as any, declaredInputs),
|
||||
declaredInputs: declaredInputs,
|
||||
outputs: invertObject(baseDefinition.outputs),
|
||||
outputs: invertObject<T>(baseDefinition.outputs as any),
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user