@wordpress/dom 5.0.0 → 5.1.0

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.
Files changed (210) hide show
  1. package/README.md +1 -1
  2. package/build/data-transfer.cjs +20 -38
  3. package/build/data-transfer.cjs.map +1 -7
  4. package/build/dom/caret-range-from-point.cjs +31 -38
  5. package/build/dom/caret-range-from-point.cjs.map +1 -7
  6. package/build/dom/clean-node-list.cjs +87 -132
  7. package/build/dom/clean-node-list.cjs.map +1 -7
  8. package/build/dom/compute-caret-rect.cjs +35 -35
  9. package/build/dom/compute-caret-rect.cjs.map +1 -7
  10. package/build/dom/document-has-selection.cjs +35 -30
  11. package/build/dom/document-has-selection.cjs.map +1 -7
  12. package/build/dom/document-has-text-selection.cjs +24 -30
  13. package/build/dom/document-has-text-selection.cjs.map +1 -7
  14. package/build/dom/document-has-uncollapsed-selection.cjs +34 -29
  15. package/build/dom/document-has-uncollapsed-selection.cjs.map +1 -7
  16. package/build/dom/get-computed-style.cjs +14 -30
  17. package/build/dom/get-computed-style.cjs.map +1 -7
  18. package/build/dom/get-offset-parent.cjs +40 -39
  19. package/build/dom/get-offset-parent.cjs.map +1 -7
  20. package/build/dom/get-range-height.cjs +18 -31
  21. package/build/dom/get-range-height.cjs.map +1 -7
  22. package/build/dom/get-rectangle-from-range.cjs +82 -128
  23. package/build/dom/get-rectangle-from-range.cjs.map +1 -7
  24. package/build/dom/get-scroll-container.cjs +46 -50
  25. package/build/dom/get-scroll-container.cjs.map +1 -7
  26. package/build/dom/hidden-caret-range-from-point.cjs +48 -42
  27. package/build/dom/hidden-caret-range-from-point.cjs.map +1 -7
  28. package/build/dom/index.cjs +233 -110
  29. package/build/dom/input-field-has-uncollapsed-selection.cjs +48 -43
  30. package/build/dom/input-field-has-uncollapsed-selection.cjs.map +1 -7
  31. package/build/dom/insert-after.cjs +17 -27
  32. package/build/dom/insert-after.cjs.map +1 -7
  33. package/build/dom/is-edge.cjs +82 -97
  34. package/build/dom/is-edge.cjs.map +1 -7
  35. package/build/dom/is-element.cjs +12 -25
  36. package/build/dom/is-element.cjs.map +1 -7
  37. package/build/dom/is-empty.cjs +23 -37
  38. package/build/dom/is-empty.cjs.map +1 -7
  39. package/build/dom/is-entirely-selected.cjs +70 -67
  40. package/build/dom/is-entirely-selected.cjs.map +1 -7
  41. package/build/dom/is-form-element.cjs +33 -33
  42. package/build/dom/is-form-element.cjs.map +1 -7
  43. package/build/dom/is-horizontal-edge.cjs +31 -28
  44. package/build/dom/is-horizontal-edge.cjs.map +1 -7
  45. package/build/dom/is-html-input-element.cjs +12 -25
  46. package/build/dom/is-html-input-element.cjs.map +1 -7
  47. package/build/dom/is-input-or-text-area.cjs +12 -25
  48. package/build/dom/is-input-or-text-area.cjs.map +1 -7
  49. package/build/dom/is-number-input.cjs +36 -33
  50. package/build/dom/is-number-input.cjs.map +1 -7
  51. package/build/dom/is-rtl.cjs +30 -28
  52. package/build/dom/is-rtl.cjs.map +1 -7
  53. package/build/dom/is-selection-forward.cjs +26 -39
  54. package/build/dom/is-selection-forward.cjs.map +1 -7
  55. package/build/dom/is-text-field.cjs +45 -42
  56. package/build/dom/is-text-field.cjs.map +1 -7
  57. package/build/dom/is-vertical-edge.cjs +31 -28
  58. package/build/dom/is-vertical-edge.cjs.map +1 -7
  59. package/build/dom/place-caret-at-edge.cjs +75 -78
  60. package/build/dom/place-caret-at-edge.cjs.map +1 -7
  61. package/build/dom/place-caret-at-horizontal-edge.cjs +29 -28
  62. package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
  63. package/build/dom/place-caret-at-vertical-edge.cjs +30 -28
  64. package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
  65. package/build/dom/remove-invalid-html.cjs +35 -31
  66. package/build/dom/remove-invalid-html.cjs.map +1 -7
  67. package/build/dom/remove.cjs +15 -27
  68. package/build/dom/remove.cjs.map +1 -7
  69. package/build/dom/replace-tag.cjs +21 -32
  70. package/build/dom/replace-tag.cjs.map +1 -7
  71. package/build/dom/replace.cjs +34 -32
  72. package/build/dom/replace.cjs.map +1 -7
  73. package/build/dom/safe-html.cjs +45 -46
  74. package/build/dom/safe-html.cjs.map +1 -7
  75. package/build/dom/scroll-if-no-range.cjs +24 -37
  76. package/build/dom/scroll-if-no-range.cjs.map +1 -7
  77. package/build/dom/strip-html.cjs +33 -31
  78. package/build/dom/strip-html.cjs.map +1 -7
  79. package/build/dom/types.cjs +4 -18
  80. package/build/dom/unwrap.cjs +17 -31
  81. package/build/dom/unwrap.cjs.map +1 -7
  82. package/build/dom/wrap.cjs +17 -28
  83. package/build/dom/wrap.cjs.map +1 -7
  84. package/build/focusable.cjs +99 -76
  85. package/build/focusable.cjs.map +1 -7
  86. package/build/index.cjs +57 -38
  87. package/build/index.cjs.map +1 -7
  88. package/build/phrasing-content.cjs +163 -159
  89. package/build/phrasing-content.cjs.map +1 -7
  90. package/build/tabbable.cjs +123 -78
  91. package/build/tabbable.cjs.map +1 -7
  92. package/build/types.cjs +4 -18
  93. package/build/utils/assert-is-defined.cjs +8 -33
  94. package/build/utils/assert-is-defined.cjs.map +1 -7
  95. package/build-module/data-transfer.mjs +16 -14
  96. package/build-module/data-transfer.mjs.map +1 -7
  97. package/build-module/dom/caret-range-from-point.mjs +27 -18
  98. package/build-module/dom/caret-range-from-point.mjs.map +1 -7
  99. package/build-module/dom/clean-node-list.mjs +60 -105
  100. package/build-module/dom/clean-node-list.mjs.map +1 -7
  101. package/build-module/dom/compute-caret-rect.mjs +16 -12
  102. package/build-module/dom/compute-caret-rect.mjs.map +1 -7
  103. package/build-module/dom/document-has-selection.mjs +13 -6
  104. package/build-module/dom/document-has-selection.mjs.map +1 -7
  105. package/build-module/dom/document-has-text-selection.mjs +20 -10
  106. package/build-module/dom/document-has-text-selection.mjs.map +1 -7
  107. package/build-module/dom/document-has-uncollapsed-selection.mjs +14 -6
  108. package/build-module/dom/document-has-uncollapsed-selection.mjs.map +1 -7
  109. package/build-module/dom/get-computed-style.mjs +10 -10
  110. package/build-module/dom/get-computed-style.mjs.map +1 -7
  111. package/build-module/dom/get-offset-parent.mjs +20 -16
  112. package/build-module/dom/get-offset-parent.mjs.map +1 -7
  113. package/build-module/dom/get-range-height.mjs +14 -11
  114. package/build-module/dom/get-range-height.mjs.map +1 -7
  115. package/build-module/dom/get-rectangle-from-range.mjs +78 -108
  116. package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
  117. package/build-module/dom/get-scroll-container.mjs +28 -28
  118. package/build-module/dom/get-scroll-container.mjs.map +1 -7
  119. package/build-module/dom/hidden-caret-range-from-point.mjs +28 -19
  120. package/build-module/dom/hidden-caret-range-from-point.mjs.map +1 -7
  121. package/build-module/dom/index.mjs +28 -58
  122. package/build-module/dom/input-field-has-uncollapsed-selection.mjs +28 -20
  123. package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +1 -7
  124. package/build-module/dom/insert-after.mjs +13 -7
  125. package/build-module/dom/insert-after.mjs.map +1 -7
  126. package/build-module/dom/is-edge.mjs +53 -69
  127. package/build-module/dom/is-edge.mjs.map +1 -7
  128. package/build-module/dom/is-element.mjs +8 -5
  129. package/build-module/dom/is-element.mjs.map +1 -7
  130. package/build-module/dom/is-empty.mjs +19 -17
  131. package/build-module/dom/is-empty.mjs.map +1 -7
  132. package/build-module/dom/is-entirely-selected.mjs +51 -44
  133. package/build-module/dom/is-entirely-selected.mjs.map +1 -7
  134. package/build-module/dom/is-form-element.mjs +15 -11
  135. package/build-module/dom/is-form-element.mjs.map +1 -7
  136. package/build-module/dom/is-horizontal-edge.mjs +13 -6
  137. package/build-module/dom/is-horizontal-edge.mjs.map +1 -7
  138. package/build-module/dom/is-html-input-element.mjs +8 -5
  139. package/build-module/dom/is-html-input-element.mjs.map +1 -7
  140. package/build-module/dom/is-input-or-text-area.mjs +8 -5
  141. package/build-module/dom/is-input-or-text-area.mjs.map +1 -7
  142. package/build-module/dom/is-number-input.mjs +16 -10
  143. package/build-module/dom/is-number-input.mjs.map +1 -7
  144. package/build-module/dom/is-rtl.mjs +12 -6
  145. package/build-module/dom/is-rtl.mjs.map +1 -7
  146. package/build-module/dom/is-selection-forward.mjs +22 -19
  147. package/build-module/dom/is-selection-forward.mjs.map +1 -7
  148. package/build-module/dom/is-text-field.mjs +27 -20
  149. package/build-module/dom/is-text-field.mjs.map +1 -7
  150. package/build-module/dom/is-vertical-edge.mjs +13 -6
  151. package/build-module/dom/is-vertical-edge.mjs.map +1 -7
  152. package/build-module/dom/place-caret-at-edge.mjs +51 -52
  153. package/build-module/dom/place-caret-at-edge.mjs.map +1 -7
  154. package/build-module/dom/place-caret-at-horizontal-edge.mjs +11 -6
  155. package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +1 -7
  156. package/build-module/dom/place-caret-at-vertical-edge.mjs +12 -6
  157. package/build-module/dom/place-caret-at-vertical-edge.mjs.map +1 -7
  158. package/build-module/dom/remove-invalid-html.mjs +17 -9
  159. package/build-module/dom/remove-invalid-html.mjs.map +1 -7
  160. package/build-module/dom/remove.mjs +11 -7
  161. package/build-module/dom/remove.mjs.map +1 -7
  162. package/build-module/dom/replace-tag.mjs +17 -12
  163. package/build-module/dom/replace-tag.mjs.map +1 -7
  164. package/build-module/dom/replace.mjs +13 -8
  165. package/build-module/dom/replace.mjs.map +1 -7
  166. package/build-module/dom/safe-html.mjs +27 -24
  167. package/build-module/dom/safe-html.mjs.map +1 -7
  168. package/build-module/dom/scroll-if-no-range.mjs +20 -13
  169. package/build-module/dom/scroll-if-no-range.mjs.map +1 -7
  170. package/build-module/dom/strip-html.mjs +15 -9
  171. package/build-module/dom/strip-html.mjs.map +1 -7
  172. package/build-module/dom/types.mjs +0 -1
  173. package/build-module/dom/unwrap.mjs +13 -11
  174. package/build-module/dom/unwrap.mjs.map +1 -7
  175. package/build-module/dom/wrap.mjs +13 -8
  176. package/build-module/dom/wrap.mjs.map +1 -7
  177. package/build-module/focusable.mjs +95 -52
  178. package/build-module/focusable.mjs.map +1 -7
  179. package/build-module/index.mjs +11 -5
  180. package/build-module/index.mjs.map +1 -7
  181. package/build-module/phrasing-content.mjs +157 -133
  182. package/build-module/phrasing-content.mjs.map +1 -7
  183. package/build-module/tabbable.mjs +116 -51
  184. package/build-module/tabbable.mjs.map +1 -7
  185. package/build-module/types.mjs +0 -1
  186. package/build-module/utils/assert-is-defined.mjs +4 -9
  187. package/build-module/utils/assert-is-defined.mjs.map +1 -7
  188. package/build-types/dom/clean-node-list.d.ts +2 -2
  189. package/build-types/dom/clean-node-list.d.ts.map +1 -1
  190. package/build-types/dom/is-edge.d.ts.map +1 -1
  191. package/build-types/dom/remove-invalid-html.d.ts +4 -4
  192. package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
  193. package/package.json +4 -4
  194. package/src/dom/clean-node-list.ts +2 -2
  195. package/src/dom/is-edge.ts +35 -43
  196. package/src/dom/remove-invalid-html.ts +4 -4
  197. package/src/dom/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
  198. package/src/test/{dom.jsdom.test.js → dom.jsdom.test.ts} +9 -6
  199. package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
  200. package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
  201. package/build/dom/index.cjs.map +0 -7
  202. package/build/dom/types.cjs.map +0 -7
  203. package/build/types.cjs.map +0 -7
  204. package/build-module/dom/index.mjs.map +0 -7
  205. package/build-module/dom/types.mjs.map +0 -7
  206. package/build-module/types.mjs.map +0 -7
  207. /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
  208. /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
  209. /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
  210. /package/src/test/{utils.js → utils.ts} +0 -0
