@wordpress/dom 4.57.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 (334) hide show
  1. package/README.md +23 -23
  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 +88 -133
  7. package/build/dom/clean-node-list.cjs.map +1 -7
  8. package/build/dom/compute-caret-rect.cjs +36 -36
  9. package/build/dom/compute-caret-rect.cjs.map +1 -7
  10. package/build/dom/document-has-selection.cjs +36 -31
  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 +35 -30
  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 +41 -48
  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 -133
  23. package/build/dom/get-rectangle-from-range.cjs.map +1 -7
  24. package/build/dom/get-scroll-container.cjs +47 -55
  25. package/build/dom/get-scroll-container.cjs.map +1 -7
  26. package/build/dom/hidden-caret-range-from-point.cjs +49 -43
  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 +49 -47
  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 +83 -98
  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 -40
  38. package/build/dom/is-empty.cjs.map +1 -7
  39. package/build/dom/is-entirely-selected.cjs +71 -71
  40. package/build/dom/is-entirely-selected.cjs.map +1 -7
  41. package/build/dom/is-form-element.cjs +34 -34
  42. package/build/dom/is-form-element.cjs.map +1 -7
  43. package/build/dom/is-horizontal-edge.cjs +32 -29
  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 +37 -34
  50. package/build/dom/is-number-input.cjs.map +1 -7
  51. package/build/dom/is-rtl.cjs +31 -29
  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 +46 -44
  56. package/build/dom/is-text-field.cjs.map +1 -7
  57. package/build/dom/is-vertical-edge.cjs +32 -29
  58. package/build/dom/is-vertical-edge.cjs.map +1 -7
  59. package/build/dom/place-caret-at-edge.cjs +76 -79
  60. package/build/dom/place-caret-at-edge.cjs.map +1 -7
  61. package/build/dom/place-caret-at-horizontal-edge.cjs +30 -29
  62. package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
  63. package/build/dom/place-caret-at-vertical-edge.cjs +31 -29
  64. package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
  65. package/build/dom/remove-invalid-html.cjs +36 -32
  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 +35 -33
  72. package/build/dom/replace.cjs.map +1 -7
  73. package/build/dom/safe-html.cjs +46 -47
  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 +34 -32
  78. package/build/dom/strip-html.cjs.map +1 -7
  79. package/build/dom/types.cjs +5 -0
  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 -77
  85. package/build/focusable.cjs.map +1 -7
  86. package/build/index.cjs +58 -39
  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 +5 -0
  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 +17 -15
  96. package/build-module/data-transfer.mjs.map +1 -7
  97. package/build-module/dom/caret-range-from-point.mjs +28 -19
  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 +21 -25
  112. package/build-module/dom/get-offset-parent.mjs.map +1 -7
  113. package/build-module/dom/get-range-height.mjs +15 -12
  114. package/build-module/dom/get-range-height.mjs.map +1 -7
  115. package/build-module/dom/get-rectangle-from-range.mjs +78 -113
  116. package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
  117. package/build-module/dom/get-scroll-container.mjs +28 -32
  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 -23
  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 +9 -6
  129. package/build-module/dom/is-element.mjs.map +1 -7
  130. package/build-module/dom/is-empty.mjs +20 -21
  131. package/build-module/dom/is-empty.mjs.map +1 -7
  132. package/build-module/dom/is-entirely-selected.mjs +51 -47
  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 +9 -6
  139. package/build-module/dom/is-html-input-element.mjs.map +1 -7
  140. package/build-module/dom/is-input-or-text-area.mjs +9 -6
  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 -21
  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 +21 -14
  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 -0
  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 +96 -54
  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 +158 -134
  182. package/build-module/phrasing-content.mjs.map +1 -7
  183. package/build-module/tabbable.mjs +117 -52
  184. package/build-module/tabbable.mjs.map +1 -7
  185. package/build-module/types.mjs +0 -0
  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/data-transfer.d.ts +2 -2
  189. package/build-types/data-transfer.d.ts.map +1 -1
  190. package/build-types/dom/caret-range-from-point.d.ts +4 -4
  191. package/build-types/dom/caret-range-from-point.d.ts.map +1 -1
  192. package/build-types/dom/clean-node-list.d.ts +6 -46
  193. package/build-types/dom/clean-node-list.d.ts.map +1 -1
  194. package/build-types/dom/compute-caret-rect.d.ts +2 -2
  195. package/build-types/dom/compute-caret-rect.d.ts.map +1 -1
  196. package/build-types/dom/document-has-selection.d.ts +2 -2
  197. package/build-types/dom/document-has-selection.d.ts.map +1 -1
  198. package/build-types/dom/document-has-text-selection.d.ts +2 -2
  199. package/build-types/dom/document-has-text-selection.d.ts.map +1 -1
  200. package/build-types/dom/document-has-uncollapsed-selection.d.ts +2 -2
  201. package/build-types/dom/document-has-uncollapsed-selection.d.ts.map +1 -1
  202. package/build-types/dom/get-computed-style.d.ts +3 -3
  203. package/build-types/dom/get-computed-style.d.ts.map +1 -1
  204. package/build-types/dom/get-offset-parent.d.ts +2 -2
  205. package/build-types/dom/get-offset-parent.d.ts.map +1 -1
  206. package/build-types/dom/get-range-height.d.ts +2 -2
  207. package/build-types/dom/get-range-height.d.ts.map +1 -1
  208. package/build-types/dom/get-rectangle-from-range.d.ts +2 -2
  209. package/build-types/dom/get-rectangle-from-range.d.ts.map +1 -1
  210. package/build-types/dom/get-scroll-container.d.ts +5 -5
  211. package/build-types/dom/get-scroll-container.d.ts.map +1 -1
  212. package/build-types/dom/hidden-caret-range-from-point.d.ts +5 -5
  213. package/build-types/dom/hidden-caret-range-from-point.d.ts.map +1 -1
  214. package/build-types/dom/index.d.ts.map +1 -1
  215. package/build-types/dom/input-field-has-uncollapsed-selection.d.ts +2 -2
  216. package/build-types/dom/input-field-has-uncollapsed-selection.d.ts.map +1 -1
  217. package/build-types/dom/insert-after.d.ts +2 -3
  218. package/build-types/dom/insert-after.d.ts.map +1 -1
  219. package/build-types/dom/is-edge.d.ts +4 -4
  220. package/build-types/dom/is-edge.d.ts.map +1 -1
  221. package/build-types/dom/is-element.d.ts.map +1 -1
  222. package/build-types/dom/is-empty.d.ts +3 -3
  223. package/build-types/dom/is-empty.d.ts.map +1 -1
  224. package/build-types/dom/is-entirely-selected.d.ts +2 -2
  225. package/build-types/dom/is-entirely-selected.d.ts.map +1 -1
  226. package/build-types/dom/is-form-element.d.ts +3 -3
  227. package/build-types/dom/is-form-element.d.ts.map +1 -1
  228. package/build-types/dom/is-horizontal-edge.d.ts.map +1 -1
  229. package/build-types/dom/is-html-input-element.d.ts +1 -1
  230. package/build-types/dom/is-html-input-element.d.ts.map +1 -1
  231. package/build-types/dom/is-input-or-text-area.d.ts.map +1 -1
  232. package/build-types/dom/is-number-input.d.ts +2 -2
  233. package/build-types/dom/is-number-input.d.ts.map +1 -1
  234. package/build-types/dom/is-rtl.d.ts +2 -2
  235. package/build-types/dom/is-rtl.d.ts.map +1 -1
  236. package/build-types/dom/is-selection-forward.d.ts +2 -2
  237. package/build-types/dom/is-selection-forward.d.ts.map +1 -1
  238. package/build-types/dom/is-text-field.d.ts +2 -2
  239. package/build-types/dom/is-text-field.d.ts.map +1 -1
  240. package/build-types/dom/is-vertical-edge.d.ts.map +1 -1
  241. package/build-types/dom/place-caret-at-edge.d.ts +3 -3
  242. package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
  243. package/build-types/dom/place-caret-at-horizontal-edge.d.ts.map +1 -1
  244. package/build-types/dom/place-caret-at-vertical-edge.d.ts.map +1 -1
  245. package/build-types/dom/remove-invalid-html.d.ts +5 -4
  246. package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
  247. package/build-types/dom/remove.d.ts +1 -2
  248. package/build-types/dom/remove.d.ts.map +1 -1
  249. package/build-types/dom/replace-tag.d.ts +3 -3
  250. package/build-types/dom/replace-tag.d.ts.map +1 -1
  251. package/build-types/dom/replace.d.ts +2 -3
  252. package/build-types/dom/replace.d.ts.map +1 -1
  253. package/build-types/dom/safe-html.d.ts +2 -2
  254. package/build-types/dom/safe-html.d.ts.map +1 -1
  255. package/build-types/dom/scroll-if-no-range.d.ts +5 -5
  256. package/build-types/dom/scroll-if-no-range.d.ts.map +1 -1
  257. package/build-types/dom/strip-html.d.ts +2 -2
  258. package/build-types/dom/strip-html.d.ts.map +1 -1
  259. package/build-types/dom/types.d.ts +32 -0
  260. package/build-types/dom/types.d.ts.map +1 -0
  261. package/build-types/dom/unwrap.d.ts +1 -3
  262. package/build-types/dom/unwrap.d.ts.map +1 -1
  263. package/build-types/dom/wrap.d.ts +2 -2
  264. package/build-types/dom/wrap.d.ts.map +1 -1
  265. package/build-types/focusable.d.ts +11 -30
  266. package/build-types/focusable.d.ts.map +1 -1
  267. package/build-types/index.d.ts +17 -0
  268. package/build-types/index.d.ts.map +1 -1
  269. package/build-types/phrasing-content.d.ts +9 -24
  270. package/build-types/phrasing-content.d.ts.map +1 -1
  271. package/build-types/tabbable.d.ts +10 -15
  272. package/build-types/tabbable.d.ts.map +1 -1
  273. package/build-types/types.d.ts +29 -0
  274. package/build-types/types.d.ts.map +1 -0
  275. package/package.json +6 -7
  276. package/src/{data-transfer.js → data-transfer.ts} +3 -3
  277. package/src/dom/{caret-range-from-point.js → caret-range-from-point.ts} +9 -5
  278. package/src/dom/{clean-node-list.js → clean-node-list.ts} +16 -24
  279. package/src/dom/{compute-caret-rect.js → compute-caret-rect.ts} +3 -3
  280. package/src/dom/{document-has-selection.js → document-has-selection.ts} +3 -3
  281. package/src/dom/{document-has-text-selection.js → document-has-text-selection.ts} +3 -3
  282. package/src/dom/{document-has-uncollapsed-selection.js → document-has-uncollapsed-selection.ts} +5 -3
  283. package/src/dom/{get-computed-style.js → get-computed-style.ts} +5 -3
  284. package/src/dom/{get-offset-parent.js → get-offset-parent.ts} +9 -14
  285. package/src/dom/{get-range-height.js → get-range-height.ts} +3 -3
  286. package/src/dom/{get-rectangle-from-range.js → get-rectangle-from-range.ts} +6 -12
  287. package/src/dom/{get-scroll-container.js → get-scroll-container.ts} +9 -9
  288. package/src/dom/{hidden-caret-range-from-point.js → hidden-caret-range-from-point.ts} +11 -6
  289. package/src/dom/{input-field-has-uncollapsed-selection.js → input-field-has-uncollapsed-selection.ts} +7 -5
  290. package/src/dom/{insert-after.js → insert-after.ts} +6 -4
  291. package/src/dom/{is-edge.js → is-edge.ts} +44 -48
  292. package/src/dom/{is-element.js → is-element.ts} +3 -1
  293. package/src/dom/{is-empty.js → is-empty.ts} +5 -7
  294. package/src/dom/{is-entirely-selected.js → is-entirely-selected.ts} +14 -11
  295. package/src/dom/{is-form-element.js → is-form-element.ts} +5 -3
  296. package/src/dom/{is-horizontal-edge.js → is-horizontal-edge.ts} +4 -1
  297. package/src/dom/{is-html-input-element.js → is-html-input-element.ts} +3 -1
  298. package/src/dom/{is-input-or-text-area.js → is-input-or-text-area.ts} +3 -1
  299. package/src/dom/{is-number-input.js → is-number-input.ts} +3 -3
  300. package/src/dom/{is-rtl.js → is-rtl.ts} +3 -3
  301. package/src/dom/{is-selection-forward.js → is-selection-forward.ts} +3 -3
  302. package/src/dom/{is-text-field.js → is-text-field.ts} +4 -4
  303. package/src/dom/{is-vertical-edge.js → is-vertical-edge.ts} +4 -1
  304. package/src/dom/{place-caret-at-edge.js → place-caret-at-edge.ts} +17 -9
  305. package/src/dom/{place-caret-at-horizontal-edge.js → place-caret-at-horizontal-edge.ts} +4 -1
  306. package/src/dom/{place-caret-at-vertical-edge.js → place-caret-at-vertical-edge.ts} +5 -1
  307. package/src/dom/{remove-invalid-html.js → remove-invalid-html.ts} +9 -4
  308. package/src/dom/{remove.js → remove.ts} +2 -3
  309. package/src/dom/{replace-tag.js → replace-tag.ts} +4 -4
  310. package/src/dom/{replace.js → replace.ts} +6 -4
  311. package/src/dom/{safe-html.js → safe-html.ts} +3 -3
  312. package/src/dom/{scroll-if-no-range.js → scroll-if-no-range.ts} +9 -5
  313. package/src/dom/{strip-html.js → strip-html.ts} +3 -3
  314. package/src/dom/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
  315. package/src/dom/types.ts +28 -0
  316. package/src/dom/{unwrap.js → unwrap.ts} +2 -4
  317. package/src/dom/{wrap.js → wrap.ts} +3 -3
  318. package/src/{focusable.js → focusable.ts} +34 -32
  319. package/src/index.ts +33 -0
  320. package/src/{phrasing-content.js → phrasing-content.ts} +15 -30
  321. package/src/{tabbable.js → tabbable.ts} +48 -39
  322. package/src/test/{dom.jsdom.test.js → dom.jsdom.test.ts} +30 -6
  323. package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
  324. package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
  325. package/src/types.ts +32 -0
  326. package/CHANGELOG.md +0 -317
  327. package/build/dom/index.cjs.map +0 -7
  328. package/build-module/dom/index.mjs.map +0 -7
  329. package/src/index.js +0 -12
  330. /package/src/dom/{index.js → index.ts} +0 -0
  331. /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
  332. /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
  333. /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
  334. /package/src/test/{utils.js → utils.ts} +0 -0
