Skip to content

Commit 0bcb115

Browse files
authored
wip: WindowEventHandlersEventMap 6
1 parent f99c226 commit 0bcb115

File tree

1 file changed

+81
-18
lines changed

1 file changed

+81
-18
lines changed

src/types.ts

+81-18
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,20 @@ type MakeUnionsArray<T extends object> = {
3030
// TODO: Give HTMLElement to the attribute that specifies the id of the dependent element, and automatically extracts the id
3131

3232
type CommonHTMLAttributes = { // use ABC order
33+
autocomplete: "on" | "off" | ( string & {} ) | Array<string>
3334
/** @see https://html.spec.whatwg.org/#blocking-attribute */
3435
blocking: "render"
3536
/** @see https://html.spec.whatwg.org/#cors-settings-attribute */
36-
crossorigin: "anonymous" | "" | "use-credentials"
37+
cors: "anonymous" | "" | "use-credentials"
3738
/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time#valid_datetime_values */
3839
datetime: string
3940
/** @see https://html.spec.whatwg.org/#fetch-priority-attribute */
4041
fetchpriority: "high" | "low" | "auto"
4142
/** @see https://w3c.github.io/webappsec-subresource-integrity/ */
4243
integrity: string
4344
lang: string // TODO: Enumeration of all language codes?
45+
/** @see https://html.spec.whatwg.org/#lazy-loading-attribute */
46+
lazyloading: "lazy" | "eager"
4447
/** @see https://html.spec.whatwg.org/#linkTypes */
4548
linkTypes: MakeUnionsArray<{
4649
link: "alternate" | "canonical" | "author" | "dns-prefetch" | "expect" | "help" | "icon" | "manifest" | "modulepreload" | "license" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prev" | "privacy-policy" | "search" | "stylesheet" | "terms-of-service"
@@ -49,6 +52,8 @@ type CommonHTMLAttributes = { // use ABC order
4952
}>
5053
/** @see https://drafts.csswg.org/mediaqueries/ @see https://html.spec.whatwg.org/#mq */
5154
media: string // TODO: union
55+
/** MIME type */
56+
mime: string
5257
ping: string // TODO: Allow array and URL
5358
preload: "auto" | "" | "none" | "metadata"
5459
referrerpolicy: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url"
@@ -59,8 +64,6 @@ type CommonHTMLAttributes = { // use ABC order
5964
srcset: string // TODO: type
6065
/** @see https://html.spec.whatwg.org/#navigable-target-names */
6166
target: "_blank" | "_self" | "_parent" | "_top"
62-
/** MIME type */
63-
type: string
6467
/** @see https://html.spec.whatwg.org/#hyperlink */
6568
url: string | URL
6669
}
@@ -132,7 +135,7 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
132135
ping: CommonHTMLAttributes["ping"]
133136
rel: CommonHTMLAttributes["linkTypes"]["a_area"] | string
134137
hreflang: CommonHTMLAttributes["lang"]
135-
type: CommonHTMLAttributes["type"]
138+
type: CommonHTMLAttributes["mime"]
136139
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
137140
}
138141
area: {
@@ -148,7 +151,7 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
148151
}
149152
audio: {
150153
src: CommonHTMLAttributes["url"]
151-
crossorigin: CommonHTMLAttributes["crossorigin"]
154+
crossorigin: CommonHTMLAttributes["cors"]
152155
preload: CommonHTMLAttributes["preload"]
153156
autoplay: boolean
154157
loop: boolean
@@ -162,7 +165,7 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
162165
blockquote: {
163166
cite: string
164167
}
165-
body: {}
168+
body: {} // generate from WindowEventHandlersEventMap
166169
button: {
167170
command: "toggle-popover" | "show-popover" | "hide-popover" | "close" | "show-modal" | `--${string}` // Experimental
168171
commandfor: string // Experimental
@@ -206,7 +209,7 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
206209
}
207210
embed: {
208211
src: CommonHTMLAttributes["url"]
209-
type: CommonHTMLAttributes["type"]
212+
type: CommonHTMLAttributes["mime"]
210213
width: number
211214
height: number
212215
}
@@ -226,8 +229,34 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
226229
target: CommonHTMLAttributes["target"]
227230
rel: CommonHTMLAttributes["linkTypes"]["form"]
228231
}
229-
iframe: {}
230-
img: {}
232+
iframe: {
233+
src: CommonHTMLAttributes["url"]
234+
srcdoc: string // TODO: add HTMLElement
235+
name: string
236+
sandbox: string | Array<"allow-downloads" | "allow-forms" | "allow-modals" | "allow-orientation-lock" | "allow-pointer-lock" | "allow-popups" | "allow-popups-to-escape-sandbox" | "allow-presentation" | "allow-same-origin" | "allow-scripts" | "allow-top-navigation" | "allow-top-navigation-by-user-activation" | "allow-top-navigation-to-custom-protocols">
237+
/** @see https://html.spec.whatwg.org/#attr-iframe-allow */
238+
allow: string // TODO: union
239+
allowfullscreen: boolean
240+
width: number
241+
height: number
242+
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
243+
loading: CommonHTMLAttributes["lazyloading"]
244+
}
245+
img: {
246+
alt: string
247+
src: CommonHTMLAttributes["url"]
248+
srcset: CommonHTMLAttributes["srcset"]
249+
sizes: CommonHTMLAttributes["sizes"]
250+
crossorigin: CommonHTMLAttributes["cors"]
251+
usemap: `#${string}` // map element's id
252+
ismap: boolean
253+
width: number
254+
height: number
255+
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
256+
decoding: "sync" | "async" | "auto"
257+
loading: CommonHTMLAttributes["lazyloading"]
258+
fetchpriority: CommonHTMLAttributes["fetchpriority"]
259+
}
231260
input: {}
232261
ins: {
233262
cite: string
@@ -236,15 +265,19 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
236265
label: {
237266
for: string
238267
}
239-
li: {}
268+
li: {
269+
value: number
270+
// /** @deprecated */
271+
// type: "1" | "a" | "A" | "i" | "I"
272+
}
240273
link: {
241274
href: CommonHTMLAttributes["url"]
242-
crossorigin: CommonHTMLAttributes["crossorigin"]
275+
crossorigin: CommonHTMLAttributes["cors"]
243276
rel: CommonHTMLAttributes["linkTypes"]["link"]
244277
media: CommonHTMLAttributes["media"]
245278
integrity: CommonHTMLAttributes["integrity"]
246279
hreflang: CommonHTMLAttributes["lang"]
247-
type: CommonHTMLAttributes["type"]
280+
type: CommonHTMLAttributes["mime"]
248281
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
249282
sizes: string // TODO: Type sizes="16x16 32x32 48x48"
250283
imagesrcset: CommonHTMLAttributes["srcset"]
@@ -302,7 +335,7 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
302335
}
303336
object: {
304337
data: CommonHTMLAttributes["url"]
305-
type: CommonHTMLAttributes["type"]
338+
type: CommonHTMLAttributes["mime"]
306339
name: string
307340
form: string // form element
308341
width: number
@@ -335,13 +368,43 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
335368
q: {
336369
cite: string
337370
}
338-
script: {}
339-
select: {}
371+
script: {
372+
src: CommonHTMLAttributes["url"]
373+
type: CommonHTMLAttributes["mime"]
374+
nomodule: boolean
375+
async: boolean
376+
defer: boolean
377+
crossorigin: CommonHTMLAttributes["cors"]
378+
integrity: CommonHTMLAttributes["integrity"]
379+
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
380+
blocking: CommonHTMLAttributes["blocking"]
381+
fetchpriority: CommonHTMLAttributes["fetchpriority"]
382+
}
383+
select: {
384+
autocomplete: CommonHTMLAttributes["autocomplete"]
385+
disabled: boolean
386+
form: string // form element
387+
multiple: boolean
388+
name: string
389+
required: boolean
390+
size: number
391+
}
340392
slot: {
341393
name: string
342394
}
343-
source: {}
344-
style: {}
395+
source: {
396+
type: CommonHTMLAttributes["mime"]
397+
media: MediaQuery
398+
src: CommonHTMLAttributes["url"]
399+
srcset: CommonHTMLAttributes["srcset"]
400+
sizes: CommonHTMLAttributes["sizes"]
401+
width: number
402+
height: number
403+
}
404+
style: {
405+
media: MediaQuery
406+
blocking: CommonHTMLAttributes["blocking"]
407+
}
345408
td: {
346409
colspan: number
347410
rowspan: number
@@ -373,7 +436,7 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
373436
}
374437
video: {
375438
src: CommonHTMLAttributes["url"]
376-
crossorigin: CommonHTMLAttributes["crossorigin"]
439+
crossorigin: CommonHTMLAttributes["cors"]
377440
poster: CommonHTMLAttributes["url"]
378441
preload: CommonHTMLAttributes["preload"]
379442
autoplay: boolean

0 commit comments

Comments
 (0)