@@ -1,145 +1,169 @@
1
1
  // packages/dom/src/phrasing-content.ts
2
- var textContentSchema = {
3
- strong: {},
4
- em: {},
5
- s: {},
6
- del: {},
7
- ins: {},
8
- a: { attributes: ["href", "target", "rel", "id"] },
9
- code: {},
10
- abbr: { attributes: ["title"] },
11
- sub: {},
12
- sup: {},
13
- br: {},
14
- small: {},
15
- // To do: fix blockquote.
16
- // cite: {},
17
- q: { attributes: ["cite"] },
18
- dfn: { attributes: ["title"] },
19
- data: { attributes: ["value"] },
20
- time: { attributes: ["datetime"] },
21
- var: {},
22
- samp: {},
23
- kbd: {},
24
- i: {},
25
- b: {},
26
- u: {},
27
- mark: {},
28
- ruby: {},
29
- rt: {},
30
- rp: {},
31
- bdi: { attributes: ["dir"] },
32
- bdo: { attributes: ["dir"] },
33
- wbr: {},
34
- "#text": {}
2
+ /**
3
+ * All phrasing content elements.
4
+ *
5
+ * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
6
+ */
7
+ /**
8
+ * All text-level semantic elements.
9
+ *
10
+ * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html
11
+ */
12
+ const textContentSchema = {
13
+ strong: {},
14
+ em: {},
15
+ s: {},
16
+ del: {},
17
+ ins: {},
18
+ a: { attributes: [
19
+ "href",
20
+ "target",
21
+ "rel",
22
+ "id"
23
+ ] },
24
+ code: {},
25
+ abbr: { attributes: ["title"] },
26
+ sub: {},
27
+ sup: {},
28
+ br: {},
29
+ small: {},
30
+ q: { attributes: ["cite"] },
31
+ dfn: { attributes: ["title"] },
32
+ data: { attributes: ["value"] },
33
+ time: { attributes: ["datetime"] },
34
+ var: {},
35
+ samp: {},
36
+ kbd: {},
37
+ i: {},
38
+ b: {},
39
+ u: {},
40
+ mark: {},
41
+ ruby: {},
42
+ rt: {},
43
+ rp: {},
44
+ bdi: { attributes: ["dir"] },
45
+ bdo: { attributes: ["dir"] },
46
+ wbr: {},
47
+ "#text": {}
35
48
  };
36
- var embeddedContentSchema = {
37
- audio: {
38
- attributes: [
39
- "src",
40
- "preload",
41
- "autoplay",
42
- "mediagroup",
43
- "loop",
44
- "muted"
45
- ]
46
- },
47
- canvas: { attributes: ["width", "height"] },
48
- embed: { attributes: ["src", "type", "width", "height"] },
49
- img: {
50
- attributes: [
51
- "alt",
52
- "src",
53
- "srcset",
54
- "usemap",
55
- "ismap",
56
- "width",
57
- "height"
58
- ]
59
- },
60
- object: {
61
- attributes: [
62
- "data",
63
- "type",
64
- "name",
65
- "usemap",
66
- "form",
67
- "width",
68
- "height"
69
- ]
70
- },
71
- video: {
72
- attributes: [
73
- "src",
74
- "poster",
75
- "preload",
76
- "playsinline",
77
- "autoplay",
78
- "mediagroup",
79
- "loop",
80
- "muted",
81
- "controls",
82
- "width",
83
- "height"
84
- ]
85
- },
86
- math: {
87
- attributes: ["display", "xmlns"],
88
- children: "*"
89
- }
49
+ /**
50
+ * Embedded content elements.
51
+ *
52
+ * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0
53
+ */
54
+ const embeddedContentSchema = {
55
+ audio: { attributes: [
56
+ "src",
57
+ "preload",
58
+ "autoplay",
59
+ "mediagroup",
60
+ "loop",
61
+ "muted"
62
+ ] },
63
+ canvas: { attributes: ["width", "height"] },
64
+ embed: { attributes: [
65
+ "src",
66
+ "type",
67
+ "width",
68
+ "height"
69
+ ] },
70
+ img: { attributes: [
71
+ "alt",
72
+ "src",
73
+ "srcset",
74
+ "usemap",
75
+ "ismap",
76
+ "width",
77
+ "height"
78
+ ] },
79
+ object: { attributes: [
80
+ "data",
81
+ "type",
82
+ "name",
83
+ "usemap",
84
+ "form",
85
+ "width",
86
+ "height"
87
+ ] },
88
+ video: { attributes: [
89
+ "src",
90
+ "poster",
91
+ "preload",
92
+ "playsinline",
93
+ "autoplay",
94
+ "mediagroup",
95
+ "loop",
96
+ "muted",
97
+ "controls",
98
+ "width",
99
+ "height"
100
+ ] },
101
+ math: {
102
+ attributes: ["display", "xmlns"],
103
+ children: "*"
104
+ }
90
105
  };
91
- var excludedElements = ["#text", "br", "wbr"];
106
+ const excludedElements = [
107
+ "#text",
108
+ "br",
109
+ "wbr"
110
+ ];
92
111
  Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
93
- const { [tag]: removedTag, ...restSchema } = textContentSchema;
94
- textContentSchema[tag].children = {
95
- ...restSchema,
96
- img: embeddedContentSchema.img
97
- };
112
+ const { [tag]: removedTag, ...restSchema } = textContentSchema;
113
+ textContentSchema[tag].children = {
114
+ ...restSchema,
115
+ img: embeddedContentSchema.img
116
+ };
98
117
  });
