html-standard 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -20,2414 +20,309 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- getElementSpec: () => getElementSpec
23
+ accessibility: () => accessibility,
24
+ element: () => element
24
25
  });
25
26
  module.exports = __toCommonJS(index_exports);
26
27
 
27
- // src/elements/index.ts
28
- var elements_exports = {};
29
- __export(elements_exports, {
30
- _var: () => _var,
31
- a: () => a,
32
- abbr: () => abbr,
33
- address: () => address,
34
- area: () => area,
35
- article: () => article,
36
- aside: () => aside,
37
- audio: () => audio,
38
- b: () => b,
39
- base: () => base,
40
- bdi: () => bdi,
41
- bdo: () => bdo,
42
- blockquote: () => blockquote,
43
- body: () => body,
44
- br: () => br,
45
- button: () => button,
46
- canvas: () => canvas,
47
- caption: () => caption,
48
- cite: () => cite,
49
- code: () => code,
50
- col: () => col,
51
- colgroup: () => colgroup,
52
- data: () => data,
53
- datalist: () => datalist,
54
- dd: () => dd,
55
- del: () => del,
56
- details: () => details,
57
- dfn: () => dfn,
58
- dialog: () => dialog,
59
- div: () => div,
60
- dl: () => dl,
61
- dt: () => dt,
62
- em: () => em,
63
- embed: () => embed,
64
- fieldset: () => fieldset,
65
- figcaption: () => figcaption,
66
- figure: () => figure,
67
- footer: () => footer,
68
- form: () => form,
69
- h1: () => h1,
70
- h2: () => h2,
71
- h3: () => h3,
72
- h4: () => h4,
73
- h5: () => h5,
74
- h6: () => h6,
75
- head: () => head,
76
- header: () => header,
77
- hr: () => hr,
78
- hrgroup: () => hrgroup,
79
- html: () => html,
80
- i: () => i,
81
- iframe: () => iframe,
82
- img: () => img,
83
- input: () => input,
84
- ins: () => ins,
85
- kbd: () => kbd,
86
- label: () => label,
87
- legend: () => legend,
88
- li: () => li,
89
- link: () => link,
90
- main: () => main,
91
- map: () => map,
92
- mark: () => mark,
93
- menu: () => menu,
94
- meta: () => meta,
95
- meter: () => meter,
96
- nav: () => nav,
97
- noscript: () => noscript,
98
- object: () => object,
99
- ol: () => ol,
100
- optgroup: () => optgroup,
101
- option: () => option,
102
- output: () => output,
103
- p: () => p,
104
- picture: () => picture,
105
- pre: () => pre,
106
- progress: () => progress,
107
- q: () => q,
108
- rp: () => rp,
109
- rt: () => rt,
110
- ruby: () => ruby,
111
- s: () => s,
112
- samp: () => samp,
113
- script: () => script,
114
- search: () => search,
115
- section: () => section,
116
- select: () => select,
117
- slot: () => slot,
118
- small: () => small,
119
- source: () => source,
120
- span: () => span,
121
- strong: () => strong,
122
- style: () => style,
123
- sub: () => sub,
124
- summary: () => summary,
125
- sup: () => sup,
126
- table: () => table,
127
- tbody: () => tbody,
128
- td: () => td,
129
- template: () => template,
130
- textarea: () => textarea,
131
- tfoot: () => tfoot,
132
- th: () => th,
133
- thead: () => thead,
134
- time: () => time,
135
- title: () => title,
136
- tr: () => tr,
137
- track: () => track,
138
- u: () => u,
139
- ul: () => ul,
140
- video: () => video,
141
- wbr: () => wbr
142
- });
143
-
144
- // src/helpers/contents.ts
145
- var contents = {
146
- fromKeys(...keys) {
147
- return new Set(keys);
148
- },
149
- fromSet(set, ...keys) {
150
- const result = new Set(set);
151
- keys.forEach((key) => set.add(key));
152
- return result;
153
- },
154
- fromUnionSets(setA, setB) {
155
- const set = new Set(...setA, ...setB);
156
- return set;
157
- }
158
- };
159
-
160
- // src/helpers/content-constraint.ts
161
- var contentConstraint = {
162
- fromEntries(entries) {
163
- return new Map(entries);
164
- },
165
- fromSets(value, ...sets) {
166
- return new Map(
167
- sets.reduce((acc, set) => [...acc, ...set], []).map((key) => [key, value])
168
- );
28
+ // src/constants/defaults.ts
29
+ var DEFAULT_ATTRIBUTES_OPTIONS = {
30
+ get(_) {
31
+ return null;
169
32
  }
170
33
  };
171
- var required = {
172
- required: true
173
- };
174
- var onlyOne = {
175
- max: 1
176
- };
177
- var disallow = {
178
- disallow: true
179
- };
180
-
181
- // src/helpers/attributes.ts
182
- var emptyAttributes = /* @__PURE__ */ new Set([]);
183
- var globalAttributes = /* @__PURE__ */ new Set([
184
- "accesskey",
185
- "autocapitalize",
186
- "autocorrect",
187
- "autofocus",
188
- "contenteditable",
189
- "dir",
190
- "draggable",
191
- "enterkeyhint",
192
- "hidden",
193
- "inert",
194
- "inputmode",
195
- "is",
196
- "itemid",
197
- "itemprop",
198
- "itemref",
199
- "itemscope",
200
- "itemtype",
201
- "lang",
202
- "nonce",
203
- "popover",
204
- "spellcheck",
205
- "style",
206
- "tabindex",
207
- "title",
208
- "translate",
209
- "writingsuggestions",
210
- "class",
211
- "id",
212
- "slot",
213
- "xmlns",
214
- "xml:lang",
215
- "xml:space",
216
- // event handlers
217
- "onauxclick",
218
- "onbeforeinput",
219
- "onbeforematch",
220
- "onbeforetoggle",
221
- "onblur",
222
- "oncancel",
223
- "oncanplay",
224
- "oncanplaythrough",
225
- "onchange",
226
- "onclick",
227
- "onclose",
228
- "oncommand",
229
- "oncontextlost",
230
- "oncontextmenu",
231
- "oncontextrestored",
232
- "oncopy",
233
- "oncuechange",
234
- "oncut",
235
- "ondblclick",
236
- "ondrag",
237
- "ondragend",
238
- "ondragenter",
239
- "ondragleave",
240
- "ondragover",
241
- "ondragstart",
242
- "ondrop",
243
- "ondurationchange",
244
- "onemptied",
245
- "onended",
246
- "onerror",
247
- "onfocus",
248
- "onformdata",
249
- "oninput",
250
- "oninvalid",
251
- "onkeydown",
252
- "onkeypress",
253
- "onkeyup",
254
- "onload",
255
- "onloadeddata",
256
- "onloadedmetadata",
257
- "onloadstart",
258
- "onmousedown",
259
- "onmouseenter",
260
- "onmouseleave",
261
- "onmousemove",
262
- "onmouseout",
263
- "onmouseover",
264
- "onmouseup",
265
- "onpaste",
266
- "onpause",
267
- "onplay",
268
- "onplaying",
269
- "onprogress",
270
- "onratechange",
271
- "onreset",
272
- "onresize",
273
- "onscroll",
274
- "onscrollend",
275
- "onsecuritypolicyviolation",
276
- "onseeked",
277
- "onseeking",
278
- "onselect",
279
- "onslotchange",
280
- "onstalled",
281
- "onsubmit",
282
- "onsuspend",
283
- "ontimeupdate",
284
- "ontoggle",
285
- "onvolumechange",
286
- "onwaiting",
287
- "onwheel"
288
- ]);
289
-
290
- // src/helpers/content-attributes.ts
291
- var contentAttributes = (global, specific) => {
292
- if (!specific || specific.length === 0) {
293
- if (global) {
294
- return globalAttributes;
34
+ var DEFAULT_ELEMENT_OPTIONS = {
35
+ attributes: {
36
+ get(_) {
37
+ return null;
295
38
  }
296
- return emptyAttributes;
297
39
  }
298
- const specificAttributes = new Set(specific);
299
- return {
300
- has(name) {
301
- const key = name.toLowerCase();
302
- if (key.startsWith("data-")) {
303
- return true;
304
- }
305
- return globalAttributes.has(key) || specificAttributes.has(key);
306
- }
307
- };
308
- };
309
-
310
- // src/helpers/contents-preset.ts
311
- var contentsPreset = {
312
- metadataContent: /* @__PURE__ */ new Set([
313
- "base",
314
- "link",
315
- "meta",
316
- "noscript",
317
- "script",
318
- "style",
319
- "template",
320
- "title"
321
- ]),
322
- flowContent: /* @__PURE__ */ new Set([
323
- "a",
324
- "abbr",
325
- "address",
326
- "area",
327
- "article",
328
- "aside",
329
- "audio",
330
- "b",
331
- "bdi",
332
- "bdo",
333
- "blockquote",
334
- "br",
335
- "button",
336
- "canvas",
337
- "cite",
338
- "code",
339
- "data",
340
- "datalist",
341
- "del",
342
- "details",
343
- "dfn",
344
- "dialog",
345
- "div",
346
- "dl",
347
- "em",
348
- "embed",
349
- "fieldset",
350
- "figure",
351
- "footer",
352
- "form",
353
- "h1",
354
- "h2",
355
- "h3",
356
- "h4",
357
- "h5",
358
- "h6",
359
- "header",
360
- "hgroup",
361
- "hr",
362
- "i",
363
- "iframe",
364
- "img",
365
- "input",
366
- "ins",
367
- "kbd",
368
- "label",
369
- "link",
370
- "main",
371
- "map",
372
- "mark",
373
- "math",
374
- "menu",
375
- "meta",
376
- "meter",
377
- "nav",
378
- "noscript",
379
- "object",
380
- "ol",
381
- "output",
382
- "p",
383
- "picture",
384
- "pre",
385
- "progress",
386
- "q",
387
- "ruby",
388
- "s",
389
- "samp",
390
- "script",
391
- "search",
392
- "section",
393
- "select",
394
- "slot",
395
- "small",
396
- "span",
397
- "strong",
398
- "sub",
399
- "sup",
400
- "svg",
401
- "table",
402
- "template",
403
- "textarea",
404
- "time",
405
- "u",
406
- "ul",
407
- "var",
408
- "video",
409
- "wbr",
410
- "#text"
411
- ]),
412
- phrasingContent: /* @__PURE__ */ new Set([
413
- "a",
414
- "abbr",
415
- "area",
416
- "audio",
417
- "b",
418
- "bdi",
419
- "bdo",
420
- "br",
421
- "button",
422
- "canvas",
423
- "cite",
424
- "code",
425
- "data",
426
- "datalist",
427
- "del",
428
- "dfn",
429
- "em",
430
- "embed",
431
- "i",
432
- "iframe",
433
- "img",
434
- "input",
435
- "ins",
436
- "kbd",
437
- "label",
438
- "link",
439
- "map",
440
- "mark",
441
- "math",
442
- "meta",
443
- "meter",
444
- "noscript",
445
- "object",
446
- "output",
447
- "picture",
448
- "progress",
449
- "q",
450
- "ruby",
451
- "s",
452
- "samp",
453
- "script",
454
- "select",
455
- "slot",
456
- "small",
457
- "span",
458
- "strong",
459
- "sub",
460
- "sup",
461
- "svg",
462
- "template",
463
- "textarea",
464
- "time",
465
- "u",
466
- "var",
467
- "video",
468
- "wbr",
469
- "#text"
470
- ]),
471
- scriptSupportingElements: /* @__PURE__ */ new Set(["script", "template"]),
472
- headingContent: /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6", "hgroup"]),
473
- sectioningContent: /* @__PURE__ */ new Set(["article", "aside", "nav", "section"]),
474
- transparentContent: /* @__PURE__ */ new Set(["#transparent"]),
475
- interactiveContent: /* @__PURE__ */ new Set([
476
- "a",
477
- "audio",
478
- "button",
479
- "details",
480
- "embed",
481
- "iframe",
482
- "img",
483
- "input",
484
- "label",
485
- "select",
486
- "text",
487
- "area",
488
- "video"
489
- ]),
490
- text: new Set("#text"),
491
- mediaElements: /* @__PURE__ */ new Set(["audio", "video"]),
492
- labelableElements: /* @__PURE__ */ new Set([
493
- "button",
494
- "input",
495
- "meter",
496
- "output",
497
- "progress",
498
- "select",
499
- "textarea"
500
- ])
501
- };
502
-
503
- // src/elements/html.ts
504
- var htmlSpec = {
505
- contents: [
506
- {
507
- type: "required",
508
- contents: contents.fromKeys("head")
509
- },
510
- {
511
- type: "required",
512
- contents: contents.fromKeys("body")
513
- }
514
- ],
515
- attributes: contentAttributes(true)
516
- };
517
- var html = () => htmlSpec;
518
-
519
- // src/elements/head.ts
520
- var headSpec = {
521
- contents: [
522
- {
523
- type: "oneOrMore",
524
- contents: contentsPreset.metadataContent,
525
- constraints: {
526
- children: contentConstraint.fromEntries([
527
- ["title", required],
528
- ["base", onlyOne]
529
- ])
530
- }
531
- }
532
- ],
533
- attributes: contentAttributes(true)
534
- };
535
- var head = () => headSpec;
536
-
537
- // src/elements/title.ts
538
- var titleSpec = {
539
- contents: [
540
- {
541
- type: "required",
542
- contents: contentsPreset.text
543
- }
544
- ],
545
- attributes: contentAttributes(true)
546
- };
547
- var title = () => titleSpec;
548
-
549
- // src/elements/base.ts
550
- var baseSpec = {
551
- contents: null,
552
- attributes: contentAttributes(true, ["href", "target"])
553
- };
554
- var base = () => baseSpec;
555
-
556
- // src/elements/link.ts
557
- var linkSpec = {
558
- contents: null,
559
- attributes: contentAttributes(true, [
560
- "href",
561
- "crossorigin",
562
- "rel",
563
- "media",
564
- "integrity",
565
- "hreflang",
566
- "type",
567
- "referrerpolicy",
568
- "sizes",
569
- "imagesrcset",
570
- "imagesizes",
571
- "as",
572
- "blocking",
573
- "color",
574
- "disabled",
575
- "fetchpriority",
576
- "title"
577
- ])
578
- };
579
- var link = () => linkSpec;
580
-
581
- // src/elements/meta.ts
582
- var metaSpec = {
583
- contents: null,
584
- attributes: contentAttributes(true, [
585
- "name",
586
- "http-equiv",
587
- "content",
588
- "charset",
589
- "media"
590
- ])
591
- };
592
- var meta = () => metaSpec;
593
-
594
- // src/elements/style.ts
595
- var styleSpec = {
596
- contents: [
597
- {
598
- type: "required",
599
- contents: contentsPreset.text
600
- }
601
- ],
602
- attributes: contentAttributes(true, ["media", "blocking", "title"])
603
- };
604
- var style = () => styleSpec;
605
-
606
- // src/elements/body.ts
607
- var bodySpec = {
608
- contents: [
609
- {
610
- type: "oneOrMore",
611
- contents: contentsPreset.flowContent
612
- }
613
- ],
614
- attributes: contentAttributes(true, [
615
- "onafterprint",
616
- "onbeforeprint",
617
- "onbeforeunload",
618
- "onhashchange",
619
- "onlanguagechange",
620
- "onmessage",
621
- "onmessageerror",
622
- "onoffline",
623
- "ononline",
624
- "onpageswap",
625
- "onpagehide",
626
- "onpagereveal",
627
- "onpageshow",
628
- "onpopstate",
629
- "onrejectionhandled",
630
- "onstorage",
631
- "onunhandledrejection",
632
- "onunload"
633
- ])
634
- };
635
- var body = () => bodySpec;
636
-
637
- // src/elements/article.ts
638
- var articleSpec = {
639
- contents: [
640
- {
641
- type: "oneOrMore",
642
- contents: contentsPreset.flowContent
643
- }
644
- ],
645
- attributes: contentAttributes(true)
646
- };
647
- var article = () => articleSpec;
648
-
649
- // src/elements/section.ts
650
- var sectionSpec = {
651
- contents: [
652
- {
653
- type: "oneOrMore",
654
- contents: contentsPreset.flowContent
655
- }
656
- ],
657
- attributes: contentAttributes(true)
658
- };
659
- var section = () => sectionSpec;
660
-
661
- // src/elements/nav.ts
662
- var navSpec = {
663
- contents: [
664
- {
665
- type: "oneOrMore",
666
- contents: contentsPreset.flowContent
667
- }
668
- ],
669
- attributes: contentAttributes(true)
670
- };
671
- var nav = () => navSpec;
672
-
673
- // src/elements/aside.ts
674
- var asideSpec = {
675
- contents: [
676
- {
677
- type: "oneOrMore",
678
- contents: contentsPreset.flowContent
679
- }
680
- ],
681
- attributes: contentAttributes(true)
682
- };
683
- var aside = () => asideSpec;
684
-
685
- // src/elements/h1.ts
686
- var h1Spec = {
687
- contents: [
688
- {
689
- type: "oneOrMore",
690
- contents: contentsPreset.phrasingContent
691
- }
692
- ],
693
- attributes: contentAttributes(true)
694
- };
695
- var h1 = () => h1Spec;
696
-
697
- // src/elements/h2.ts
698
- var h2 = h1;
699
-
700
- // src/elements/h3.ts
701
- var h3 = h1;
702
-
703
- // src/elements/h4.ts
704
- var h4 = h1;
705
-
706
- // src/elements/h5.ts
707
- var h5 = h1;
708
-
709
- // src/elements/h6.ts
710
- var h6 = h1;
711
-
712
- // src/elements/hrgroup.ts
713
- var hrgroupSpec = {
714
- contents: [
715
- {
716
- type: "zeroOrMore",
717
- contents: contentsPreset.scriptSupportingElements
718
- },
719
- {
720
- type: "zeroOrMore",
721
- contents: contents.fromKeys("p")
722
- },
723
- {
724
- type: "zeroOrMore",
725
- contents: contentsPreset.scriptSupportingElements
726
- },
727
- {
728
- type: "required",
729
- contents: contents.fromKeys("h1", "h2", "h3", "h4", "h5", "h6")
730
- },
731
- {
732
- type: "zeroOrMore",
733
- contents: contentsPreset.scriptSupportingElements
734
- },
735
- {
736
- type: "zeroOrMore",
737
- contents: contents.fromKeys("p")
738
- },
739
- {
740
- type: "zeroOrMore",
741
- contents: contentsPreset.scriptSupportingElements
742
- }
743
- ],
744
- attributes: contentAttributes(true)
745
- };
746
- var hrgroup = () => hrgroupSpec;
747
-
748
- // src/elements/header.ts
749
- var headerSpec = {
750
- contents: [
751
- {
752
- type: "oneOrMore",
753
- contents: contentsPreset.flowContent,
754
- constraints: {
755
- descendants: contentConstraint.fromSets(
756
- disallow,
757
- /* @__PURE__ */ new Set(["header", "footer"])
758
- )
759
- }
760
- }
761
- ],
762
- attributes: contentAttributes(true)
763
- };
764
- var header = () => headerSpec;
765
-
766
- // src/elements/footer.ts
767
- var footerSpec = {
768
- contents: [
769
- {
770
- type: "oneOrMore",
771
- contents: contentsPreset.flowContent,
772
- constraints: {
773
- descendants: contentConstraint.fromSets(
774
- disallow,
775
- /* @__PURE__ */ new Set(["header", "footer"])
776
- )
777
- }
778
- }
779
- ],
780
- attributes: contentAttributes(true)
781
- };
782
- var footer = () => footerSpec;
783
-
784
- // src/elements/address.ts
785
- var addressSpec = {
786
- contents: [
787
- {
788
- type: "oneOrMore",
789
- contents: contentsPreset.flowContent,
790
- constraints: {
791
- descendants: contentConstraint.fromSets(
792
- disallow,
793
- contentsPreset.headingContent,
794
- contentsPreset.sectioningContent,
795
- /* @__PURE__ */ new Set(["header", "footer", "address"])
796
- )
797
- }
798
- }
799
- ],
800
- attributes: contentAttributes(true)
801
- };
802
- var address = () => addressSpec;
803
-
804
- // src/elements/p.ts
805
- var pSpec = {
806
- contents: [
807
- {
808
- type: "oneOrMore",
809
- contents: contentsPreset.phrasingContent
810
- }
811
- ],
812
- attributes: contentAttributes(true)
813
- };
814
- var p = () => pSpec;
815
-
816
- // src/elements/hr.ts
817
- var hrSpec = {
818
- contents: null,
819
- attributes: contentAttributes(true)
820
- };
821
- var hr = () => hrSpec;
822
-
823
- // src/elements/pre.ts
824
- var preSpec = {
825
- contents: [
826
- {
827
- type: "oneOrMore",
828
- contents: contentsPreset.phrasingContent
829
- }
830
- ],
831
- attributes: contentAttributes(true)
832
- };
833
- var pre = () => preSpec;
834
-
835
- // src/elements/blockquote.ts
836
- var blockquoteSpec = {
837
- contents: [
838
- {
839
- type: "oneOrMore",
840
- contents: contentsPreset.flowContent
841
- }
842
- ],
843
- attributes: contentAttributes(true, ["cite"])
844
- };
845
- var blockquote = () => blockquoteSpec;
846
-
847
- // src/elements/ol.ts
848
- var olSpec = {
849
- contents: [
850
- {
851
- type: "zeroOrMore",
852
- contents: contents.fromSet(contentsPreset.scriptSupportingElements, "li")
853
- }
854
- ],
855
- attributes: contentAttributes(true, ["reversed", "start", "type"])
856
- };
857
- var ol = () => olSpec;
858
-
859
- // src/elements/ul.ts
860
- var ulSpec = {
861
- contents: [
862
- {
863
- type: "zeroOrMore",
864
- contents: contents.fromSet(contentsPreset.scriptSupportingElements, "li")
865
- }
866
- ],
867
- attributes: contentAttributes(true)
868
- };
869
- var ul = () => ulSpec;
870
-
871
- // src/elements/menu.ts
872
- var menuSpec = {
873
- contents: [
874
- {
875
- type: "zeroOrMore",
876
- contents: contents.fromSet(contentsPreset.scriptSupportingElements, "li")
877
- }
878
- ],
879
- attributes: contentAttributes(true)
880
40
  };
881
- var menu = () => menuSpec;
882
41
 
883
- // src/elements/li.ts
884
- var liInMenuOrUl = {
885
- contents: [
886
- {
887
- type: "oneOrMore",
888
- contents: contentsPreset.flowContent
889
- }
890
- ],
891
- attributes: contentAttributes(true)
892
- };
893
- var liNotInMenuOrUl = {
894
- contents: [
895
- {
896
- type: "oneOrMore",
897
- contents: contentsPreset.flowContent
898
- }
899
- ],
900
- attributes: contentAttributes(true, ["value"])
901
- };
902
- var li = (state) => {
903
- const parent = state == null ? void 0 : state.parent;
904
- if (parent === "menu" || parent === "ul") {
905
- return liInMenuOrUl;
42
+ // src/core/attribute-state.ts
43
+ var AttributeState = class {
44
+ constructor(options = DEFAULT_ATTRIBUTES_OPTIONS) {
45
+ this.options = options;
906
46
  }
907
- return liNotInMenuOrUl;
908
- };
909
-
910
- // src/elements/dl.ts
911
- var dlSpec = {
912
- contents: [
913
- {
914
- type: "either",
915
- options: [
916
- [
917
- {
918
- type: "zeroOrMore",
919
- contents: contentsPreset.scriptSupportingElements
920
- },
921
- {
922
- type: "oneOrMore",
923
- contents: /* @__PURE__ */ new Set(["dt"])
924
- },
925
- {
926
- type: "zeroOrMore",
927
- contents: contentsPreset.scriptSupportingElements
928
- },
929
- {
930
- type: "oneOrMore",
931
- contents: /* @__PURE__ */ new Set(["dd"])
932
- },
933
- {
934
- type: "zeroOrMore",
935
- contents: contentsPreset.scriptSupportingElements
936
- }
937
- ],
938
- [
939
- {
940
- type: "zeroOrMore",
941
- contents: contentsPreset.scriptSupportingElements
942
- },
943
- {
944
- type: "oneOrMore",
945
- contents: /* @__PURE__ */ new Set(["div"])
946
- },
947
- {
948
- type: "zeroOrMore",
949
- contents: contentsPreset.scriptSupportingElements
950
- }
951
- ]
952
- ]
953
- }
954
- ],
955
- attributes: contentAttributes(true)
956
- };
957
- var dl = () => dlSpec;
958
-
959
- // src/elements/dt.ts
960
- var dtSpec = {
961
- contents: [
962
- {
963
- type: "oneOrMore",
964
- contents: contentsPreset.flowContent,
965
- constraints: {
966
- descendants: contentConstraint.fromSets(
967
- disallow,
968
- /* @__PURE__ */ new Set(["header", "footer"]),
969
- contentsPreset.sectioningContent,
970
- contentsPreset.headingContent
971
- )
972
- }
973
- }
974
- ],
975
- attributes: contentAttributes(true)
976
- };
977
- var dt = () => dtSpec;
978
-
979
- // src/elements/dd.ts
980
- var ddSpec = {
981
- contents: [
982
- {
983
- type: "oneOrMore",
984
- contents: contentsPreset.flowContent
985
- }
986
- ],
987
- attributes: contentAttributes(true)
988
- };
989
- var dd = () => ddSpec;
990
-
991
- // src/elements/figure.ts
992
- var figureSpec = {
993
- contents: [
994
- {
995
- type: "either",
996
- options: [
997
- [
998
- {
999
- type: "required",
1000
- contents: new Set("figcaption")
1001
- },
1002
- {
1003
- type: "oneOrMore",
1004
- contents: contentsPreset.flowContent
1005
- }
1006
- ],
1007
- [
1008
- {
1009
- type: "oneOrMore",
1010
- contents: contentsPreset.flowContent
1011
- },
1012
- {
1013
- type: "required",
1014
- contents: contents.fromKeys("figcaption")
1015
- }
1016
- ],
1017
- [
1018
- {
1019
- type: "oneOrMore",
1020
- contents: contentsPreset.flowContent
1021
- }
1022
- ]
1023
- ]
1024
- }
1025
- ],
1026
- attributes: contentAttributes(true)
1027
- };
1028
- var figure = () => figureSpec;
1029
-
1030
- // src/elements/figcaption.ts
1031
- var figcaptionSpec = {
1032
- contents: [
1033
- {
1034
- type: "oneOrMore",
1035
- contents: contentsPreset.flowContent
1036
- }
1037
- ],
1038
- attributes: contentAttributes(true)
1039
- };
1040
- var figcaption = () => figcaptionSpec;
1041
-
1042
- // src/elements/main.ts
1043
- var mainSpec = {
1044
- contents: [
1045
- {
1046
- type: "oneOrMore",
1047
- contents: contentsPreset.flowContent
1048
- }
1049
- ],
1050
- attributes: contentAttributes(true)
1051
- };
1052
- var main = () => mainSpec;
1053
-
1054
- // src/elements/search.ts
1055
- var searchSpec = {
1056
- contents: [
1057
- {
1058
- type: "oneOrMore",
1059
- contents: contentsPreset.flowContent
1060
- }
1061
- ],
1062
- attributes: contentAttributes(true)
1063
- };
1064
- var search = () => searchSpec;
1065
-
1066
- // src/elements/div.ts
1067
- var divChildOfDlSpec = {
1068
- contents: [
1069
- {
1070
- type: "zeroOrMore",
1071
- contents: contentsPreset.scriptSupportingElements
1072
- },
1073
- {
1074
- type: "oneOrMore",
1075
- contents: contents.fromKeys("dt")
1076
- },
1077
- {
1078
- type: "zeroOrMore",
1079
- contents: contentsPreset.scriptSupportingElements
1080
- },
1081
- {
1082
- type: "oneOrMore",
1083
- contents: contents.fromKeys("dd")
1084
- }
1085
- ],
1086
- attributes: contentAttributes(true)
1087
- };
1088
- var divSpec = {
1089
- contents: [
1090
- {
1091
- type: "oneOrMore",
1092
- contents: contentsPreset.flowContent
1093
- }
1094
- ],
1095
- attributes: contentAttributes(true)
1096
- };
1097
- var div = (state) => {
1098
- const parent = state == null ? void 0 : state.parent;
1099
- if (parent === "dl") {
1100
- return divChildOfDlSpec;
47
+ get(key) {
48
+ return this.options.get(key);
1101
49
  }
1102
- return divSpec;
1103
- };
1104
-
1105
- // src/elements/a.ts
1106
- var descendantsConstraints = new Map(
1107
- [contentsPreset.interactiveContent, /* @__PURE__ */ new Set(["a"])].reduce((acc, set) => [...acc, ...set], []).map((key) => [key, disallow])
1108
- );
1109
- descendantsConstraints.set("*", {
1110
- disallow: true,
1111
- ifAttributes(attributes5) {
1112
- return !!attributes5["tabindex"];
50
+ has(key) {
51
+ return this.options.get(key) !== null;
1113
52
  }
1114
- });
1115
- var aSpec = {
1116
- contents: [
1117
- {
1118
- type: "oneOrMore",
1119
- contents: contentsPreset.transparentContent,
1120
- constraints: {
1121
- descendants: contentConstraint.fromSets(
1122
- disallow,
1123
- contentsPreset.interactiveContent,
1124
- /* @__PURE__ */ new Set(["a"])
1125
- )
1126
- }
1127
- }
1128
- ],
1129
- attributes: contentAttributes(true, [
1130
- "href",
1131
- "target",
1132
- "download",
1133
- "ping",
1134
- "rel",
1135
- "hreflang",
1136
- "type",
1137
- "referrerpolicy"
1138
- ])
1139
53
  };
1140
- var a = () => aSpec;
1141
54
 
1142
- // src/elements/em.ts
1143
- var emSpec = {
1144
- contents: [
1145
- {
1146
- type: "oneOrMore",
1147
- contents: contentsPreset.phrasingContent
1148
- }
1149
- ],
1150
- attributes: contentAttributes(true)
1151
- };
1152
- var em = () => emSpec;
1153
-
1154
- // src/elements/strong.ts
1155
- var strongSpec = {
1156
- contents: [
1157
- {
1158
- type: "oneOrMore",
1159
- contents: contentsPreset.phrasingContent
1160
- }
1161
- ],
1162
- attributes: contentAttributes(true)
1163
- };
1164
- var strong = () => strongSpec;
1165
-
1166
- // src/elements/small.ts
1167
- var smallSpec = {
1168
- contents: [
1169
- {
1170
- type: "oneOrMore",
1171
- contents: contentsPreset.phrasingContent
1172
- }
1173
- ],
1174
- attributes: contentAttributes(true)
1175
- };
1176
- var small = () => smallSpec;
1177
-
1178
- // src/elements/s.ts
1179
- var sSpec = {
1180
- contents: [
1181
- {
1182
- type: "oneOrMore",
1183
- contents: contentsPreset.phrasingContent
1184
- }
1185
- ],
1186
- attributes: contentAttributes(true)
1187
- };
1188
- var s = () => sSpec;
1189
-
1190
- // src/elements/cite.ts
1191
- var citeSpec = {
1192
- contents: [
1193
- {
1194
- type: "oneOrMore",
1195
- contents: contentsPreset.phrasingContent
1196
- }
1197
- ],
1198
- attributes: contentAttributes(true)
1199
- };
1200
- var cite = () => citeSpec;
1201
-
1202
- // src/elements/q.ts
1203
- var qSpec = {
1204
- contents: [
1205
- {
1206
- type: "oneOrMore",
1207
- contents: contentsPreset.phrasingContent
1208
- }
1209
- ],
1210
- attributes: contentAttributes(true, ["cite"])
1211
- };
1212
- var q = () => qSpec;
1213
-
1214
- // src/elements/dfn.ts
1215
- var dfnSpec = {
1216
- contents: [
1217
- {
1218
- type: "oneOrMore",
1219
- contents: contentsPreset.phrasingContent,
1220
- constraints: {
1221
- descendants: contentConstraint.fromEntries([["dfn", disallow]])
1222
- }
1223
- }
1224
- ],
1225
- attributes: contentAttributes(true)
1226
- };
1227
- var dfn = () => dfnSpec;
1228
-
1229
- // src/elements/abbr.ts
1230
- var abbrSpec = {
1231
- contents: [
1232
- {
1233
- type: "oneOrMore",
1234
- contents: contentsPreset.phrasingContent
1235
- }
1236
- ],
1237
- attributes: contentAttributes(true)
1238
- };
1239
- var abbr = () => abbrSpec;
1240
-
1241
- // src/elements/ruby.ts
1242
- var rubySpec = {
1243
- contents: [
1244
- {
1245
- type: "zeroOrMore",
1246
- contents: contents.fromSet(contentsPreset.phrasingContent, "rt", "rp")
1247
- }
1248
- ],
1249
- attributes: contentAttributes(true)
1250
- };
1251
- var ruby = () => rubySpec;
1252
-
1253
- // src/elements/rt.ts
1254
- var rtSpec = {
1255
- contents: [
1256
- {
1257
- type: "oneOrMore",
1258
- contents: contentsPreset.phrasingContent
1259
- }
1260
- ],
1261
- attributes: contentAttributes(true)
1262
- };
1263
- var rt = () => rtSpec;
1264
-
1265
- // src/elements/rp.ts
1266
- var rpSpec = {
1267
- contents: [
1268
- {
1269
- type: "oneOrMore",
1270
- contents: contentsPreset.text
1271
- }
1272
- ],
1273
- attributes: contentAttributes(true)
1274
- };
1275
- var rp = () => rpSpec;
1276
-
1277
- // src/elements/data.ts
1278
- var dataSpec = {
1279
- contents: [
1280
- {
1281
- type: "oneOrMore",
1282
- contents: contentsPreset.phrasingContent
1283
- }
1284
- ],
1285
- attributes: contentAttributes(true, ["value"])
1286
- };
1287
- var data = () => dataSpec;
1288
-
1289
- // src/elements/time.ts
1290
- var timeWihthoutDatetimeSpec = {
1291
- contents: [
1292
- {
1293
- type: "oneOrMore",
1294
- contents: contentsPreset.phrasingContent
1295
- }
1296
- ],
1297
- attributes: contentAttributes(true, ["datetime"])
1298
- };
1299
- var timeWithDatetimeSpec = {
1300
- contents: [
1301
- {
1302
- type: "oneOrMore",
1303
- contents: contentsPreset.text
1304
- }
1305
- ],
1306
- attributes: contentAttributes(true, ["datetime"])
1307
- };
1308
- var time = (state) => {
1309
- const attributes5 = (state == null ? void 0 : state.attributes) || {};
1310
- if (!!attributes5["datetime"]) {
1311
- return timeWihthoutDatetimeSpec;
55
+ // src/core/element-state.ts
56
+ var ElementState = class _ElementState {
57
+ constructor(name, options) {
58
+ this.options = options;
59
+ this.name = name.toLowerCase();
1312
60
  }
1313
- return timeWithDatetimeSpec;
1314
- };
1315
-
1316
- // src/elements/code.ts
1317
- var codeSpec = {
1318
- contents: [
1319
- {
1320
- type: "oneOrMore",
1321
- contents: contentsPreset.phrasingContent
1322
- }
1323
- ],
1324
- attributes: contentAttributes(true)
1325
- };
1326
- var code = () => codeSpec;
1327
-
1328
- // src/elements/var.ts
1329
- var varSpec = {
1330
- contents: [
1331
- {
1332
- type: "oneOrMore",
1333
- contents: contentsPreset.phrasingContent
1334
- }
1335
- ],
1336
- attributes: contentAttributes(true)
1337
- };
1338
- var _var = () => varSpec;
1339
-
1340
- // src/elements/samp.ts
1341
- var sampSpec = {
1342
- contents: [
1343
- {
1344
- type: "oneOrMore",
1345
- contents: contentsPreset.phrasingContent
1346
- }
1347
- ],
1348
- attributes: contentAttributes(true)
1349
- };
1350
- var samp = () => sampSpec;
1351
-
1352
- // src/elements/kbd.ts
1353
- var kbdSpec = {
1354
- contents: [
1355
- {
1356
- type: "oneOrMore",
1357
- contents: contentsPreset.phrasingContent
1358
- }
1359
- ],
1360
- attributes: contentAttributes(true)
1361
- };
1362
- var kbd = () => kbdSpec;
1363
-
1364
- // src/elements/sub.ts
1365
- var subSpec = {
1366
- contents: [
1367
- {
1368
- type: "oneOrMore",
1369
- contents: contentsPreset.phrasingContent
1370
- }
1371
- ],
1372
- attributes: contentAttributes(true)
1373
- };
1374
- var sub = () => subSpec;
1375
-
1376
- // src/elements/sup.ts
1377
- var sup = sub;
1378
-
1379
- // src/elements/i.ts
1380
- var iSpec = {
1381
- contents: [
1382
- {
1383
- type: "oneOrMore",
1384
- contents: contentsPreset.phrasingContent
1385
- }
1386
- ],
1387
- attributes: contentAttributes(true)
1388
- };
1389
- var i = () => iSpec;
1390
-
1391
- // src/elements/b.ts
1392
- var bSpec = {
1393
- contents: [
1394
- {
1395
- type: "oneOrMore",
1396
- contents: contentsPreset.phrasingContent
1397
- }
1398
- ],
1399
- attributes: contentAttributes(true)
1400
- };
1401
- var b = () => bSpec;
1402
-
1403
- // src/elements/u.ts
1404
- var uSpec = {
1405
- contents: [
1406
- {
1407
- type: "oneOrMore",
1408
- contents: contentsPreset.phrasingContent
1409
- }
1410
- ],
1411
- attributes: contentAttributes(true)
1412
- };
1413
- var u = () => uSpec;
1414
-
1415
- // src/elements/mark.ts
1416
- var markSpec = {
1417
- contents: [
1418
- {
1419
- type: "oneOrMore",
1420
- contents: contentsPreset.phrasingContent
1421
- }
1422
- ],
1423
- attributes: contentAttributes(true)
1424
- };
1425
- var mark = () => markSpec;
1426
-
1427
- // src/elements/bdi.ts
1428
- var bdiSpec = {
1429
- contents: [
1430
- {
1431
- type: "oneOrMore",
1432
- contents: contentsPreset.phrasingContent
1433
- }
1434
- ],
1435
- attributes: contentAttributes(true)
1436
- };
1437
- var bdi = () => bdiSpec;
1438
-
1439
- // src/elements/bdo.ts
1440
- var bdoSpec = {
1441
- contents: [
1442
- {
1443
- type: "oneOrMore",
1444
- contents: contentsPreset.phrasingContent
1445
- }
1446
- ],
1447
- attributes: contentAttributes(true)
1448
- };
1449
- var bdo = () => bdoSpec;
1450
-
1451
- // src/elements/span.ts
1452
- var spanSpec = {
1453
- contents: [
1454
- {
1455
- type: "oneOrMore",
1456
- contents: contentsPreset.phrasingContent
1457
- }
1458
- ],
1459
- attributes: contentAttributes(true)
1460
- };
1461
- var span = () => spanSpec;
1462
-
1463
- // src/elements/br.ts
1464
- var brSpec = {
1465
- contents: null,
1466
- attributes: contentAttributes(true)
1467
- };
1468
- var br = () => brSpec;
1469
-
1470
- // src/elements/wbr.ts
1471
- var wbrSpec = {
1472
- contents: null,
1473
- attributes: contentAttributes(true)
1474
- };
1475
- var wbr = () => wbrSpec;
1476
-
1477
- // src/elements/ins.ts
1478
- var insSpec = {
1479
- contents: [
1480
- {
1481
- type: "oneOrMore",
1482
- contents: contentsPreset.transparentContent
1483
- }
1484
- ],
1485
- attributes: contentAttributes(true, ["cite", "datetime"])
1486
- };
1487
- var ins = () => insSpec;
1488
-
1489
- // src/elements/del.ts
1490
- var delSpec = {
1491
- contents: [
1492
- {
1493
- type: "oneOrMore",
1494
- contents: contentsPreset.transparentContent
1495
- }
1496
- ],
1497
- attributes: contentAttributes(true, ["cite", "datetime"])
1498
- };
1499
- var del = () => delSpec;
1500
-
1501
- // src/elements/picture.ts
1502
- var pictureSpec = {
1503
- contents: [
1504
- {
1505
- type: "zeroOrMore",
1506
- contents: contentsPreset.scriptSupportingElements
1507
- },
1508
- {
1509
- type: "zeroOrMore",
1510
- contents: contents.fromKeys("source")
1511
- },
1512
- {
1513
- type: "zeroOrMore",
1514
- contents: contentsPreset.scriptSupportingElements
1515
- },
1516
- {
1517
- type: "required",
1518
- contents: contents.fromKeys("img")
1519
- },
1520
- {
1521
- type: "zeroOrMore",
1522
- contents: contentsPreset.scriptSupportingElements
1523
- }
1524
- ],
1525
- attributes: contentAttributes(true)
1526
- };
1527
- var picture = () => pictureSpec;
1528
-
1529
- // src/elements/source.ts
1530
- var sourceSpec = {
1531
- contents: null,
1532
- attributes: contentAttributes(true, [
1533
- "type",
1534
- "media",
1535
- "src",
1536
- "srcset",
1537
- "sizes",
1538
- "width",
1539
- "height"
1540
- ])
1541
- };
1542
- var source = () => sourceSpec;
1543
-
1544
- // src/elements/img.ts
1545
- var imgSpec = {
1546
- contents: null,
1547
- attributes: contentAttributes(true, [
1548
- "alt",
1549
- "src",
1550
- "srcset",
1551
- "sizes",
1552
- "crossorigin",
1553
- "usemap",
1554
- "ismap",
1555
- "width",
1556
- "height",
1557
- "referrerpolicy",
1558
- "decoding",
1559
- "loading",
1560
- "fetchpriority"
1561
- ])
1562
- };
1563
- var img = () => imgSpec;
1564
-
1565
- // src/elements/iframe.ts
1566
- var iframeSpec = {
1567
- contents: null,
1568
- attributes: contentAttributes(true, [
1569
- "src",
1570
- "srcdoc",
1571
- "name",
1572
- "sandbox",
1573
- "allow",
1574
- "allowfullscreen",
1575
- "width",
1576
- "height",
1577
- "referrerpolicy",
1578
- "loading"
1579
- ])
1580
- };
1581
- var iframe = () => iframeSpec;
1582
-
1583
- // src/elements/embed.ts
1584
- var embedSpec = {
1585
- contents: null,
1586
- attributes: contentAttributes(true, ["src", "type", "width", "height"])
1587
- };
1588
- var embed = () => embedSpec;
1589
-
1590
- // src/elements/object.ts
1591
- var objectSpec = {
1592
- contents: [
1593
- {
1594
- type: "oneOrMore",
1595
- contents: contentsPreset.transparentContent
1596
- }
1597
- ],
1598
- attributes: contentAttributes(true, [
1599
- "data",
1600
- "type",
1601
- "name",
1602
- "form",
1603
- "width",
1604
- "height"
1605
- ])
1606
- };
1607
- var object = () => objectSpec;
1608
-
1609
- // src/elements/video.ts
1610
- var attributes = contentAttributes(true, [
1611
- "src",
1612
- "crossorigin",
1613
- "poster",
1614
- "preload",
1615
- "autoplay",
1616
- "playsinline",
1617
- "loop",
1618
- "muted",
1619
- "controls",
1620
- "width",
1621
- "height"
1622
- ]);
1623
- var videoWithSrcSpec = {
1624
- contents: [
1625
- {
1626
- type: "zeroOrMore",
1627
- contents: contents.fromKeys("track")
1628
- },
1629
- {
1630
- type: "zeroOrMore",
1631
- contents: contentsPreset.transparentContent,
1632
- constraints: {
1633
- descendants: contentConstraint.fromSets(
1634
- disallow,
1635
- contentsPreset.mediaElements
1636
- )
1637
- }
1638
- }
1639
- ],
1640
- attributes
1641
- };
1642
- var videoWitoutSrcSpec = {
1643
- contents: [
1644
- {
1645
- type: "zeroOrMore",
1646
- contents: contents.fromKeys("source")
1647
- },
1648
- {
1649
- type: "zeroOrMore",
1650
- contents: contents.fromKeys("track")
1651
- },
1652
- {
1653
- type: "zeroOrMore",
1654
- contents: contentsPreset.transparentContent,
1655
- constraints: {
1656
- descendants: contentConstraint.fromSets(
1657
- disallow,
1658
- contentsPreset.mediaElements
1659
- )
1660
- }
1661
- }
1662
- ],
1663
- attributes
1664
- };
1665
- var video = (state) => {
1666
- const attributes5 = (state == null ? void 0 : state.attributes) || {};
1667
- if (!!attributes5["src"]) {
1668
- return videoWithSrcSpec;
61
+ get attributes() {
62
+ return new AttributeState(this.options.attributes);
1669
63
  }
1670
- return videoWitoutSrcSpec;
1671
- };
1672
-
1673
- // src/elements/audio.ts
1674
- var attributes2 = contentAttributes(true, [
1675
- "src",
1676
- "crossorigin",
1677
- "preload",
1678
- "autoplay",
1679
- "loop",
1680
- "muted",
1681
- "controls"
1682
- ]);
1683
- var audioWithSrcSpec = {
1684
- contents: [
1685
- {
1686
- type: "zeroOrMore",
1687
- contents: contents.fromKeys("track")
1688
- },
1689
- {
1690
- type: "oneOrMore",
1691
- contents: contentsPreset.transparentContent
64
+ parent() {
65
+ if (!this.options.ancestors) {
66
+ return null;
1692
67
  }
1693
- ],
1694
- attributes: attributes2
1695
- };
1696
- var audioWithoutSrcSpec = {
1697
- contents: [
1698
- {
1699
- type: "zeroOrMore",
1700
- contents: contents.fromKeys("source")
1701
- },
1702
- {
1703
- type: "zeroOrMore",
1704
- contents: contents.fromKeys("track")
1705
- },
1706
- {
1707
- type: "oneOrMore",
1708
- contents: contentsPreset.transparentContent,
1709
- constraints: {
1710
- descendants: contentConstraint.fromSets(
1711
- disallow,
1712
- contentsPreset.mediaElements
1713
- )
1714
- }
68
+ const iterator = this.options.ancestors()[Symbol.iterator]();
69
+ const first = iterator.next();
70
+ if (first.done || !first.value) {
71
+ return null;
1715
72
  }
1716
- ],
1717
- attributes: attributes2
1718
- };
1719
- var audio = (state) => {
1720
- const attributes5 = (state == null ? void 0 : state.attributes) || {};
1721
- if (!!attributes5["src"]) {
1722
- return audioWithSrcSpec;
73
+ return new _ElementState(first.value.name, first.value);
1723
74
  }
1724
- return audioWithoutSrcSpec;
1725
- };
1726
-
1727
- // src/elements/track.ts
1728
- var trackSpec = {
1729
- contents: null,
1730
- attributes: contentAttributes(true, [
1731
- "kind",
1732
- "src",
1733
- "srclang",
1734
- "label",
1735
- "label",
1736
- "default"
1737
- ])
1738
- };
1739
- var track = () => trackSpec;
1740
-
1741
- // src/elements/map.ts
1742
- var mapSpec = {
1743
- contents: [
1744
- {
1745
- type: "oneOrMore",
1746
- contents: contentsPreset.transparentContent
1747
- }
1748
- ],
1749
- attributes: contentAttributes(true, ["name"])
1750
- };
1751
- var map = () => mapSpec;
1752
-
1753
- // src/elements/area.ts
1754
- var areaSpec = {
1755
- contents: null,
1756
- attributes: contentAttributes(true, [
1757
- "alt",
1758
- "coords",
1759
- "shape",
1760
- "href",
1761
- "target",
1762
- "download",
1763
- "ping",
1764
- "rel",
1765
- "referrerpolicy"
1766
- ])
1767
- };
1768
- var area = () => areaSpec;
1769
-
1770
- // src/elements/table.ts
1771
- var tableSpec = {
1772
- contents: [
1773
- {
1774
- type: "zeroOrMore",
1775
- contents: contentsPreset.scriptSupportingElements
1776
- },
1777
- {
1778
- type: "optional",
1779
- contents: contents.fromKeys("caption")
1780
- },
1781
- {
1782
- type: "zeroOrMore",
1783
- contents: contentsPreset.scriptSupportingElements
1784
- },
1785
- {
1786
- type: "zeroOrMore",
1787
- contents: contents.fromKeys("colgroup")
1788
- },
1789
- {
1790
- type: "zeroOrMore",
1791
- contents: contentsPreset.scriptSupportingElements
1792
- },
1793
- {
1794
- type: "optional",
1795
- contents: contents.fromKeys("thead")
1796
- },
1797
- {
1798
- type: "zeroOrMore",
1799
- contents: contentsPreset.scriptSupportingElements
1800
- },
1801
- {
1802
- type: "either",
1803
- options: [
1804
- [
1805
- {
1806
- type: "zeroOrMore",
1807
- contents: contents.fromKeys("tbody")
1808
- }
1809
- ],
1810
- [
1811
- {
1812
- type: "oneOrMore",
1813
- contents: contents.fromKeys("tr")
1814
- }
1815
- ]
1816
- ]
1817
- },
1818
- {
1819
- type: "zeroOrMore",
1820
- contents: contentsPreset.scriptSupportingElements
1821
- },
1822
- {
1823
- type: "optional",
1824
- contents: contents.fromKeys("tfoot")
1825
- },
1826
- {
1827
- type: "zeroOrMore",
1828
- contents: contentsPreset.scriptSupportingElements
1829
- }
1830
- ],
1831
- attributes: contentAttributes(true)
1832
- };
1833
- var table = () => tableSpec;
1834
-
1835
- // src/elements/caption.ts
1836
- var captionSpec = {
1837
- contents: [
1838
- {
1839
- type: "oneOrMore",
1840
- contents: contentsPreset.flowContent,
1841
- constraints: {
1842
- descendants: contentConstraint.fromEntries([["table", disallow]])
1843
- }
1844
- }
1845
- ],
1846
- attributes: contentAttributes(true)
1847
- };
1848
- var caption = () => captionSpec;
1849
-
1850
- // src/elements/colgroup.ts
1851
- var attributes3 = contentAttributes(true, ["span"]);
1852
- var colgroupWithSpanSpec = {
1853
- contents: null,
1854
- attributes: attributes3
1855
- };
1856
- var colgroupWithoutSpanSpec = {
1857
- contents: [
1858
- {
1859
- type: "zeroOrMore",
1860
- contents: contents.fromKeys("col", "template")
1861
- }
1862
- ],
1863
- attributes: attributes3
1864
- };
1865
- var colgroup = (state) => {
1866
- const attributes5 = (state == null ? void 0 : state.attributes) || {};
1867
- if (attributes5["span"]) {
1868
- return colgroupWithSpanSpec;
75
+ anceters() {
76
+ var _a, _b;
77
+ return ((_b = (_a = this.options).ancestors) == null ? void 0 : _b.call(_a)) || [];
1869
78
  }
1870
- return colgroupWithoutSpanSpec;
1871
- };
1872
-
1873
- // src/elements/col.ts
1874
- var colSpec = {
1875
- contents: null,
1876
- attributes: contentAttributes(true, ["span"])
1877
79
  };
1878
- var col = () => colSpec;
1879
80
 
1880
- // src/elements/tbody.ts
1881
- var tbodySpec = {
1882
- contents: [
1883
- {
1884
- type: "zeroOrMore",
1885
- contents: contents.fromSet(contentsPreset.scriptSupportingElements, "tr")
1886
- }
1887
- ],
1888
- attributes: contentAttributes(true)
1889
- };
1890
- var tbody = () => tbodySpec;
1891
-
1892
- // src/elements/thead.ts
1893
- var theadSpec = {
1894
- contents: [
1895
- {
1896
- type: "zeroOrMore",
1897
- contents: contents.fromSet(contentsPreset.scriptSupportingElements, "tr")
1898
- }
1899
- ],
1900
- attributes: contentAttributes(true)
1901
- };
1902
- var thead = () => theadSpec;
1903
-
1904
- // src/elements/tfoot.ts
1905
- var tfootSpec = {
1906
- contents: [
1907
- {
1908
- type: "zeroOrMore",
1909
- contents: contents.fromSet(contentsPreset.scriptSupportingElements, "tr")
1910
- }
1911
- ],
1912
- attributes: contentAttributes(true)
1913
- };
1914
- var tfoot = () => tfootSpec;
1915
-
1916
- // src/elements/tr.ts
1917
- var trSpec = {
1918
- contents: [
1919
- {
1920
- type: "zeroOrMore",
1921
- contents: contents.fromSet(
1922
- contentsPreset.scriptSupportingElements,
1923
- "td",
1924
- "th"
1925
- )
1926
- }
1927
- ],
1928
- attributes: contentAttributes(true)
1929
- };
1930
- var tr = () => trSpec;
1931
-
1932
- // src/elements/td.ts
1933
- var tdSpec = {
1934
- contents: [
1935
- {
1936
- type: "oneOrMore",
1937
- contents: contentsPreset.flowContent
1938
- }
1939
- ],
1940
- attributes: contentAttributes(true, ["colspan", "rowspan", "headers"])
1941
- };
1942
- var td = () => tdSpec;
1943
-
1944
- // src/elements/th.ts
1945
- var thSpec = {
1946
- contents: [
1947
- {
1948
- type: "oneOrMore",
1949
- contents: contentsPreset.flowContent,
1950
- constraints: {
1951
- descendants: contentConstraint.fromSets(
1952
- disallow,
1953
- /* @__PURE__ */ new Set(["header", "footer"]),
1954
- contentsPreset.sectioningContent,
1955
- contentsPreset.headingContent
1956
- )
81
+ // src/constants/roles.ts
82
+ var ROLES = {
83
+ ARTICLE: "article",
84
+ BLOCKQUOTE: "blockquote",
85
+ BUTTON: "button",
86
+ CAPTION: "caption",
87
+ CELL: "cell",
88
+ CHECKBOX: "checkbox",
89
+ CODE: "code",
90
+ COMBOBOX: "combobox",
91
+ COMPLEMENTARY: "complementary",
92
+ CONTENTINFO: "contentinfo",
93
+ DELETION: "deletion",
94
+ DIALOG: "dialog",
95
+ DOCUMENT: "document",
96
+ EMPHASIS: "emphasis",
97
+ FIGURE: "figure",
98
+ FORM: "form",
99
+ GENERIC: "generic",
100
+ GROUP: "group",
101
+ HEADING: "heading",
102
+ IMG: "img",
103
+ INSERTION: "insertion",
104
+ LINK: "link",
105
+ LIST: "list",
106
+ LISTBOX: "listbox",
107
+ MAIN: "main",
108
+ METER: "meter",
109
+ NAVIGATION: "navigation",
110
+ OPTION: "option",
111
+ PARAGRAPH: "paragraph",
112
+ PROGRESSBAR: "progressbar",
113
+ RADIO: "radio",
114
+ ROW: "row",
115
+ ROWGROUP: "rowgroup",
116
+ SEARCH: "search",
117
+ SEARCHBOX: "searchbox",
118
+ SEPARATOR: "separator",
119
+ SLIDER: "slider",
120
+ SPINBUTTON: "spinbutton",
121
+ STATUS: "status",
122
+ STRONG: "strong",
123
+ TABLE: "table",
124
+ TERM: "term",
125
+ TEXTBOX: "textbox",
126
+ TIME: "time"
127
+ };
128
+
129
+ // src/accessibility/implicit-role/implicit-role.ts
130
+ var IMPLICIT_ROLE = {
131
+ a: (element2) => element2.attributes.has("href") ? ROLES.LINK : ROLES.GENERIC,
132
+ abbr: () => null,
133
+ address: () => ROLES.GROUP,
134
+ area: (element2) => element2.attributes.has("href") ? ROLES.LINK : ROLES.GENERIC,
135
+ article: () => ROLES.ARTICLE,
136
+ aside: () => ROLES.COMPLEMENTARY,
137
+ audio: () => null,
138
+ b: () => ROLES.GENERIC,
139
+ base: () => null,
140
+ bdi: () => ROLES.GENERIC,
141
+ bdo: () => ROLES.GENERIC,
142
+ blockquote: () => ROLES.BLOCKQUOTE,
143
+ body: () => ROLES.GENERIC,
144
+ br: () => null,
145
+ button: () => ROLES.BUTTON,
146
+ canvas: () => null,
147
+ caption: () => ROLES.CAPTION,
148
+ cite: () => null,
149
+ code: () => ROLES.CODE,
150
+ col: () => null,
151
+ colgroup: () => null,
152
+ data: () => ROLES.GENERIC,
153
+ datalist: () => ROLES.LISTBOX,
154
+ dd: () => null,
155
+ del: () => ROLES.DELETION,
156
+ details: () => ROLES.GROUP,
157
+ dfn: () => ROLES.TERM,
158
+ dialog: () => ROLES.DIALOG,
159
+ div: () => ROLES.GENERIC,
160
+ dl: () => null,
161
+ dt: () => null,
162
+ em: () => ROLES.EMPHASIS,
163
+ embed: () => null,
164
+ fieldset: () => ROLES.GROUP,
165
+ figcaption: () => null,
166
+ figure: () => ROLES.FIGURE,
167
+ footer: (element2) => {
168
+ const sectioningElements = ["article", "aside", "main", "nav", "section"];
169
+ for (const ancestor of element2.anceters()) {
170
+ if (sectioningElements.includes(ancestor.name.toLowerCase())) {
171
+ return ROLES.GENERIC;
1957
172
  }
1958
173
  }
1959
- ],
1960
- attributes: contentAttributes(true, [
1961
- "colspan",
1962
- "rowspan",
1963
- "headers",
1964
- "scope",
1965
- "abbr"
1966
- ])
1967
- };
1968
- var th = () => thSpec;
1969
-
1970
- // src/elements/form.ts
1971
- var formSpec = {
1972
- contents: [
1973
- {
1974
- type: "oneOrMore",
1975
- contents: contentsPreset.flowContent,
1976
- constraints: {
1977
- descendants: contentConstraint.fromEntries([["from", disallow]])
1978
- }
1979
- }
1980
- ],
1981
- attributes: contentAttributes(true, [
1982
- "accept-charset",
1983
- "action",
1984
- "autocomplete",
1985
- "enctype",
1986
- "method",
1987
- "name",
1988
- "novalidate",
1989
- "target",
1990
- "rel"
1991
- ])
1992
- };
1993
- var form = () => formSpec;
1994
-
1995
- // src/elements/label.ts
1996
- var labelSpec = {
1997
- contents: [
1998
- {
1999
- type: "oneOrMore",
2000
- contents: contentsPreset.phrasingContent,
2001
- constraints: {
2002
- descendants: contentConstraint.fromEntries([["label", disallow]])
2003
- }
2004
- }
2005
- ],
2006
- attributes: contentAttributes(true, ["for"])
2007
- };
2008
- var label = () => labelSpec;
2009
-
2010
- // src/elements/input.ts
2011
- var inputSpec = {
2012
- contents: null,
2013
- attributes: contentAttributes(true, [
2014
- "accept",
2015
- "alpha",
2016
- "alt",
2017
- "autocomplete",
2018
- "checked",
2019
- "colorspace",
2020
- "dirname",
2021
- "disabled",
2022
- "form",
2023
- "formaction",
2024
- "formenctype",
2025
- "formmethod",
2026
- "formnovalidate",
2027
- "formtarget",
2028
- "height",
2029
- "list",
2030
- "max",
2031
- "maxlength",
2032
- "min",
2033
- "minlength",
2034
- "multiple",
2035
- "name",
2036
- "pattern",
2037
- "placeholder",
2038
- "popovertarget",
2039
- "popovertargetaction",
2040
- "readonly",
2041
- "required",
2042
- "size",
2043
- "src",
2044
- "step",
2045
- "type",
2046
- "value",
2047
- "width",
2048
- "title"
2049
- ])
2050
- };
2051
- var input = () => inputSpec;
2052
-
2053
- // src/elements/button.ts
2054
- var buttonSpec = {
2055
- contents: [
2056
- {
2057
- type: "oneOrMore",
2058
- contents: contentsPreset.phrasingContent,
2059
- constraints: {
2060
- descendants: contentConstraint.fromSets(
2061
- disallow,
2062
- contentsPreset.interactiveContent
2063
- )
2064
- }
2065
- }
2066
- ],
2067
- attributes: contentAttributes(true, [
2068
- "command",
2069
- "commandfor",
2070
- "disabled",
2071
- "form",
2072
- "formaction",
2073
- "formenctype",
2074
- "formmethod",
2075
- "formnovalidate",
2076
- "formtarget",
2077
- "name",
2078
- "popovertarget",
2079
- "popovertargetaction",
2080
- "type",
2081
- "value"
2082
- ])
2083
- };
2084
- var button = () => buttonSpec;
2085
-
2086
- // src/elements/select.ts
2087
- var selectSpec = {
2088
- contents: [
2089
- {
2090
- type: "zeroOrMore",
2091
- contents: contents.fromSet(
2092
- contentsPreset.scriptSupportingElements,
2093
- "option",
2094
- "optgroup",
2095
- "hr"
2096
- )
2097
- }
2098
- ],
2099
- attributes: contentAttributes(true, [
2100
- "autocomplete",
2101
- "disabled",
2102
- "form",
2103
- "multiple",
2104
- "name",
2105
- "required",
2106
- "size"
2107
- ])
2108
- };
2109
- var select = () => selectSpec;
2110
-
2111
- // src/elements/datalist.ts
2112
- var datalistSpec = {
2113
- contents: [
2114
- {
2115
- type: "either",
2116
- options: [
2117
- [
2118
- {
2119
- type: "oneOrMore",
2120
- contents: contentsPreset.phrasingContent
2121
- }
2122
- ],
2123
- [
2124
- {
2125
- type: "zeroOrMore",
2126
- contents: contents.fromSet(
2127
- contentsPreset.scriptSupportingElements,
2128
- "option"
2129
- )
2130
- }
2131
- ]
2132
- ]
2133
- }
2134
- ],
2135
- attributes: contentAttributes(true)
2136
- };
2137
- var datalist = () => datalistSpec;
2138
-
2139
- // src/elements/optgroup.ts
2140
- var optgroupSpec = {
2141
- contents: [
2142
- {
2143
- type: "zeroOrMore",
2144
- contents: contents.fromSet(
2145
- contentsPreset.scriptSupportingElements,
2146
- "option"
2147
- )
2148
- }
2149
- ],
2150
- attributes: contentAttributes(true, ["disabled", "label"])
2151
- };
2152
- var optgroup = () => optgroupSpec;
2153
-
2154
- // src/elements/option.ts
2155
- var attributes4 = contentAttributes(true, [
2156
- "disabled",
2157
- "label",
2158
- "selected",
2159
- "value"
2160
- ]);
2161
- var optionWithLabelAndValueSpec = {
2162
- contents: null,
2163
- attributes: attributes4
2164
- };
2165
- var optionWithLabelSpec = {
2166
- contents: [
2167
- {
2168
- type: "required",
2169
- contents: contentsPreset.text
2170
- }
2171
- ],
2172
- attributes: attributes4
2173
- };
2174
- var optionWithoutLabelAndValueSpec = {
2175
- contents: [
2176
- {
2177
- type: "oneOrMore",
2178
- contents: contentsPreset.text
174
+ return ROLES.CONTENTINFO;
175
+ },
176
+ form: () => ROLES.FORM,
177
+ h1: () => ROLES.HEADING,
178
+ h2: () => ROLES.HEADING,
179
+ h3: () => ROLES.HEADING,
180
+ h4: () => ROLES.HEADING,
181
+ h5: () => ROLES.HEADING,
182
+ h6: () => ROLES.HEADING,
183
+ head: () => null,
184
+ header: () => null,
185
+ // TODO: banner if not descendant of article/aside/main/nav/section, otherwise generic
186
+ hgroup: () => ROLES.GROUP,
187
+ hr: () => ROLES.SEPARATOR,
188
+ html: () => ROLES.DOCUMENT,
189
+ i: () => ROLES.GENERIC,
190
+ iframe: () => null,
191
+ img: (element2) => {
192
+ const alt = element2.attributes.get("alt");
193
+ if (alt === "") return null;
194
+ return ROLES.IMG;
195
+ },
196
+ input: (element2) => {
197
+ const type = element2.attributes.get("type") || "text";
198
+ switch (type) {
199
+ case "button":
200
+ case "image":
201
+ case "reset":
202
+ case "submit":
203
+ return ROLES.BUTTON;
204
+ case "checkbox":
205
+ return ROLES.CHECKBOX;
206
+ case "color":
207
+ case "date":
208
+ case "datetime-local":
209
+ case "file":
210
+ case "hidden":
211
+ case "month":
212
+ case "password":
213
+ case "time":
214
+ case "week":
215
+ return null;
216
+ case "email":
217
+ case "tel":
218
+ case "text":
219
+ case "url":
220
+ return ROLES.TEXTBOX;
221
+ case "number":
222
+ return ROLES.SPINBUTTON;
223
+ case "radio":
224
+ return ROLES.RADIO;
225
+ case "range":
226
+ return ROLES.SLIDER;
227
+ case "search":
228
+ return ROLES.SEARCHBOX;
229
+ default:
230
+ return ROLES.TEXTBOX;
2179
231
  }
2180
- ],
2181
- attributes: attributes4
2182
- };
2183
- var option = (state) => {
2184
- const attributes5 = (state == null ? void 0 : state.attributes) || {};
2185
- if (attributes5["label"] && attributes5["value"]) {
2186
- return optionWithLabelAndValueSpec;
232
+ },
233
+ ins: () => ROLES.INSERTION,
234
+ kbd: () => null,
235
+ label: () => null,
236
+ legend: () => null,
237
+ li: () => null,
238
+ // TODO: listitem if child of ol/ul/menu, otherwise generic
239
+ link: () => null,
240
+ main: () => ROLES.MAIN,
241
+ map: () => null,
242
+ mark: () => null,
243
+ menu: () => ROLES.LIST,
244
+ meta: () => null,
245
+ meter: () => ROLES.METER,
246
+ nav: () => ROLES.NAVIGATION,
247
+ noscript: () => null,
248
+ object: () => null,
249
+ ol: () => ROLES.LIST,
250
+ optgroup: () => ROLES.GROUP,
251
+ option: () => ROLES.OPTION,
252
+ output: () => ROLES.STATUS,
253
+ p: () => ROLES.PARAGRAPH,
254
+ param: () => null,
255
+ picture: () => null,
256
+ pre: () => ROLES.GENERIC,
257
+ progress: () => ROLES.PROGRESSBAR,
258
+ q: () => ROLES.GENERIC,
259
+ rp: () => null,
260
+ rt: () => null,
261
+ ruby: () => null,
262
+ s: () => ROLES.DELETION,
263
+ samp: () => ROLES.GENERIC,
264
+ script: () => null,
265
+ search: () => ROLES.SEARCH,
266
+ section: () => null,
267
+ select: (element2) => element2.attributes.has("multiple") ? ROLES.LISTBOX : ROLES.COMBOBOX,
268
+ slot: () => null,
269
+ small: () => ROLES.GENERIC,
270
+ span: () => ROLES.GENERIC,
271
+ strong: () => ROLES.STRONG,
272
+ style: () => null,
273
+ sub: () => null,
274
+ summary: () => ROLES.BUTTON,
275
+ sup: () => null,
276
+ svg: () => null,
277
+ table: () => ROLES.TABLE,
278
+ tbody: () => ROLES.ROWGROUP,
279
+ td: () => ROLES.CELL,
280
+ template: () => null,
281
+ textarea: () => ROLES.TEXTBOX,
282
+ tfoot: () => ROLES.ROWGROUP,
283
+ th: () => null,
284
+ thead: () => ROLES.ROWGROUP,
285
+ time: () => ROLES.TIME,
286
+ title: () => null,
287
+ tr: () => ROLES.ROW,
288
+ track: () => null,
289
+ u: () => null,
290
+ ul: () => ROLES.LIST,
291
+ var: () => null,
292
+ video: () => null,
293
+ wbr: () => null
294
+ };
295
+
296
+ // src/accessibility/accessibility.ts
297
+ var Accessibility = class {
298
+ constructor(element2) {
299
+ this.element = element2;
2187
300
  }
2188
- if (attributes5["label"]) {
2189
- return optionWithLabelSpec;
301
+ implicitRole() {
302
+ var _a, _b, _c;
303
+ return (_c = (_b = (_a = IMPLICIT_ROLE)[this.element.name.toLowerCase()]) == null ? void 0 : _b.call(_a, this.element)) != null ? _c : null;
2190
304
  }
2191
- return optionWithoutLabelAndValueSpec;
2192
- };
2193
-
2194
- // src/elements/textarea.ts
2195
- var textareaSpec = {
2196
- contents: [
2197
- {
2198
- type: "zeroOrMore",
2199
- contents: contentsPreset.text
2200
- }
2201
- ],
2202
- attributes: contentAttributes(true, [
2203
- "autocomplete",
2204
- "cols",
2205
- "dirname",
2206
- "disabled",
2207
- "form",
2208
- "maxlength",
2209
- "minlength",
2210
- "name",
2211
- "placeholder",
2212
- "readonly",
2213
- "required",
2214
- "rows",
2215
- "wrap"
2216
- ])
2217
305
  };
2218
- var textarea = () => textareaSpec;
2219
-
2220
- // src/elements/output.ts
2221
- var outputSpec = {
2222
- contents: [
2223
- {
2224
- type: "oneOrMore",
2225
- contents: contentsPreset.phrasingContent
2226
- }
2227
- ],
2228
- attributes: contentAttributes(true, ["for", "form", "name"])
2229
- };
2230
- var output = () => outputSpec;
2231
-
2232
- // src/elements/progress.ts
2233
- var progressSpec = {
2234
- contents: [
2235
- {
2236
- type: "oneOrMore",
2237
- contents: contentsPreset.phrasingContent,
2238
- constraints: {
2239
- descendants: contentConstraint.fromEntries([["progress", disallow]])
2240
- }
2241
- }
2242
- ],
2243
- attributes: contentAttributes(true, ["value", "max"])
2244
- };
2245
- var progress = () => progressSpec;
2246
-
2247
- // src/elements/meter.ts
2248
- var meterSpec = {
2249
- contents: [
2250
- {
2251
- type: "oneOrMore",
2252
- contents: contentsPreset.phrasingContent,
2253
- constraints: {
2254
- descendants: contentConstraint.fromEntries([["meter", disallow]])
2255
- }
2256
- }
2257
- ],
2258
- attributes: contentAttributes(true, [
2259
- "value",
2260
- "min",
2261
- "max",
2262
- "low",
2263
- "high",
2264
- "optimum"
2265
- ])
2266
- };
2267
- var meter = () => meterSpec;
2268
-
2269
- // src/elements/fieldset.ts
2270
- var fieldsetSpec = {
2271
- contents: [
2272
- {
2273
- type: "optional",
2274
- contents: contents.fromKeys("legend")
2275
- },
2276
- {
2277
- type: "oneOrMore",
2278
- contents: contentsPreset.flowContent
2279
- }
2280
- ],
2281
- attributes: contentAttributes(true, ["disabled", "form", "name"])
2282
- };
2283
- var fieldset = () => fieldsetSpec;
2284
-
2285
- // src/elements/legend.ts
2286
- var legendSpec = {
2287
- contents: [
2288
- {
2289
- type: "zeroOrMore",
2290
- contents: contents.fromUnionSets(
2291
- contentsPreset.phrasingContent,
2292
- contentsPreset.headingContent
2293
- )
2294
- }
2295
- ],
2296
- attributes: contentAttributes(true)
2297
- };
2298
- var legend = () => legendSpec;
2299
-
2300
- // src/elements/details.ts
2301
- var detailsSpec = {
2302
- contents: [
2303
- {
2304
- type: "required",
2305
- contents: contents.fromKeys("summary")
2306
- },
2307
- {
2308
- type: "oneOrMore",
2309
- contents: contentsPreset.flowContent
2310
- }
2311
- ],
2312
- attributes: contentAttributes(true, ["name", "open"])
2313
- };
2314
- var details = () => detailsSpec;
2315
-
2316
- // src/elements/summary.ts
2317
- var summarySpec = {
2318
- contents: [
2319
- {
2320
- type: "oneOrMore",
2321
- contents: contents.fromUnionSets(
2322
- contentsPreset.phrasingContent,
2323
- contentsPreset.headingContent
2324
- )
2325
- }
2326
- ],
2327
- attributes: contentAttributes(true)
2328
- };
2329
- var summary = () => summarySpec;
2330
-
2331
- // src/elements/dialog.ts
2332
- var dialogSpec = {
2333
- contents: [
2334
- {
2335
- type: "oneOrMore",
2336
- contents: contentsPreset.flowContent
2337
- }
2338
- ],
2339
- attributes: contentAttributes(true, ["closedby", "open"])
2340
- };
2341
- var dialog = () => dialogSpec;
2342
-
2343
- // src/elements/script.ts
2344
- var scriptSpec = {
2345
- contents: [
2346
- {
2347
- type: "zeroOrMore",
2348
- contents: contentsPreset.text
2349
- }
2350
- ],
2351
- attributes: contentAttributes(true, [
2352
- "src",
2353
- "type",
2354
- "nomodule",
2355
- "async",
2356
- "defer",
2357
- "crossorigin",
2358
- "integrity",
2359
- "referrerpolicy",
2360
- "blocking",
2361
- "fetchpriority"
2362
- ])
2363
- };
2364
- var script = () => scriptSpec;
2365
-
2366
- // src/elements/noscript.ts
2367
- var noscriptSpec = {
2368
- contents: [
2369
- {
2370
- type: "zeroOrMore",
2371
- contents: contentsPreset.text
2372
- }
2373
- ],
2374
- attributes: contentAttributes(true)
2375
- };
2376
- var noscript = () => noscriptSpec;
2377
-
2378
- // src/elements/template.ts
2379
- var templateSpec = {
2380
- contents: null,
2381
- attributes: contentAttributes(true, [
2382
- "shadowrootmode",
2383
- "shadowrootdelegatesfocus",
2384
- "shadowrootclonable",
2385
- "shadowrootserializable"
2386
- ])
2387
- };
2388
- var template = () => templateSpec;
2389
-
2390
- // src/elements/slot.ts
2391
- var slotSpec = {
2392
- contents: [
2393
- {
2394
- type: "oneOrMore",
2395
- contents: contentsPreset.transparentContent
2396
- }
2397
- ],
2398
- attributes: contentAttributes(true, ["name"])
2399
- };
2400
- var slot = () => slotSpec;
2401
-
2402
- // src/elements/canvas.ts
2403
- var canvasSpec = {
2404
- contents: [
2405
- {
2406
- type: "oneOrMore",
2407
- contents: contentsPreset.transparentContent,
2408
- constraints: {
2409
- descendants: contentConstraint.fromSets(
2410
- disallow,
2411
- contentsPreset.interactiveContent
2412
- )
2413
- }
2414
- }
2415
- ],
2416
- attributes: contentAttributes(true, ["width", "height"])
2417
- };
2418
- var canvas = () => canvasSpec;
306
+ function accessibility(name, options) {
307
+ return new Accessibility(new ElementState(name, options));
308
+ }
2419
309
 
2420
- // src/getElementSpec.ts
2421
- var specsRecord = elements_exports;
2422
- function getElementSpec(name, options) {
2423
- const getSpec = specsRecord[name.toLowerCase()] || null;
2424
- if (!getSpec) {
2425
- return null;
310
+ // src/element.ts
311
+ var Element = class {
312
+ constructor(name, options) {
313
+ this.name = name;
314
+ this.options = options;
2426
315
  }
2427
- return getSpec(options);
316
+ get accessibility() {
317
+ return accessibility(this.name, this.options);
318
+ }
319
+ };
320
+ function element(name, options = DEFAULT_ELEMENT_OPTIONS) {
321
+ return new Element(name, options);
2428
322
  }
2429
323
  // Annotate the CommonJS export names for ESM import in node:
2430
324
  0 && (module.exports = {
2431
- getElementSpec
325
+ accessibility,
326
+ element
2432
327
  });
2433
328
  //# sourceMappingURL=index.cjs.map