Skip to content

Commit 3267a8f

Browse files
committed
Enhance handleProperty function to dynamically handle additional properties from child nodes
1 parent 3082e4f commit 3267a8f

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

inputfiles/overridingTypes.jsonc

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,6 @@
3838
}
3939
}
4040
},
41-
"GlobalEventHandlers": {
42-
"properties": {
43-
"property": {
44-
"onerror": {
45-
"overrideType": "OnErrorEventHandler"
46-
},
47-
"ontouchcancel": {
48-
"optional": true
49-
},
50-
"ontouchend": {
51-
"optional": true
52-
},
53-
"ontouchmove": {
54-
"optional": true
55-
},
56-
"ontouchstart": {
57-
"optional": true
58-
}
59-
}
60-
}
61-
},
6241
"HTMLOrSVGElement": {
6342
"properties": {
6443
"property": {

inputfiles/patches/eventhandlers.kdl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface-mixin GlobalEventHandlers {
2+
property ontouchcancel optional=#true
3+
property ontouchend optional=#true
4+
property ontouchmove optional=#true
5+
property ontouchstart optional=#true
6+
property onerror overrideType=OnErrorEventHandler
7+
}

src/build/patches.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,19 @@ function handleEvent(child: Node): Event {
119119
* @param child The child node to handle.
120120
*/
121121
function handleProperty(child: Node): Partial<Property> {
122-
return {
122+
const result: Partial<Property> = {
123123
name: child.values[0] as string,
124-
exposed: child.properties?.exposed as string,
125124
};
125+
126+
const props: (keyof Property)[] = ["exposed", "optional", "overrideType"];
127+
128+
props.forEach((prop) => {
129+
const value = child.properties[prop];
130+
if (value !== undefined) {
131+
result[prop] = value as any;
132+
}
133+
});
134+
return result;
126135
}
127136

128137
/**

0 commit comments

Comments
 (0)