99
- var phrasingContentSchema = {
100
- ...textContentSchema,
101
- ...embeddedContentSchema
118
+ /**
119
+ * Phrasing content elements.
120
+ *
121
+ * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
122
+ */
123
+ const phrasingContentSchema = {
124
+ ...textContentSchema,
125
+ ...embeddedContentSchema
102
126
  };
127
+ /**
128
+ * Get schema of possible paths for phrasing content.
129
+ *
130
+ * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
131
+ *
132
+ * @param [context] Set to "paste" to exclude invisible elements and
133
+ * sensitive data.
134
+ *
135
+ * @return Schema.
136
+ */
103
137
  function getPhrasingContentSchema(context) {
104
- if (context !== "paste") {
105
- return phrasingContentSchema;
106
- }
107
- const {
108
- u,
109
- // Used to mark misspelling. Shouldn't be pasted.
110
- abbr,
111
- // Invisible.
112
- data,
113
- // Invisible.
114
- time,
115
- // Invisible.
116
- wbr,
117
- // Invisible.
118
- bdi,
119
- // Invisible.
120
- bdo,
121
- // Invisible.
122
- ...remainingContentSchema
123
- } = {
124
- ...phrasingContentSchema,
125
- // We shouldn't paste potentially sensitive information which is not
126
- // visible to the user when pasted, so strip the attributes.
127
- ins: { children: phrasingContentSchema.ins.children },
128
- del: { children: phrasingContentSchema.del.children }
129
- };
130
- return remainingContentSchema;
138
+ if (context !== "paste") return phrasingContentSchema;
139
+ const { u, abbr, data, time, wbr, bdi, bdo, ...remainingContentSchema } = {
140
+ ...phrasingContentSchema,
141
+ ins: { children: phrasingContentSchema.ins.children },
142
+ del: { children: phrasingContentSchema.del.children }
143
+ };
144
+ return remainingContentSchema;
131
145
  }
146
+ /**
147
+ * Find out whether or not the given node is phrasing content.
148
+ *
149
+ * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
150
+ *
151
+ * @param node The node to test.
152
+ *
153
+ * @return True if phrasing content, false if not.
154
+ */
132
155
  function isPhrasingContent(node) {
133
- const tag = node.nodeName.toLowerCase();
134
- return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
156
+ const tag = node.nodeName.toLowerCase();
157
+ return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
135
158
  }
159
+ /**
160
+ * @param node
161
+ * @return Node is text content
162
+ */
136
163
  function isTextContent(node) {
137
- const tag = node.nodeName.toLowerCase();
138
- return textContentSchema.hasOwnProperty(tag) || tag === "span";
164
+ const tag = node.nodeName.toLowerCase();
165
+ return textContentSchema.hasOwnProperty(tag) || tag === "span";
139
166
  }
140
- export {
141
- getPhrasingContentSchema,
142
- isPhrasingContent,
143
- isTextContent
144
- };
145
- //# sourceMappingURL=phrasing-content.mjs.map
167
+ export { getPhrasingContentSchema, isPhrasingContent, isTextContent };
168
+
169
+ //# sourceMappingURL=phrasing-content.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/phrasing-content.ts"],
4
- "sourcesContent": ["import type { ContentSchema } from './types';\n\n/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n */\nconst textContentSchema: ContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n */\nconst embeddedContentSchema: ContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'playsinline',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tmath: {\n\t\tattributes: [ 'display', 'xmlns' ],\n\t\tchildren: '*',\n\t},\n};\n\nconst excludedElements = [ '#text', 'br', 'wbr' ];\n\n// Wire up children for each text-level wrapper.\n// - Recursion is needed (e.g. strong > em > strong; not strong > strong).\n// - <img> is allowed too: text-level wrappers accept phrasing content, and\n// <a>'s transparent model permits non-interactive embedded content.\nObject.keys( textContentSchema )\n\t.filter( ( element ) => ! excludedElements.includes( element ) )\n\t.forEach( ( tag ) => {\n\t\tconst { [ tag ]: removedTag, ...restSchema } = textContentSchema;\n\t\ttextContentSchema[ tag ].children = {\n\t\t\t...restSchema,\n\t\t\timg: embeddedContentSchema.img,\n\t\t};\n\t} );\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return Schema.\n */\nexport function getPhrasingContentSchema( context?: string ): ContentSchema {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\tconst {\n\t\tu, // Used to mark misspelling. Shouldn't be pasted.\n\t\tabbr, // Invisible.\n\t\tdata, // Invisible.\n\t\ttime, // Invisible.\n\t\twbr, // Invisible.\n\t\tbdi, // Invisible.\n\t\tbdo, // Invisible.\n\t\t...remainingContentSchema\n\t}: ContentSchema = {\n\t\t...phrasingContentSchema,\n\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t// visible to the user when pasted, so strip the attributes.\n\t\tins: { children: phrasingContentSchema.ins.children },\n\t\tdel: { children: phrasingContentSchema.del.children },\n\t};\n\n\treturn remainingContentSchema;\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param node The node to test.\n *\n * @return True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node: Node ): boolean {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param node\n * @return Node is text content\n */\nexport function isTextContent( node: Node ): boolean {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"],
5
- "mappings": ";AAaA,IAAM,oBAAmC;AAAA,EACxC,QAAQ,CAAC;AAAA,EACT,IAAI,CAAC;AAAA,EACL,GAAG,CAAC;AAAA,EACJ,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,GAAG,EAAE,YAAY,CAAE,QAAQ,UAAU,OAAO,IAAK,EAAE;AAAA,EACnD,MAAM,CAAC;AAAA,EACP,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,KAAK,CAAC;AAAA,EACN,KAAK,CAAC;AAAA,EACN,IAAI,CAAC;AAAA,EACL,OAAO,CAAC;AAAA;AAAA;AAAA,EAGR,GAAG,EAAE,YAAY,CAAE,MAAO,EAAE;AAAA,EAC5B,KAAK,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAC/B,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;AAAA,EAChC,MAAM,EAAE,YAAY,CAAE,UAAW,EAAE;AAAA,EACnC,KAAK,CAAC;AAAA,EACN,MAAM,CAAC;AAAA,EACP,KAAK,CAAC;AAAA,EACN,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,GAAG,CAAC;AAAA,EACJ,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,IAAI,CAAC;AAAA,EACL,IAAI,CAAC;AAAA,EACL,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;AAAA,EAC7B,KAAK,CAAC;AAAA,EACN,SAAS,CAAC;AACX;AAOA,IAAM,wBAAuC;AAAA,EAC5C,OAAO;AAAA,IACN,YAAY;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EACA,QAAQ,EAAE,YAAY,CAAE,SAAS,QAAS,EAAE;AAAA,EAC5C,OAAO,EAAE,YAAY,CAAE,OAAO,QAAQ,SAAS,QAAS,EAAE;AAAA,EAC1D,KAAK;AAAA,IACJ,YAAY;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EACA,QAAQ;AAAA,IACP,YAAY;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,IACN,YAAY;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EACA,MAAM;AAAA,IACL,YAAY,CAAE,WAAW,OAAQ;AAAA,IACjC,UAAU;AAAA,EACX;AACD;AAEA,IAAM,mBAAmB,CAAE,SAAS,MAAM,KAAM;AAMhD,OAAO,KAAM,iBAAkB,EAC7B,OAAQ,CAAE,YAAa,CAAE,iBAAiB,SAAU,OAAQ,CAAE,EAC9D,QAAS,CAAE,QAAS;AACpB,QAAM,EAAE,CAAE,GAAI,GAAG,YAAY,GAAG,WAAW,IAAI;AAC/C,oBAAmB,GAAI,EAAE,WAAW;AAAA,IACnC,GAAG;AAAA,IACH,KAAK,sBAAsB;AAAA,EAC5B;AACD,CAAE;AAOH,IAAM,wBAAwB;AAAA,EAC7B,GAAG;AAAA,EACH,GAAG;AACJ;AAYO,SAAS,yBAA0B,SAAkC;AAC3E,MAAK,YAAY,SAAU;AAC1B,WAAO;AAAA,EACR;AAEA,QAAM;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EACJ,IAAmB;AAAA,IAClB,GAAG;AAAA;AAAA;AAAA,IAGH,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;AAAA,IACpD,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;AAAA,EACrD;AAEA,SAAO;AACR;AAWO,SAAS,kBAAmB,MAAsB;AACxD,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,yBAAyB,EAAE,eAAgB,GAAI,KAAK,QAAQ;AACpE;AAMO,SAAS,cAAe,MAAsB;AACpD,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,kBAAkB,eAAgB,GAAI,KAAK,QAAQ;AAC3D;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"phrasing-content.mjs","names":[],"sources":["../src/phrasing-content.ts"],"sourcesContent":["import type { ContentSchema } from './types';\n\n/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n */\nconst textContentSchema: ContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n */\nconst embeddedContentSchema: ContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'playsinline',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tmath: {\n\t\tattributes: [ 'display', 'xmlns' ],\n\t\tchildren: '*',\n\t},\n};\n\nconst excludedElements = [ '#text', 'br', 'wbr' ];\n\n// Wire up children for each text-level wrapper.\n// - Recursion is needed (e.g. strong > em > strong; not strong > strong).\n// - <img> is allowed too: text-level wrappers accept phrasing content, and\n// <a>'s transparent model permits non-interactive embedded content.\nObject.keys( textContentSchema )\n\t.filter( ( element ) => ! excludedElements.includes( element ) )\n\t.forEach( ( tag ) => {\n\t\tconst { [ tag ]: removedTag, ...restSchema } = textContentSchema;\n\t\ttextContentSchema[ tag ].children = {\n\t\t\t...restSchema,\n\t\t\timg: embeddedContentSchema.img,\n\t\t};\n\t} );\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return Schema.\n */\nexport function getPhrasingContentSchema( context?: string ): ContentSchema {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\tconst {\n\t\tu, // Used to mark misspelling. Shouldn't be pasted.\n\t\tabbr, // Invisible.\n\t\tdata, // Invisible.\n\t\ttime, // Invisible.\n\t\twbr, // Invisible.\n\t\tbdi, // Invisible.\n\t\tbdo, // Invisible.\n\t\t...remainingContentSchema\n\t}: ContentSchema = {\n\t\t...phrasingContentSchema,\n\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t// visible to the user when pasted, so strip the attributes.\n\t\tins: { children: phrasingContentSchema.ins.children },\n\t\tdel: { children: phrasingContentSchema.del.children },\n\t};\n\n\treturn remainingContentSchema;\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param node The node to test.\n *\n * @return True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node: Node ): boolean {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param node\n * @return Node is text content\n */\nexport function isTextContent( node: Node ): boolean {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,oBAAmC;CACxC,QAAQ,CAAC;CACT,IAAI,CAAC;CACL,GAAG,CAAC;CACJ,KAAK,CAAC;CACN,KAAK,CAAC;CACN,GAAG,EAAE,YAAY;EAAE;EAAQ;EAAU;EAAO;CAAK,EAAE;CACnD,MAAM,CAAC;CACP,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;CAChC,KAAK,CAAC;CACN,KAAK,CAAC;CACN,IAAI,CAAC;CACL,OAAO,CAAC;CAGR,GAAG,EAAE,YAAY,CAAE,MAAO,EAAE;CAC5B,KAAK,EAAE,YAAY,CAAE,OAAQ,EAAE;CAC/B,MAAM,EAAE,YAAY,CAAE,OAAQ,EAAE;CAChC,MAAM,EAAE,YAAY,CAAE,UAAW,EAAE;CACnC,KAAK,CAAC;CACN,MAAM,CAAC;CACP,KAAK,CAAC;CACN,GAAG,CAAC;CACJ,GAAG,CAAC;CACJ,GAAG,CAAC;CACJ,MAAM,CAAC;CACP,MAAM,CAAC;CACP,IAAI,CAAC;CACL,IAAI,CAAC;CACL,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;CAC7B,KAAK,EAAE,YAAY,CAAE,KAAM,EAAE;CAC7B,KAAK,CAAC;CACN,SAAS,CAAC;AACX;;;;;;AAOA,MAAM,wBAAuC;CAC5C,OAAO,EACN,YAAY;EACX;EACA;EACA;EACA;EACA;EACA;CACD,EACD;CACA,QAAQ,EAAE,YAAY,CAAE,SAAS,QAAS,EAAE;CAC5C,OAAO,EAAE,YAAY;EAAE;EAAO;EAAQ;EAAS;CAAS,EAAE;CAC1D,KAAK,EACJ,YAAY;EACX;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EACD;CACA,QAAQ,EACP,YAAY;EACX;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EACD;CACA,OAAO,EACN,YAAY;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EACD;CACA,MAAM;EACL,YAAY,CAAE,WAAW,OAAQ;EACjC,UAAU;CACX;AACD;AAEA,MAAM,mBAAmB;CAAE;CAAS;CAAM;AAAM;AAMhD,OAAO,KAAM,iBAAkB,CAAC,CAC9B,QAAU,YAAa,CAAE,iBAAiB,SAAU,OAAQ,CAAE,CAAC,CAC/D,SAAW,QAAS;CACpB,MAAM,GAAI,MAAO,YAAY,GAAG,eAAe;CAC/C,kBAAmB,IAAK,CAAC,WAAW;EACnC,GAAG;EACH,KAAK,sBAAsB;CAC5B;AACD,CAAE;;;;;;AAOH,MAAM,wBAAwB;CAC7B,GAAG;CACH,GAAG;AACJ;;;;;;;;;;;AAYA,SAAgB,yBAA0B,SAAkC;CAC3E,IAAK,YAAY,SAChB,OAAO;CAGR,MAAM,EACL,GACA,MACA,MACA,MACA,KACA,KACA,KACA,GAAG,2BACe;EAClB,GAAG;EAGH,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;EACpD,KAAK,EAAE,UAAU,sBAAsB,IAAI,SAAS;CACrD;CAEA,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,kBAAmB,MAAsB;CACxD,MAAM,MAAM,KAAK,SAAS,YAAY;CACtC,OAAO,yBAAyB,CAAC,CAAC,eAAgB,GAAI,KAAK,QAAQ;AACpE;;;;;AAMA,SAAgB,cAAe,MAAsB;CACpD,MAAM,MAAM,KAAK,SAAS,YAAY;CACtC,OAAO,kBAAkB,eAAgB,GAAI,KAAK,QAAQ;AAC3D"}
@@ -1,72 +1,137 @@
1
+ import { find as find$1 } from "./focusable.mjs";
1
2
  // packages/dom/src/tabbable.ts