@@ -1,172 +1,176 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/dom/src/phrasing-content.js
21
- var phrasing_content_exports = {};
22
- __export(phrasing_content_exports, {
23
- getPhrasingContentSchema: () => getPhrasingContentSchema,
24
- isPhrasingContent: () => isPhrasingContent,
25
- isTextContent: () => isTextContent
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
26
5
  });
27
- module.exports = __toCommonJS(phrasing_content_exports);
28
- var textContentSchema = {
29
- strong: {},
30
- em: {},
31
- s: {},
32
- del: {},
33
- ins: {},
34
- a: { attributes: ["href", "target", "rel", "id"] },
35
- code: {},
36
- abbr: { attributes: ["title"] },
37
- sub: {},
38
- sup: {},
39
- br: {},
40
- small: {},
41
- // To do: fix blockquote.
42
- // cite: {},
43
- q: { attributes: ["cite"] },
44
- dfn: { attributes: ["title"] },
45
- data: { attributes: ["value"] },
46
- time: { attributes: ["datetime"] },
47
- var: {},
48
- samp: {},
49
- kbd: {},
50
- i: {},
51
- b: {},
52
- u: {},
53
- mark: {},
54
- ruby: {},
55
- rt: {},
56
- rp: {},
57
- bdi: { attributes: ["dir"] },
58
- bdo: { attributes: ["dir"] },
59
- wbr: {},
60
- "#text": {}
6
+ // packages/dom/src/phrasing-content.ts
7
+ /**
8
+ * All phrasing content elements.
9
+ *
10
+ * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
11
+ */
12
+ /**
13
+ * All text-level semantic elements.
14
+ *
15
+ * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html
16
+ */
17
+ const textContentSchema = {
18
+ strong: {},
19
+ em: {},
20
+ s: {},
21
+ del: {},
22
+ ins: {},
23
+ a: { attributes: [
24
+ "href",
25
+ "target",
26
+ "rel",
27
+ "id"
28
+ ] },
29
+ code: {},
30
+ abbr: { attributes: ["title"] },
31
+ sub: {},
32
+ sup: {},
33
+ br: {},
34
+ small: {},
35
+ q: { attributes: ["cite"] },
36
+ dfn: { attributes: ["title"] },
37
+ data: { attributes: ["value"] },
38
+ time: { attributes: ["datetime"] },
39
+ var: {},
40
+ samp: {},
41
+ kbd: {},
42
+ i: {},
43
+ b: {},
44
+ u: {},
45
+ mark: {},
46
+ ruby: {},
47
+ rt: {},
48
+ rp: {},
49
+ bdi: { attributes: ["dir"] },
50
+ bdo: { attributes: ["dir"] },
51
+ wbr: {},
52
+ "#text": {}
61
53
  };
62
- var embeddedContentSchema = {
63
- audio: {
64
- attributes: [
65
- "src",
66
- "preload",
67
- "autoplay",
68
- "mediagroup",
69
- "loop",
70
- "muted"
71
- ]
72
- },
73
- canvas: { attributes: ["width", "height"] },
74
- embed: { attributes: ["src", "type", "width", "height"] },
75
- img: {
76
- attributes: [
77
- "alt",
78
- "src",
79
- "srcset",
80
- "usemap",
81
- "ismap",
82
- "width",
83
- "height"
84
- ]
85
- },
86
- object: {
87
- attributes: [
88
- "data",
89
- "type",
90
- "name",
91
- "usemap",
92
- "form",
93
- "width",
94
- "height"
95
- ]
96
- },
97
- video: {
98
- attributes: [
99
- "src",
100
- "poster",
101
- "preload",
102
- "playsinline",
103
- "autoplay",
104
- "mediagroup",
105
- "loop",
106
- "muted",
107
- "controls",
108
- "width",
109
- "height"
110
- ]
111
- },
112
- math: {
113
- attributes: ["display", "xmlns"],
114
- children: "*"
115
- }
54
+ /**
55
+ * Embedded content elements.
56
+ *
57
+ * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0
58
+ */
59
+ const embeddedContentSchema = {
60
+ audio: { attributes: [
61
+ "src",
62
+ "preload",
63
+ "autoplay",
64
+ "mediagroup",
65
+ "loop",
66
+ "muted"
67
+ ] },
68
+ canvas: { attributes: ["width", "height"] },
69
+ embed: { attributes: [
70
+ "src",
71
+ "type",
72
+ "width",
73
+ "height"
74
+ ] },
75
+ img: { attributes: [
76
+ "alt",
77
+ "src",
78
+ "srcset",
79
+ "usemap",
80
+ "ismap",
81
+ "width",
82
+ "height"
83
+ ] },
84
+ object: { attributes: [
85
+ "data",
86
+ "type",
87
+ "name",
88
+ "usemap",
89
+ "form",
90
+ "width",
91
+ "height"
92
+ ] },
93
+ video: { attributes: [
94
+ "src",
95
+ "poster",
96
+ "preload",
97
+ "playsinline",
98
+ "autoplay",
99
+ "mediagroup",
100
+ "loop",
101
+ "muted",
102
+ "controls",
103
+ "width",
104
+ "height"
105
+ ] },
106
+ math: {
107
+ attributes: ["display", "xmlns"],
108
+ children: "*"
109
+ }
116
110
  };
117
- var excludedElements = ["#text", "br", "wbr"];
111
+ const excludedElements = [
112
+ "#text",
113
+ "br",
114
+ "wbr"
115
+ ];
118
116
  Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
119
- const { [tag]: removedTag, ...restSchema } = textContentSchema;
120
- textContentSchema[tag].children = {
121
- ...restSchema,
122
- img: embeddedContentSchema.img
123
- };
117
+ const { [tag]: removedTag, ...restSchema } = textContentSchema;
118
+ textContentSchema[tag].children = {
119
+ ...restSchema,
120
+ img: embeddedContentSchema.img
121
+ };
124
122
  });
