Skip to content

Commit 83332aa

Browse files
authored
HTMLElementAttributeMap 4
1 parent 086aaf3 commit 83332aa

File tree

1 file changed

+115
-23
lines changed

1 file changed

+115
-23
lines changed

src/types.ts

+115-23
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ type MakeUnionsArray<T extends object> = {
2424
* Attribute names must be written in the order listed in the HTML specification.
2525
*/
2626

27+
// TODO: Give HTMLElement to the attribute that specifies the id of the dependent element, and automatically extracts the id
28+
2729
type CommonHTMLAttributes = { // use ABC order
2830
/** @see https://html.spec.whatwg.org/#blocking-attribute */
2931
blocking: "render"
3032
/** @see https://html.spec.whatwg.org/#cors-settings-attribute */
3133
crossorigin: "anonymous" | "" | "use-credentials"
34+
/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time#valid_datetime_values */
35+
datetime: string
3236
/** @see https://html.spec.whatwg.org/#fetch-priority-attribute */
3337
fetchpriority: "high" | "low" | "auto"
3438
/** @see https://html.spec.whatwg.org/#hyperlink */
@@ -44,16 +48,17 @@ type CommonHTMLAttributes = { // use ABC order
4448
}>
4549
/** @see https://drafts.csswg.org/mediaqueries/ @see https://html.spec.whatwg.org/#mq */
4650
media: string // TODO: union
51+
ping: string // TODO: Allow array and URL
4752
/** MIME type */
4853
type: string
4954
referrerpolicy: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url"
5055
/** @see https://html.spec.whatwg.org/#sizes-attribute */
5156
sizes: string // TODO: type
57+
src: string | URL
5258
/** @see https://html.spec.whatwg.org/#srcset-attribute */
5359
srcset: string // TODO: type
5460
/** @see https://html.spec.whatwg.org/#navigable-target-names */
5561
target: "_blank" | "_self" | "_parent" | "_top"
56-
| "_unfencedTop" // Non-standard
5762
}
5863

5964
// based on HTML Living Standard (March 6, 2025)
@@ -109,14 +114,25 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
109114
// attributionsrc: string // Experimental
110115
href: CommonHTMLAttributes["href"]
111116
target: CommonHTMLAttributes["target"]
117+
| "_unfencedTop" // Non-standard
112118
download: string | boolean
113-
ping: string // TODO: Allow array and URL
119+
ping: CommonHTMLAttributes["ping"]
114120
rel: CommonHTMLAttributes["linkTypes"]["a_area"] | string
115121
hreflang: CommonHTMLAttributes["lang"]
116122
type: CommonHTMLAttributes["type"]
117123
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
118124
}
119-
area: {}
125+
area: {
126+
alt: string
127+
coords: string
128+
shape: "circle" | "circ" | "default" | "poly" | "polygon" | "rect" | "rectangle"
129+
href: CommonHTMLAttributes["href"]
130+
target: CommonHTMLAttributes["target"]
131+
download: string
132+
ping: CommonHTMLAttributes["ping"]
133+
rel: CommonHTMLAttributes["linkTypes"]["a_area"]
134+
referrerpolicy: CommonHTMLAttributes["referrerpolicy"]
135+
}
120136
audio: {}
121137
base: {
122138
href: CommonHTMLAttributes["href"]
@@ -137,18 +153,43 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
137153
colgroup: {
138154
span: number
139155
}
140-
data: {}
141-
del: {}
142-
details: {}
143-
dialog: {}
144-
embed: {}
145-
fieldset: {}
156+
data: {
157+
value: string
158+
}
159+
del: {
160+
cite: string
161+
datetime: CommonHTMLAttributes["datetime"]
162+
}
163+
details: {
164+
name: string
165+
open: boolean
166+
}
167+
dialog: {
168+
closedby: "any" | "closerequest" | "none"
169+
open: boolean
170+
}
171+
embed: {
172+
src: CommonHTMLAttributes["src"]
173+
type: CommonHTMLAttributes["type"]
174+
width: number
175+
height: number
176+
}
177+
fieldset: {
178+
disabled: boolean
179+
form: string // a form element
180+
name: string
181+
}
146182
form: {}
147183
iframe: {}
148184
img: {}
149185
input: {}
150-
ins: {}
151-
label: {}
186+
ins: {
187+
cite: string
188+
datetime: CommonHTMLAttributes["datetime"]
189+
}
190+
label: {
191+
for: string
192+
}
152193
li: {}
153194
link: {
154195
href: CommonHTMLAttributes["href"]
@@ -170,15 +211,43 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
170211
disabled: boolean
171212
fetchpriority: CommonHTMLAttributes["fetchpriority"]
172213
}
173-
map: {}
214+
map: {
215+
name: string
216+
}
174217
meta: {}
175-
meter: {}
218+
meter: {
219+
value: number
220+
min: number
221+
max: number
222+
low: number
223+
high: number
224+
optimum: number
225+
}
176226
object: {}
177-
ol: {}
178-
optgroup: {}
179-
option: {}
180-
output: {}
181-
progress: {}
227+
ol: {
228+
reversed: boolean
229+
start: number
230+
type: "1" | "a" | "A" | "i" | "I"
231+
}
232+
optgroup: {
233+
disabled: boolean
234+
label: string
235+
}
236+
option: {
237+
disabled: boolean
238+
label: string
239+
selected: boolean
240+
value: string
241+
}
242+
output: {
243+
for: Array<string> | string
244+
form: string // a form element
245+
name: string
246+
}
247+
progress: {
248+
value: number
249+
max: number
250+
}
182251
q: {
183252
cite: string
184253
}
@@ -190,11 +259,34 @@ export type HTMLElementAttributeMap = HTMLElementAttributeFactory<{
190259
}
191260
source: {}
192261
style: {}
193-
td: {}
194-
template: {}
262+
td: {
263+
colspan: number
264+
rowspan: number
265+
headers: string
266+
}
267+
template: {
268+
shadowrootmode: "open" | "closed"
269+
shadowrootdelegatesfocus: boolean
270+
shadowrootclonable: boolean
271+
shadowrootserializable: boolean
272+
}
195273
textarea: {}
196-
th: {}
197-
time: {}
198-
track: {}
274+
th: {
275+
colspan: number
276+
rowspan: number
277+
headers: string
278+
scope: "row" | "col" | "rowgroup" | "colgroup"
279+
abbr: string
280+
}
281+
time: {
282+
datetime: CommonHTMLAttributes["datetime"]
283+
}
284+
track: {
285+
kind: "subtitles" | "captions" | "descriptions" | "chapters" | "metadata"
286+
src: CommonHTMLAttributes["src"]
287+
srclang: CommonHTMLAttributes["lang"]
288+
label: string
289+
default: boolean
290+
}
199291
video: {}
200292
}>

0 commit comments

Comments
 (0)