2
- import { find as findFocusable } from "./focusable.mjs";
3
+ /**
4
+ * Returns the tab index of the given element. In contrast with the tabIndex
5
+ * property, this normalizes the default (0) to avoid browser inconsistencies,
6
+ * operating under the assumption that this function is only ever called with a
7
+ * focusable node.
8
+ *
9
+ * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261
10
+ *
11
+ * @param element Element from which to retrieve.
12
+ *
13
+ * @return Tab index of element (default 0).
14
+ */
3
15
  function getTabIndex(element) {
4
- const tabIndex = element.getAttribute("tabindex");
5
- return tabIndex === null ? 0 : parseInt(tabIndex, 10);
16
+ const tabIndex = element.getAttribute("tabindex");
17
+ return tabIndex === null ? 0 : parseInt(tabIndex, 10);
6
18
  }
19
+ /**
20
+ * Returns true if the specified element is tabbable, or false otherwise.
21
+ *
22
+ * @param element Element to test.
23
+ *
24
+ * @return Whether element is tabbable.
25
+ */
7
26
  function isTabbableIndex(element) {
8
- return getTabIndex(element) !== -1;
27
+ return getTabIndex(element) !== -1;
9
28
  }
29
+ /**
30
+ * Returns a stateful reducer function which constructs a filtered array of
31
+ * tabbable elements, where at most one radio input is selected for a given
32
+ * name, giving priority to checked input, falling back to the first
33
+ * encountered.
34
+ *
35
+ * @return Radio group collapse reducer.
36
+ */
10
37
  function createStatefulCollapseRadioGroup() {
11
- const CHOSEN_RADIO_BY_NAME = {};
12
- return function collapseRadioGroup(result, element) {
13
- const { nodeName, type, checked, name } = element;
14
- if (nodeName !== "INPUT" || type !== "radio" || !name) {
15
- return result.concat(element);
16
- }
17
- const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
18
- const isChosen = checked || !hasChosen;
19
- if (!isChosen) {
20
- return result;
21
- }
22
- if (hasChosen) {
23
- const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
24
- result = result.filter((e) => e !== hadChosenElement);
25
- }
26
- CHOSEN_RADIO_BY_NAME[name] = element;
27
- return result.concat(element);
28
- };
38
+ const CHOSEN_RADIO_BY_NAME = {};
39
+ return function collapseRadioGroup(result, element) {
40
+ const { nodeName, type, checked, name } = element;
41
+ if (nodeName !== "INPUT" || type !== "radio" || !name) return result.concat(element);
42
+ const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
43
+ if (!(checked || !hasChosen)) return result;
44
+ if (hasChosen) {
45
+ const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
46
+ result = result.filter((e) => e !== hadChosenElement);
47
+ }
48
+ CHOSEN_RADIO_BY_NAME[name] = element;
49
+ return result.concat(element);
50
+ };
29
51
  }