125
- var phrasingContentSchema = {
126
- ...textContentSchema,
127
- ...embeddedContentSchema
123
+ /**
124
+ * Phrasing content elements.
125
+ *
126
+ * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
127
+ */
128
+ const phrasingContentSchema = {
129
+ ...textContentSchema,
130
+ ...embeddedContentSchema
128
131
  };
132
+ /**
133
+ * Get schema of possible paths for phrasing content.
134
+ *
135
+ * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
136
+ *
137
+ * @param [context] Set to "paste" to exclude invisible elements and
138
+ * sensitive data.
139
+ *
140
+ * @return Schema.
141
+ */
129
142
  function getPhrasingContentSchema(context) {
130
- if (context !== "paste") {
131
- return phrasingContentSchema;
132
- }
133
- const {
134
- u,
135
- // Used to mark misspelling. Shouldn't be pasted.
136
- abbr,
137
- // Invisible.
138
- data,
139
- // Invisible.
140
- time,
141
- // Invisible.
142
- wbr,
143
- // Invisible.
144
- bdi,
145
- // Invisible.
146
- bdo,
147
- // Invisible.
148
- ...remainingContentSchema
149
- } = {
150
- ...phrasingContentSchema,
151
- // We shouldn't paste potentially sensitive information which is not
152
- // visible to the user when pasted, so strip the attributes.
153
- ins: { children: phrasingContentSchema.ins.children },
154
- del: { children: phrasingContentSchema.del.children }
155
- };
156
- return remainingContentSchema;
143
+ if (context !== "paste") return phrasingContentSchema;
144
+ const { u, abbr, data, time, wbr, bdi, bdo, ...remainingContentSchema } = {
145
+ ...phrasingContentSchema,
146
+ ins: { children: phrasingContentSchema.ins.children },
147
+ del: { children: phrasingContentSchema.del.children }
148
+ };
149
+ return remainingContentSchema;
157
150
  }
151
+ /**
152
+ * Find out whether or not the given node is phrasing content.
153
+ *
154
+ * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
155
+ *
156
+ * @param node The node to test.
157
+ *
158
+ * @return True if phrasing content, false if not.
159
+ */
158
160
  function isPhrasingContent(node) {
159
- const tag = node.nodeName.toLowerCase();
160
- return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
161
+ const tag = node.nodeName.toLowerCase();
162
+ return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
161
163
  }
164
+ /**
165
+ * @param node
166
+ * @return Node is text content
167
+ */
162
168
  function isTextContent(node) {
163
- const tag = node.nodeName.toLowerCase();
164
- return textContentSchema.hasOwnProperty(tag) || tag === "span";
169
+ const tag = node.nodeName.toLowerCase();
170
+ return textContentSchema.hasOwnProperty(tag) || tag === "span";
165
171
  }
166
- // Annotate the CommonJS export names for ESM import in node:
167
- 0 && (module.exports = {
168
- getPhrasingContentSchema,
169
- isPhrasingContent,
170
- isTextContent
171
- });
172
- //# sourceMappingURL=phrasing-content.cjs.map
172
+ exports.getPhrasingContentSchema = getPhrasingContentSchema;
173
+ exports.isPhrasingContent = isPhrasingContent;
174
+ exports.isTextContent = isTextContent;
175
+
176
+ //# sourceMappingURL=phrasing-content.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/phrasing-content.js"],
4
- "sourcesContent": ["/**\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 * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema|'*'} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\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 *\n * @type {ContentSchema}\n */\nconst embeddedContentSchema = {\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 {string} [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return {Partial<ContentSchema>} Schema.\n */\nexport function getPhrasingContentSchema( context ) {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\t/**\n\t * @type {Partial<ContentSchema>}\n\t */\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} = {\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} node The node to test.\n *\n * @return {boolean} True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param {Node} node\n * @return {boolean} Node is text content\n */\nexport function isTextContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,IAAM,oBAAoB;AAAA,EACzB,QAAQ,CAAC;AAAA,EACT,IAAI,CAAC;AAAA,EACL,GAAG,CAAC;AAAA,EACJ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QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,yBAAyB,EAAE,eAAgB,GAAI,KAAK,QAAQ;AACpE;AAMO,SAAS,cAAe,MAAO;AACrC,QAAM,MAAM,KAAK,SAAS,YAAY;AACtC,SAAO,kBAAkB,eAAgB,GAAI,KAAK,QAAQ;AAC3D;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"phrasing-content.cjs","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,CAA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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,100 +1,145 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/dom/src/tabbable.js
21
- var tabbable_exports = {};
22
- __export(tabbable_exports, {
23
- find: () => find,
24
- findNext: () => findNext,
25
- findPrevious: () => findPrevious,
26
- isTabbableIndex: () => isTabbableIndex
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
27
5
  });
28
- module.exports = __toCommonJS(tabbable_exports);
29
- var import_focusable = require("./focusable.cjs");
6
+ let __focusable_ts = require("./focusable.cjs");
7
+ // packages/dom/src/tabbable.ts
8
+ /**
9
+ * Returns the tab index of the given element. In contrast with the tabIndex
10
+ * property, this normalizes the default (0) to avoid browser inconsistencies,
11
+ * operating under the assumption that this function is only ever called with a
12
+ * focusable node.
13
+ *
14
+ * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261
15
+ *
16
+ * @param element Element from which to retrieve.
17
+ *
18
+ * @return Tab index of element (default 0).
19
+ */
30
20
  function getTabIndex(element) {
31
- const tabIndex = element.getAttribute("tabindex");
32
- return tabIndex === null ? 0 : parseInt(tabIndex, 10);
21
+ const tabIndex = element.getAttribute("tabindex");
22
+ return tabIndex === null ? 0 : parseInt(tabIndex, 10);
33
23
  }
24
+ /**
25
+ * Returns true if the specified element is tabbable, or false otherwise.
26
+ *
27
+ * @param element Element to test.
28
+ *
29
+ * @return Whether element is tabbable.
30
+ */
34
31
  function isTabbableIndex(element) {
35
- return getTabIndex(element) !== -1;
32
+ return getTabIndex(element) !== -1;
36
33
  }
34
+ /**
35
+ * Returns a stateful reducer function which constructs a filtered array of
36
+ * tabbable elements, where at most one radio input is selected for a given
37
+ * name, giving priority to checked input, falling back to the first
38
+ * encountered.
39
+ *
40
+ * @return Radio group collapse reducer.
41
+ */
37
42
  function createStatefulCollapseRadioGroup() {
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) {
42
- return result.concat(element);
43
- }
44
- const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
45
- const isChosen = checked || !hasChosen;
46
- if (!isChosen) {
47
- return result;
48
- }
49
- if (hasChosen) {
50
- const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
51
- result = result.filter((e) => e !== hadChosenElement);
52
- }
53
- CHOSEN_RADIO_BY_NAME[name] = element;
54
- return result.concat(element);
55
- };
43
+ const CHOSEN_RADIO_BY_NAME = {};
44
+ return function collapseRadioGroup(result, element) {
45
+ const { nodeName, type, checked, name } = element;
46
+ if (nodeName !== "INPUT" || type !== "radio" || !name) return result.concat(element);
47
+ const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
48
+ if (!(checked || !hasChosen)) return result;
49
+ if (hasChosen) {
50
+ const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
51
+ result = result.filter((e) => e !== hadChosenElement);
52
+ }
53
+ CHOSEN_RADIO_BY_NAME[name] = element;
54
+ return result.concat(element);
55
+ };
56
56
  }
