Skip to content

Commit 23965c3

Browse files
committed
split it
1 parent 0156114 commit 23965c3

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/build/patches.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,10 @@ function handleMixin(node: Node, mixins: Record<string, any>) {
7575
const name = child.values[0] as string;
7676
switch (child.name) {
7777
case "event":
78-
event.push({
79-
name,
80-
type: child.properties.type as string,
81-
});
78+
handleEventChild(child, event, name);
8279
break;
8380
case "property":
84-
property[name] = {
85-
name,
86-
exposed: child.properties?.exposed as string,
87-
};
81+
handlePropertyChild(child, property, name);
8882
break;
8983
default:
9084
throw new Error(`Unknown node name: ${child.name}`);
@@ -94,6 +88,30 @@ function handleMixin(node: Node, mixins: Record<string, any>) {
9488
mixins[name] = { name, events: { event }, properties: { property } };
9589
}
9690

91+
/**
92+
* Handles a child node of type "event" and adds it to the event array.
93+
* @param child The child node to handle.
94+
* @param event The event array to update.
95+
*/
96+
function handleEventChild(child: Node, event: Event[], name: string) {
97+
event.push({
98+
name,
99+
type: child.properties.type as string,
100+
});
101+
}
102+
103+
/**
104+
* Handles a child node of type "property" and adds it to the property object.
105+
* @param child The child node to handle.
106+
* @param property The property object to update.
107+
*/
108+
function handlePropertyChild(child: Node, property: Properties, name: string) {
109+
property[name] = {
110+
name,
111+
exposed: child.properties?.exposed as string,
112+
};
113+
}
114+
97115
/**
98116
* Collect all file URLs in a directory.
99117
*/

0 commit comments

Comments
 (0)