52
+ /**
53
+ * An array map callback, returning an object with the element value and its
54
+ * array index location as properties. This is used to emulate a proper stable
55
+ * sort where equal tabIndex should be left in order of their occurrence in the
56
+ * document.
57
+ *
58
+ * @param element Element.
59
+ * @param index Array index of element.
60
+ *
61
+ * @return Mapped object with element, index.
62
+ */
30
63
  function mapElementToObjectTabbable(element, index) {
31
- return { element, index };
64
+ return {
65
+ element,
66
+ index
67
+ };
32
68
  }
69
+ /**
70
+ * An array map callback, returning an element of the given mapped object's
71
+ * element value.
72
+ *
73
+ * @param object Mapped object with element.
74
+ *
75
+ * @return Mapped object element.
76
+ */
33
77
  function mapObjectTabbableToElement(object) {
34
- return object.element;
78
+ return object.element;
35
79
  }
80
+ /**
81
+ * A sort comparator function used in comparing two objects of mapped elements.
82
+ *
83
+ * @see mapElementToObjectTabbable
84
+ *
85
+ * @param a First object to compare.
86
+ * @param b Second object to compare.
87
+ *
88
+ * @return Comparator result.
89
+ */
36
90
  function compareObjectTabbables(a, b) {
37
- const aTabIndex = getTabIndex(a.element);
38
- const bTabIndex = getTabIndex(b.element);
39
- if (aTabIndex === bTabIndex) {
40
- return a.index - b.index;
41
- }
42
- return aTabIndex - bTabIndex;
91
+ const aTabIndex = getTabIndex(a.element);
92
+ const bTabIndex = getTabIndex(b.element);
93
+ if (aTabIndex === bTabIndex) return a.index - b.index;
94
+ return aTabIndex - bTabIndex;
43
95
  }