57
+ /**
58
+ * An array map callback, returning an object with the element value and its
59
+ * array index location as properties. This is used to emulate a proper stable
60
+ * sort where equal tabIndex should be left in order of their occurrence in the
61
+ * document.
62
+ *
63
+ * @param element Element.
64
+ * @param index Array index of element.
65
+ *
66
+ * @return Mapped object with element, index.
67
+ */
57
68
  function mapElementToObjectTabbable(element, index) {
58
- return { element, index };
69
+ return {
70
+ element,
71
+ index
72
+ };
59
73
  }
74
+ /**
75
+ * An array map callback, returning an element of the given mapped object's
76
+ * element value.
77
+ *
78
+ * @param object Mapped object with element.
79
+ *
80
+ * @return Mapped object element.
81
+ */
60
82
  function mapObjectTabbableToElement(object) {
61
- return object.element;
83
+ return object.element;
62
84
  }
85
+ /**
86
+ * A sort comparator function used in comparing two objects of mapped elements.
87
+ *
88
+ * @see mapElementToObjectTabbable
89
+ *
90
+ * @param a First object to compare.
91
+ * @param b Second object to compare.
92
+ *
93
+ * @return Comparator result.
94
+ */
63
95
  function compareObjectTabbables(a, b) {
64
- const aTabIndex = getTabIndex(a.element);
65
- const bTabIndex = getTabIndex(b.element);
66
- if (aTabIndex === bTabIndex) {
67
- return a.index - b.index;
68
- }
69
- return aTabIndex - bTabIndex;
96
+ const aTabIndex = getTabIndex(a.element);
97
+ const bTabIndex = getTabIndex(b.element);
98
+ if (aTabIndex === bTabIndex) return a.index - b.index;
99
+ return aTabIndex - bTabIndex;
70
100
  }
