@@ -73,7 +73,7 @@ type MediaQuery = string
73
73
74
74
// based on HTML Living Standard (March 6, 2025)
75
75
// https://html.spec.whatwg.org/multipage/dom.html#global-attributes
76
- type HTMLElementGlobalAttribute = {
76
+ type HTMLElementGlobalAttributes = {
77
77
id : string
78
78
class : string // TODO: allow array
79
79
@@ -115,15 +115,19 @@ type HTMLElementGlobalAttribute = {
115
115
exportparts : string // CSS Shadow Parts
116
116
}
117
117
118
+ // ---------- Factory ----------
119
+
118
120
type HTMLElementAttributeFactory < T extends Record < string , object > > = {
119
- [ K in keyof T | Exclude < keyof HTMLElementTagNameMap , keyof T > ] : Partial < HTMLElementGlobalAttribute & ( K extends keyof T ? T [ K ] : { } ) >
121
+ [ K in keyof T | Exclude < keyof HTMLElementTagNameMap , keyof T > ] : Partial < HTMLElementGlobalAttributes & ( K extends keyof T ? T [ K ] : { } ) >
120
122
}
121
123
122
124
type HTMLMetaElementAttributeFactory < T extends [ string , unknown , object ?] > = {
123
125
name : T [ 0 ]
124
126
content : T [ 1 ]
125
127
} & T [ 2 ]
126
128
129
+ // --------------------
130
+
127
131
// https://html.spec.whatwg.org/#elements-3
128
132
export type HTMLElementAttributeMap = HTMLElementAttributeFactory < {
129
133
a : {
@@ -165,7 +169,13 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
165
169
blockquote : {
166
170
cite : string
167
171
}
168
- body : { } // generate from WindowEventHandlersEventMap
172
+ body : {
173
+ [ key in Exclude < keyof WindowEventHandlersEventMap ,
174
+ // not found in https://html.spec.whatwg.org/#the-body-element
175
+ "gamepaddisconnected" | "gamepaddisconnected"
176
+ > as `on${key } `] : ( ( this : HTMLBodyElement , event : WindowEventHandlersEventMap [ key ] ) => unknown )
177
+ // onafterprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
178
+ }
169
179
button : {
170
180
command : "toggle-popover" | "show-popover" | "hide-popover" | "close" | "show-modal" | `--${string } ` // Experimental
171
181
commandfor : string // Experimental
0 commit comments