96
+ /**
97
+ * Given focusable elements, filters out tabbable element.
98
+ *
99
+ * @param focusables Focusable elements to filter.
100
+ *
101
+ * @return Tabbable elements.
102
+ */
44
103
  function filterTabbable(focusables) {
45
- return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
104
+ return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
46
105
  }
106
+ /**
107
+ * @param context
108
+ * @return Tabbable elements within the context.
109
+ */
47
110
  function find(context) {
48
- return filterTabbable(findFocusable(context));
111
+ return filterTabbable(find$1(context));
49
112
  }
113
+ /**
114
+ * Given a focusable element, find the preceding tabbable element.
115
+ *
116
+ * @param element The focusable element before which to look. Defaults
117
+ * to the active element.
118
+ *
119
+ * @return Preceding tabbable element.
120
+ */
50
121
  function findPrevious(element) {
51
- return filterTabbable(findFocusable(element.ownerDocument.body)).reverse().find(
52
- (focusable) => (
53
- // eslint-disable-next-line no-bitwise
54
- element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING
55
- )
56
- );
122
+ return filterTabbable(find$1(element.ownerDocument.body)).reverse().find((focusable) => element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING);
57
123
  }
124
+ /**
125
+ * Given a focusable element, find the next tabbable element.
126
+ *
127
+ * @param element The focusable element after which to look. Defaults
128
+ * to the active element.
129
+ *
130
+ * @return Next tabbable element.
131
+ */
58
132
  function findNext(element) {
59
- return filterTabbable(findFocusable(element.ownerDocument.body)).find(
60
- (focusable) => (
61
- // eslint-disable-next-line no-bitwise
62
- element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING
63
- )
64
- );
133
+ return filterTabbable(find$1(element.ownerDocument.body)).find((focusable) => element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING);
65
134
  }