101
+ /**
102
+ * Given focusable elements, filters out tabbable element.
103
+ *
104
+ * @param focusables Focusable elements to filter.
105
+ *
106
+ * @return Tabbable elements.
107
+ */
71
108
  function filterTabbable(focusables) {
72
- return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
109
+ return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
73
110
  }
111
+ /**
112
+ * @param context
113
+ * @return Tabbable elements within the context.
114
+ */
74
115
  function find(context) {
75
- return filterTabbable((0, import_focusable.find)(context));
116
+ return filterTabbable((0, __focusable_ts.find)(context));
76
117
  }
118
+ /**
119
+ * Given a focusable element, find the preceding tabbable element.
120
+ *
121
+ * @param element The focusable element before which to look. Defaults
122
+ * to the active element.
123
+ *
124
+ * @return Preceding tabbable element.
125
+ */
77
126
  function findPrevious(element) {
78
- return filterTabbable((0, import_focusable.find)(element.ownerDocument.body)).reverse().find(
79
- (focusable) => (
80
- // eslint-disable-next-line no-bitwise
81
- element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING
82
- )
83
- );
127
+ return filterTabbable((0, __focusable_ts.find)(element.ownerDocument.body)).reverse().find((focusable) => element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING);
84
128
  }
129
+ /**
130
+ * Given a focusable element, find the next tabbable element.
131
+ *
132
+ * @param element The focusable element after which to look. Defaults
133
+ * to the active element.
134
+ *
135
+ * @return Next tabbable element.
136
+ */
85
137
  function findNext(element) {
86
- return filterTabbable((0, import_focusable.find)(element.ownerDocument.body)).find(
87
- (focusable) => (
88
- // eslint-disable-next-line no-bitwise
89
- element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING
90
- )
91
- );
138
+ return filterTabbable((0, __focusable_ts.find)(element.ownerDocument.body)).find((focusable) => element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING);
92
139
  }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- find,
