Skip to content

Commit da1426b

Browse files
crisbetothePunderWoman
authored andcommitted
refactor(core): simplify serialization of inputs and outputs (#59980)
Simplifies the functions that serialize inputs/outputs for the `ComponentFactory` type. PR Close #59980
1 parent a29c2e0 commit da1426b

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

packages/core/src/render3/component_ref.ts

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -95,44 +95,22 @@ export class ComponentFactoryResolver extends AbstractComponentFactoryResolver {
9595
}
9696

9797
function toInputRefArray<T>(map: DirectiveDef<T>['inputs']): ComponentFactory<T>['inputs'] {
98-
const result: ComponentFactory<T>['inputs'] = [];
99-
for (const publicName in map) {
100-
if (map.hasOwnProperty(publicName)) {
101-
const value = map[publicName];
102-
103-
if (value !== undefined) {
104-
const [propName, flags, transform] = value;
105-
const inputData: ComponentFactory<T>['inputs'][0] = {
106-
propName: propName,
107-
templateName: publicName,
108-
isSignal: (flags & InputFlags.SignalBased) !== 0,
109-
};
110-
111-
if (transform) {
112-
inputData.transform = transform;
113-
}
114-
115-
result.push(inputData);
116-
}
98+
return Object.keys(map).map((name) => {
99+
const [propName, flags, transform] = map[name];
100+
const inputData: ComponentFactory<T>['inputs'][0] = {
101+
propName: propName,
102+
templateName: name,
103+
isSignal: (flags & InputFlags.SignalBased) !== 0,
104+
};
105+
if (transform) {
106+
inputData.transform = transform;
117107
}
118-
}
119-
return result;
108+
return inputData;
109+
});
120110
}
121111

122112
function toOutputRefArray<T>(map: DirectiveDef<T>['outputs']): ComponentFactory<T>['outputs'] {
123-
const result: ComponentFactory<T>['outputs'] = [];
124-
for (const publicName in map) {
125-
if (map.hasOwnProperty(publicName)) {
126-
const value = map[publicName];
127-
if (value !== undefined) {
128-
result.push({
129-
propName: value,
130-
templateName: publicName,
131-
});
132-
}
133-
}
134-
}
135-
return result;
113+
return Object.keys(map).map((name) => ({propName: map[name], templateName: name}));
136114
}
137115

138116
function verifyNotAnOrphanComponent(componentDef: ComponentDef<unknown>) {

0 commit comments

Comments
 (0)