66
- export {
67
- find,
68
- findNext,
69
- findPrevious,
70
- isTabbableIndex
71
- };
72
- //# sourceMappingURL=tabbable.mjs.map
135
+ export { find, findNext, findPrevious, isTabbableIndex };
136
+
137
+ //# sourceMappingURL=tabbable.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/tabbable.ts"],
4
- "sourcesContent": ["import type { MaybeHTMLInputElement, ObjectTabbable } from './types';\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param element Element from which to retrieve.\n *\n * @return Tab index of element (default 0).\n */\nfunction getTabIndex( element: Element ): number {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param element Element to test.\n *\n * @return Whether element is tabbable.\n */\nexport function isTabbableIndex( element: Element ): boolean {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup(): (\n\tacc: MaybeHTMLInputElement[],\n\tel: MaybeHTMLInputElement\n) => MaybeHTMLInputElement[] {\n\tconst CHOSEN_RADIO_BY_NAME: Record< string, MaybeHTMLInputElement > = {};\n\n\treturn function collapseRadioGroup(\n\t\tresult: MaybeHTMLInputElement[],\n\t\telement: MaybeHTMLInputElement\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = result.filter( ( e ) => e !== hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param element Element.\n * @param index Array index of element.\n *\n * @return Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable(\n\telement: HTMLElement,\n\tindex: number\n): ObjectTabbable {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param object Mapped object with element.\n *\n * @return Mapped object element.\n */\nfunction mapObjectTabbableToElement(\n\tobject: Pick< ObjectTabbable, 'element' >\n): HTMLElement {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param a First object to compare.\n * @param b Second object to compare.\n *\n * @return Comparator result.\n */\nfunction compareObjectTabbables(\n\ta: ObjectTabbable,\n\tb: ObjectTabbable\n): number {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Given focusable elements, filters out tabbable element.\n *\n * @param focusables Focusable elements to filter.\n *\n * @return Tabbable elements.\n */\nfunction filterTabbable( focusables: HTMLElement[] ): HTMLElement[] {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param context\n * @return Tabbable elements within the context.\n */\nexport function find( context: Element ): HTMLElement[] {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return Preceding tabbable element.\n */\nexport function findPrevious( element: Element ): HTMLElement | undefined {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) )\n\t\t.reverse()\n\t\t.find(\n\t\t\t( focusable ) =>\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\t\telement.DOCUMENT_POSITION_PRECEDING\n\t\t);\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return Next tabbable element.\n */\nexport function findNext( element: Element ): HTMLElement | undefined {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) ).find(\n\t\t( focusable ) =>\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\telement.DOCUMENT_POSITION_FOLLOWING\n\t);\n}\n"],
5
- "mappings": ";AACA,SAAS,QAAQ,qBAAqB;AActC,SAAS,YAAa,SAA2B;AAChD,QAAM,WAAW,QAAQ,aAAc,UAAW;AAClD,SAAO,aAAa,OAAO,IAAI,SAAU,UAAU,EAAG;AACvD;AASO,SAAS,gBAAiB,SAA4B;AAC5D,SAAO,YAAa,OAAQ,MAAM;AACnC;AAUA,SAAS,mCAGoB;AAC5B,QAAM,uBAAgE,CAAC;AAEvE,SAAO,SAAS,mBACf,QACA,SACC;AACD,UAAM,EAAE,UAAU,MAAM,SAAS,KAAK,IAAI;AAG1C,QAAK,aAAa,WAAW,SAAS,WAAW,CAAE,MAAO;AACzD,aAAO,OAAO,OAAQ,OAAQ;AAAA,IAC/B;AAEA,UAAM,YAAY,qBAAqB,eAAgB,IAAK;AAG5D,UAAM,WAAW,WAAW,CAAE;AAC9B,QAAK,CAAE,UAAW;AACjB,aAAO;AAAA,IACR;AAKA,QAAK,WAAY;AAChB,YAAM,mBAAmB,qBAAsB,IAAK;AACpD,eAAS,OAAO,OAAQ,CAAE,MAAO,MAAM,gBAAiB;AAAA,IACzD;AAEA,yBAAsB,IAAK,IAAI;AAE/B,WAAO,OAAO,OAAQ,OAAQ;AAAA,EAC/B;AACD;AAaA,SAAS,2BACR,SACA,OACiB;AACjB,SAAO,EAAE,SAAS,MAAM;AACzB;AAUA,SAAS,2BACR,QACc;AACd,SAAO,OAAO;AACf;AAYA,SAAS,uBACR,GACA,GACS;AACT,QAAM,YAAY,YAAa,EAAE,OAAQ;AACzC,QAAM,YAAY,YAAa,EAAE,OAAQ;AAEzC,MAAK,cAAc,WAAY;AAC9B,WAAO,EAAE,QAAQ,EAAE;AAAA,EACpB;AAEA,SAAO,YAAY;AACpB;AASA,SAAS,eAAgB,YAA2C;AACnE,SAAO,WACL,OAAQ,eAAgB,EACxB,IAAK,0BAA2B,EAChC,KAAM,sBAAuB,EAC7B,IAAK,0BAA2B,EAChC,OAAQ,iCAAiC,GAAG,CAAC,CAAE;AAClD;AAMO,SAAS,KAAM,SAAkC;AACvD,SAAO,eAAgB,cAAe,OAAQ,CAAE;AACjD;AAUO,SAAS,aAAc,SAA4C;AACzE,SAAO,eAAgB,cAAe,QAAQ,cAAc,IAAK,CAAE,EACjE,QAAQ,EACR;AAAA,IACA,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACF;AAUO,SAAS,SAAU,SAA4C;AACrE,SAAO,eAAgB,cAAe,QAAQ,cAAc,IAAK,CAAE,EAAE;AAAA,IACpE,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"tabbable.mjs","names":["findFocusable"],"sources":["../src/tabbable.ts"],"sourcesContent":["import type { MaybeHTMLInputElement, ObjectTabbable } from './types';\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param element Element from which to retrieve.\n *\n * @return Tab index of element (default 0).\n */\nfunction getTabIndex( element: Element ): number {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param element Element to test.\n *\n * @return Whether element is tabbable.\n */\nexport function isTabbableIndex( element: Element ): boolean {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup(): (\n\tacc: MaybeHTMLInputElement[],\n\tel: MaybeHTMLInputElement\n) => MaybeHTMLInputElement[] {\n\tconst CHOSEN_RADIO_BY_NAME: Record< string, MaybeHTMLInputElement > = {};\n\n\treturn function collapseRadioGroup(\n\t\tresult: MaybeHTMLInputElement[],\n\t\telement: MaybeHTMLInputElement\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = result.filter( ( e ) => e !== hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param element Element.\n * @param index Array index of element.\n *\n * @return Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable(\n\telement: HTMLElement,\n\tindex: number\n): ObjectTabbable {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param object Mapped object with element.\n *\n * @return Mapped object element.\n */\nfunction mapObjectTabbableToElement(\n\tobject: Pick< ObjectTabbable, 'element' >\n): HTMLElement {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param a First object to compare.\n * @param b Second object to compare.\n *\n * @return Comparator result.\n */\nfunction compareObjectTabbables(\n\ta: ObjectTabbable,\n\tb: ObjectTabbable\n): number {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Given focusable elements, filters out tabbable element.\n *\n * @param focusables Focusable elements to filter.\n *\n * @return Tabbable elements.\n */\nfunction filterTabbable( focusables: HTMLElement[] ): HTMLElement[] {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param context\n * @return Tabbable elements within the context.\n */\nexport function find( context: Element ): HTMLElement[] {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return Preceding tabbable element.\n */\nexport function findPrevious( element: Element ): HTMLElement | undefined {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) )\n\t\t.reverse()\n\t\t.find(\n\t\t\t( focusable ) =>\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\t\telement.DOCUMENT_POSITION_PRECEDING\n\t\t);\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return Next tabbable element.\n */\nexport function findNext( element: Element ): HTMLElement | undefined {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) ).find(\n\t\t( focusable ) =>\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\telement.DOCUMENT_POSITION_FOLLOWING\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAS,YAAa,SAA2B;CAChD,MAAM,WAAW,QAAQ,aAAc,UAAW;CAClD,OAAO,aAAa,OAAO,IAAI,SAAU,UAAU,EAAG;AACvD;;;;;;;;AASA,SAAgB,gBAAiB,SAA4B;CAC5D,OAAO,YAAa,OAAQ,MAAM;AACnC;;;;;;;;;AAUA,SAAS,mCAGoB;CAC5B,MAAM,uBAAgE,CAAC;CAEvE,OAAO,SAAS,mBACf,QACA,SACC;EACD,MAAM,EAAE,UAAU,MAAM,SAAS,SAAS;EAG1C,IAAK,aAAa,WAAW,SAAS,WAAW,CAAE,MAClD,OAAO,OAAO,OAAQ,OAAQ;EAG/B,MAAM,YAAY,qBAAqB,eAAgB,IAAK;EAI5D,IAAK,EADY,WAAW,CAAE,YAE7B,OAAO;EAMR,IAAK,WAAY;GAChB,MAAM,mBAAmB,qBAAsB;GAC/C,SAAS,OAAO,QAAU,MAAO,MAAM,gBAAiB;EACzD;EAEA,qBAAsB,QAAS;EAE/B,OAAO,OAAO,OAAQ,OAAQ;CAC/B;AACD;;;;;;;;;;;;AAaA,SAAS,2BACR,SACA,OACiB;CACjB,OAAO;EAAE;EAAS;CAAM;AACzB;;;;;;;;;AAUA,SAAS,2BACR,QACc;CACd,OAAO,OAAO;AACf;;;;;;;;;;;AAYA,SAAS,uBACR,GACA,GACS;CACT,MAAM,YAAY,YAAa,EAAE,OAAQ;CACzC,MAAM,YAAY,YAAa,EAAE,OAAQ;CAEzC,IAAK,cAAc,WAClB,OAAO,EAAE,QAAQ,EAAE;CAGpB,OAAO,YAAY;AACpB;;;;;;;;AASA,SAAS,eAAgB,YAA2C;CACnE,OAAO,WACL,OAAQ,eAAgB,CAAC,CACzB,IAAK,0BAA2B,CAAC,CACjC,KAAM,sBAAuB,CAAC,CAC9B,IAAK,0BAA2B,CAAC,CACjC,OAAQ,iCAAiC,GAAG,CAAC,CAAE;AAClD;;;;;AAMA,SAAgB,KAAM,SAAkC;CACvD,OAAO,eAAgBA,OAAe,OAAQ,CAAE;AACjD;;;;;;;;;AAUA,SAAgB,aAAc,SAA4C;CACzE,OAAO,eAAgBA,OAAe,QAAQ,cAAc,IAAK,CAAE,CAAC,CAClE,QAAQ,CAAC,CACT,MACE,cAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ,2BACV;AACF;;;;;;;;;AAUA,SAAgB,SAAU,SAA4C;CACrE,OAAO,eAAgBA,OAAe,QAAQ,cAAc,IAAK,CAAE,CAAC,CAAC,MAClE,cAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ,2BACV;AACD"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.mjs.map
@@ -1,12 +1,7 @@
1
1
  // packages/dom/src/utils/assert-is-defined.ts
2
2
  function assertIsDefined(val, name) {
3
- if (process.env.NODE_ENV !== "production" && (val === void 0 || val === null)) {
4
- throw new Error(
5
- `Expected '${name}' to be defined, but received ${val}`
6
- );
7
- }
3
+ if (process.env.NODE_ENV !== "production" && (val === void 0 || val === null)) throw new Error(`Expected '${name}' to be defined, but received ${val}`);
8
4
  }
9
- export {
10
- assertIsDefined
11
- };
12
- //# sourceMappingURL=assert-is-defined.mjs.map
5
+ export { assertIsDefined };
6
+
7
+ //# sourceMappingURL=assert-is-defined.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/assert-is-defined.ts"],
4
- "sourcesContent": ["export function assertIsDefined< T >(\n\tval: T,\n\tname: string\n): asserts val is NonNullable< T > {\n\tif (\n\t\tprocess.env.NODE_ENV !== 'production' &&\n\t\t( val === undefined || val === null )\n\t) {\n\t\tthrow new Error(\n\t\t\t`Expected '${ name }' to be defined, but received ${ val }`\n\t\t);\n\t}\n}\n"],
5
- "mappings": ";AAAO,SAAS,gBACf,KACA,MACkC;AAClC,MACC,QAAQ,IAAI,aAAa,iBACvB,QAAQ,UAAa,QAAQ,OAC9B;AACD,UAAM,IAAI;AAAA,MACT,aAAc,IAAK,iCAAkC,GAAI;AAAA,IAC1D;AAAA,EACD;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"assert-is-defined.mjs","names":[],"sources":["../../src/utils/assert-is-defined.ts"],"sourcesContent":["export function assertIsDefined< T >(\n\tval: T,\n\tname: string\n): asserts val is NonNullable< T > {\n\tif (\n\t\tprocess.env.NODE_ENV !== 'production' &&\n\t\t( val === undefined || val === null )\n\t) {\n\t\tthrow new Error(\n\t\t\t`Expected '${ name }' to be defined, but received ${ val }`\n\t\t);\n\t}\n}\n"],"mappings":";AAAA,SAAgB,gBACf,KACA,MACkC;CAClC,IACC,QAAQ,IAAI,aAAa,iBACvB,QAAQ,KAAA,KAAa,QAAQ,OAE/B,MAAM,IAAI,MACT,aAAc,KAAM,gCAAiC,KACtD;AAEF"}
@@ -6,7 +6,7 @@ import type { Schema } from './types';
6
6
  * @param nodeList The nodeList to filter.
7
7
  * @param doc The document of the nodeList.
8
8
  * @param schema Schema for the HTML.
9
- * @param inline Whether to clean for inline mode.
9
+ * @param [inline] Whether to clean for inline mode.
10
10
  */
11
- export default function cleanNodeList(nodeList: NodeList, doc: Document, schema: Schema, inline: boolean): void;
11
+ export default function cleanNodeList(nodeList: NodeList, doc: Document, schema: Schema, inline?: boolean): void;
12
12
  //# sourceMappingURL=clean-node-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clean-node-list.d.ts","sourceRoot":"","sources":["../../src/dom/clean-node-list.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACpC,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,QAiKf"}
1
+ {"version":3,"file":"clean-node-list.d.ts","sourceRoot":"","sources":["../../src/dom/clean-node-list.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACpC,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,QAiKhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"is-edge.d.ts","sourceRoot":"","sources":["../../src/dom/is-edge.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC7B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,OAAO,EAClB,YAAY,GAAE,OAAe,GAC3B,OAAO,CAiIT"}
1
+ {"version":3,"file":"is-edge.d.ts","sourceRoot":"","sources":["../../src/dom/is-edge.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC7B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,OAAO,EAClB,YAAY,GAAE,OAAe,GAC3B,OAAO,CA0HT"}
@@ -2,11 +2,11 @@ import type { Schema } from './types';
2
2
  /**
3
3
  * Given a schema, unwraps or removes nodes, attributes and classes on HTML.
4
4
  *
5
- * @param {string} HTML The HTML to clean up.
6
- * @param {Schema} schema Schema for the HTML.
7
- * @param {boolean} inline Whether to clean for inline mode.
5
+ * @param {string} HTML The HTML to clean up.
6
+ * @param {Schema} schema Schema for the HTML.
7
+ * @param {boolean} [inline] Whether to clean for inline mode.
8
8
  *
9
9
  * @return {string} The cleaned up HTML.
10
10
  */
11
- export default function removeInvalidHTML(HTML: string, schema: Schema, inline: boolean): string;
11
+ export default function removeInvalidHTML(HTML: string, schema: Schema, inline?: boolean): string;
12
12
  //# sourceMappingURL=remove-invalid-html.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remove-invalid-html.d.ts","sourceRoot":"","sources":["../../src/dom/remove-invalid-html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACb,MAAM,CAQR"}
1
+ {"version":3,"file":"remove-invalid-html.d.ts","sourceRoot":"","sources":["../../src/dom/remove-invalid-html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,GACd,MAAM,CAQR"}