96
- findNext,
97
- findPrevious,
98
- isTabbableIndex
99
- });
100
- //# sourceMappingURL=tabbable.cjs.map
140
+ exports.find = find;
141
+ exports.findNext = findNext;
142
+ exports.findPrevious = findPrevious;
143
+ exports.isTabbableIndex = isTabbableIndex;
144
+
145
+ //# sourceMappingURL=tabbable.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/tabbable.js"],
4
- "sourcesContent": ["import { 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 Element from which to retrieve.\n *\n * @return {number} Tab index of element (default 0).\n */\nfunction getTabIndex( element ) {\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 Element to test.\n *\n * @return {boolean} Whether element is tabbable.\n */\nexport function isTabbableIndex( element ) {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/** @typedef {HTMLElement & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */\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 {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup() {\n\t/** @type {Record<string, MaybeHTMLInputElement>} */\n\tconst CHOSEN_RADIO_BY_NAME = {};\n\n\treturn function collapseRadioGroup(\n\t\t/** @type {MaybeHTMLInputElement[]} */ result,\n\t\t/** @type {MaybeHTMLInputElement} */ element\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 {HTMLElement} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: HTMLElement, index: number }} Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable( element, index ) {\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 {{ element: HTMLElement }} object Mapped object with element.\n *\n * @return {HTMLElement} Mapped object element.\n */\nfunction mapObjectTabbableToElement( object ) {\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 {{ element: HTMLElement, index: number }} a First object to compare.\n * @param {{ element: HTMLElement, index: number }} b Second object to compare.\n *\n * @return {number} Comparator result.\n */\nfunction compareObjectTabbables( a, b ) {\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 {HTMLElement[]} focusables Focusable elements to filter.\n *\n * @return {HTMLElement[]} Tabbable elements.\n */\nfunction filterTabbable( focusables ) {\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 {Element} context\n * @return {HTMLElement[]} Tabbable elements within the context.\n */\nexport function find( context ) {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param {Element} element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Preceding tabbable element.\n */\nexport function findPrevious( element ) {\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} element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Next tabbable element.\n */\nexport function findNext( element ) {\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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,u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AAU;AAC/B,SAAO,mBAAgB,iBAAAA,MAAe,OAAQ,CAAE;AACjD;AAUO,SAAS,aAAc,SAAU;AACvC,SAAO,mBAAgB,iBAAAA,MAAe,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,SAAU;AACnC,SAAO,mBAAgB,iBAAAA,MAAe,QAAQ,cAAc,IAAK,CAAE,EAAE;AAAA,IACpE,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACD;",
6
- "names": ["findFocusable"]
7
- }
1
+ {"version":3,"file":"tabbable.cjs","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":";;;;;;;;;;;;;;;;;;;AAe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