@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
package/README.md CHANGED
@@ -26,6 +26,10 @@ _Returns_
26
26
 
27
27
  - `DOMRect | null`: The rectangle.
28
28
 
29
+ ### ContentSchema
30
+
31
+ Schema of the content allowed inside an element, keyed by tag name.
32
+
29
33
  ### documentHasSelection
30
34
 
31
35
  Check whether the current document has a selection. This includes focus in input fields, textareas, and general rich-text selection.
@@ -110,7 +114,7 @@ _Parameters_
110
114
 
111
115
  _Returns_
112
116
 
113
- - `Partial<ContentSchema>`: Schema.
117
+ - `ContentSchema`: Schema.
114
118
 
115
119
  ### getRectangleFromRange
116
120
 
@@ -122,7 +126,7 @@ _Parameters_
122
126
 
123
127
  _Returns_
124
128
 
125
- - `DOMRect?`: The rectangle.
129
+ - `DOMRect | null`: The rectangle.
126
130
 
127
131
  ### getScrollContainer
128
132
 
@@ -131,7 +135,7 @@ Given a DOM node, finds the closest scrollable container node or the node itself
131
135
  _Parameters_
132
136
 
133
137
  - _node_ `Element | null`: Node from which to start.
134
- - _direction_ `?string`: Direction of scrollable container to search for ('vertical', 'horizontal', 'all'). Defaults to 'vertical'.
138
+ - _direction_ `'vertical' | 'horizontal' | 'all'`: Direction of scrollable container to search for ('vertical', 'horizontal', 'all'). Defaults to 'vertical'.
135
139
 
136
140
  _Returns_
137
141
 
@@ -146,17 +150,13 @@ _Parameters_
146
150
  - _newNode_ `Node`: Node to be inserted.
147
151
  - _referenceNode_ `Node`: Node after which to perform the insertion.
148
152
 
149
- _Returns_
150
-
151
- - `void`:
152
-
153
153
  ### isEmpty
154
154
 
155
155
  Recursively checks if an element is empty. An element is not empty if it contains text or contains elements with attributes such as images.
156
156
 
157
157
  _Parameters_
158
158
 
159
- - _element_ `Element`: The element to check.
159
+ - _element_ `Node`: The element to check.
160
160
 
161
161
  _Returns_
162
162
 
@@ -180,7 +180,7 @@ Detects if element is a form element.
180
180
 
181
181
  _Parameters_
182
182
 
183
- - _element_ `Element`: The element to check.
183
+ - _element_ `Element | null | undefined`: The element to check.
184
184
 
185
185
  _Returns_
186
186
 
@@ -319,10 +319,6 @@ _Parameters_
319
319
 
320
320
  - _node_ `Node`: Node to be removed.
321
321
 
322
- _Returns_
323
-
324
- - `void`:
325
-
326
322
  ### removeInvalidHTML
327
323
 
328
324
  Given a schema, unwraps or removes nodes, attributes and classes on HTML.
@@ -330,8 +326,8 @@ Given a schema, unwraps or removes nodes, attributes and classes on HTML.
330
326
  _Parameters_
331
327
 
332
328
  - _HTML_ `string`: The HTML to clean up.
333
- - _schema_ `import('./clean-node-list').Schema`: Schema for the HTML.
334
- - _inline_ `boolean`: Whether to clean for inline mode.
329
+ - _schema_ `Schema`: Schema for the HTML.
330
+ - _inline_ `[boolean]`: Whether to clean for inline mode.
335
331
 
336
332
  _Returns_
337
333
 
@@ -346,10 +342,6 @@ _Parameters_
346
342
  - _processedNode_ `Element`: Node to be removed.
347
343
  - _newNode_ `Element`: Node to be inserted in its place.
348
344
 
349
- _Returns_
350
-
351
- - `void`:
352
-
353
345
  ### replaceTag
354
346
 
355
347
  Replaces the given node with a new node with the given tag name.
@@ -375,6 +367,18 @@ _Returns_
375
367
 
376
368
  - `string`: The sanitized HTML.
377
369
 
370
+ ### Schema
371
+
372
+ Schema that `cleanNodeList` and `removeInvalidHTML` clean HTML against, keyed by tag name.
373
+
374
+ ### SchemaItem
375
+
376
+ The rules for a single tag in a `Schema`.
377
+
378
+ ### SemanticElementDefinition
379
+
380
+ The attributes and children allowed for an element in a `ContentSchema`.
381
+
378
382
  ### unwrap
379
383
 
380
384
  Unwrap the given node. This means any child nodes are moved to the parent.
@@ -383,10 +387,6 @@ _Parameters_
383
387
 
384
388
  - _node_ `Node`: The node to unwrap.
385
389
 
386
- _Returns_
387
-
388
- - `void`:
389
-
390
390
  ### wrap
391
391
 
392
392
  Wraps the given node with a new node with the given tag name.
@@ -1,42 +1,24 @@
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/data-transfer.js
21
- var data_transfer_exports = {};
22
- __export(data_transfer_exports, {
23
- getFilesFromDataTransfer: () => getFilesFromDataTransfer
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(data_transfer_exports);
6
+ // packages/dom/src/data-transfer.ts
7
+ /**
8
+ * Gets all files from a DataTransfer object.
9
+ *
10
+ * @param dataTransfer DataTransfer object to inspect.
11
+ *
12
+ * @return An array containing all files.
13
+ */
26
14
  function getFilesFromDataTransfer(dataTransfer) {
27
- const files = Array.from(dataTransfer.files);
28
- Array.from(dataTransfer.items).forEach((item) => {
29
- const file = item.getAsFile();
30
- if (file && !files.find(
31
- ({ name, type, size }) => name === file.name && type === file.type && size === file.size
32
- )) {
33
- files.push(file);
34
- }
35
- });
36
- return files;
15
+ const files = Array.from(dataTransfer.files);
16
+ Array.from(dataTransfer.items).forEach((item) => {
17
+ const file = item.getAsFile();
18
+ if (file && !files.find(({ name, type, size }) => name === file.name && type === file.type && size === file.size)) files.push(file);
19
+ });
20
+ return files;
37
21
  }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- getFilesFromDataTransfer
41
- });
42
- //# sourceMappingURL=data-transfer.cjs.map
22
+ exports.getFilesFromDataTransfer = getFilesFromDataTransfer;
23
+
24
+ //# sourceMappingURL=data-transfer.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/data-transfer.js"],
4
- "sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,yBAA0B,cAAe;AACxD,QAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;AAE7C,QAAM,KAAM,aAAa,KAAM,EAAE,QAAS,CAAE,SAAU;AACrD,UAAM,OAAO,KAAK,UAAU;AAE5B,QACC,QACA,CAAE,MAAM;AAAA,MACP,CAAE,EAAE,MAAM,MAAM,KAAK,MACpB,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK;AAAA,IAChB,GACC;AACD,YAAM,KAAM,IAAK;AAAA,IAClB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"data-transfer.cjs","names":[],"sources":["../src/data-transfer.ts"],"sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param dataTransfer DataTransfer object to inspect.\n *\n * @return An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer: DataTransfer ): File[] {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAgB,yBAA0B,cAAqC;CAC9E,MAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;CAE7C,MAAM,KAAM,aAAa,KAAM,CAAC,CAAC,SAAW,SAAU;EACrD,MAAM,OAAO,KAAK,UAAU;EAE5B,IACC,QACA,CAAE,MAAM,MACL,EAAE,MAAM,MAAM,WACf,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK,IAChB,GAEA,MAAM,KAAM,IAAK;CAEnB,CAAE;CAEF,OAAO;AACR"}
@@ -1,42 +1,35 @@
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/dom/caret-range-from-point.js
21
- var caret_range_from_point_exports = {};
22
- __export(caret_range_from_point_exports, {
23
- default: () => caretRangeFromPoint
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(caret_range_from_point_exports);
6
+ // packages/dom/src/dom/caret-range-from-point.ts
7
+ /**
8
+ * Get a collapsed range for a given point.
9
+ *
10
+ * Prefers the standard `caretPositionFromPoint` API and falls back to the
11
+ * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.
12
+ *
13
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint
14
+ *
15
+ * @param doc The document of the range.
16
+ * @param x Horizontal position within the current viewport.
17
+ * @param y Vertical position within the current viewport.
18
+ *
19
+ * @return The best range for the given point.
20
+ */
26
21
  function caretRangeFromPoint(doc, x, y) {
27
- if (doc.caretPositionFromPoint) {
28
- const point = doc.caretPositionFromPoint(x, y);
29
- if (!point) {
30
- return null;
31
- }
32
- const range = doc.createRange();
33
- range.setStart(point.offsetNode, point.offset);
34
- range.collapse(true);
35
- return range;
36
- }
37
- if (doc.caretRangeFromPoint) {
38
- return doc.caretRangeFromPoint(x, y);
39
- }
40
- return null;
22
+ if (doc.caretPositionFromPoint) {
23
+ const point = doc.caretPositionFromPoint(x, y);
24
+ if (!point) return null;
25
+ const range = doc.createRange();
26
+ range.setStart(point.offsetNode, point.offset);
27
+ range.collapse(true);
28
+ return range;
29
+ }
30
+ if (doc.caretRangeFromPoint) return doc.caretRangeFromPoint(x, y);
31
+ return null;
41
32
  }
42
- //# sourceMappingURL=caret-range-from-point.cjs.map
33
+ exports.default = caretRangeFromPoint;
34
+
35
+ //# sourceMappingURL=caret-range-from-point.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/caret-range-from-point.js"],
4
- "sourcesContent": ["/**\n * Get a collapsed range for a given point.\n *\n * Prefers the standard `caretPositionFromPoint` API and falls back to the\n * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n *\n * @param {Document} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretPositionFromPoint ) {\n\t\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n\t\tif ( ! point ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst range = doc.createRange();\n\n\t\trange.setStart( point.offsetNode, point.offset );\n\t\trange.collapse( true );\n\n\t\treturn range;\n\t}\n\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\treturn null;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAce,SAAR,oBAAsC,KAAK,GAAG,GAAI;AACxD,MAAK,IAAI,wBAAyB;AACjC,UAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;AAI/C,QAAK,CAAE,OAAQ;AACd,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,IAAI,YAAY;AAE9B,UAAM,SAAU,MAAM,YAAY,MAAM,MAAO;AAC/C,UAAM,SAAU,IAAK;AAErB,WAAO;AAAA,EACR;AAEA,MAAK,IAAI,qBAAsB;AAC9B,WAAO,IAAI,oBAAqB,GAAG,CAAE;AAAA,EACtC;AAEA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"caret-range-from-point.cjs","names":[],"sources":["../../src/dom/caret-range-from-point.ts"],"sourcesContent":["/**\n * Get a collapsed range for a given point.\n *\n * Prefers the standard `caretPositionFromPoint` API and falls back to the\n * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n *\n * @param doc The document of the range.\n * @param x Horizontal position within the current viewport.\n * @param y Vertical position within the current viewport.\n *\n * @return The best range for the given point.\n */\nexport default function caretRangeFromPoint(\n\tdoc: Document,\n\tx: number,\n\ty: number\n): Range | null {\n\tif ( doc.caretPositionFromPoint ) {\n\t\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n\t\tif ( ! point ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst range = doc.createRange();\n\n\t\trange.setStart( point.offsetNode, point.offset );\n\t\trange.collapse( true );\n\n\t\treturn range;\n\t}\n\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,SAAwB,oBACvB,KACA,GACA,GACe;CACf,IAAK,IAAI,wBAAyB;EACjC,MAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;EAI/C,IAAK,CAAE,OACN,OAAO;EAGR,MAAM,QAAQ,IAAI,YAAY;EAE9B,MAAM,SAAU,MAAM,YAAY,MAAM,MAAO;EAC/C,MAAM,SAAU,IAAK;EAErB,OAAO;CACR;CAEA,IAAK,IAAI,qBACR,OAAO,IAAI,oBAAqB,GAAG,CAAE;CAGtC,OAAO;AACR"}
@@ -1,144 +1,99 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
13
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/dom/src/dom/clean-node-list.js
31
- var clean_node_list_exports = {};
32
- __export(clean_node_list_exports, {
33
- default: () => cleanNodeList
34
- });
35
- module.exports = __toCommonJS(clean_node_list_exports);
36
- var import_is_empty = __toESM(require("./is-empty.cjs"));
37
- var import_remove = __toESM(require("./remove.cjs"));
38
- var import_unwrap = __toESM(require("./unwrap.cjs"));
39
- var import_phrasing_content = require("../phrasing-content.cjs");
40
- var import_insert_after = __toESM(require("./insert-after.cjs"));
41
- var import_is_element = __toESM(require("./is-element.cjs"));
42
- var noop = () => {
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
43
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let __is_empty_ts = require("./is-empty.cjs");
28
+ __is_empty_ts = __toESM(__is_empty_ts);
29
+ let __remove_ts = require("./remove.cjs");
30
+ __remove_ts = __toESM(__remove_ts);
31
+ let __unwrap_ts = require("./unwrap.cjs");
32
+ __unwrap_ts = __toESM(__unwrap_ts);
33
+ let ___phrasing_content_ts = require("../phrasing-content.cjs");
34
+ let __insert_after_ts = require("./insert-after.cjs");
35
+ __insert_after_ts = __toESM(__insert_after_ts);
36
+ let __is_element_ts = require("./is-element.cjs");
37
+ __is_element_ts = __toESM(__is_element_ts);
38
+ // packages/dom/src/dom/clean-node-list.ts
39
+ const noop = () => {};
40
+ /**
41
+ * Given a schema, unwraps or removes nodes, attributes and classes on a node
42
+ * list.
43
+ *
44
+ * @param nodeList The nodeList to filter.
45
+ * @param doc The document of the nodeList.
46
+ * @param schema Schema for the HTML.
47
+ * @param [inline] Whether to clean for inline mode.
48
+ */
44
49
  function cleanNodeList(nodeList, doc, schema, inline) {
45
- Array.from(nodeList).forEach(
46
- (node) => {
47
- const tag = node.nodeName.toLowerCase();
48
- if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
49
- if ((0, import_is_element.default)(node)) {
50
- const {
51
- attributes = [],
52
- classes = [],
53
- children,
54
- require: require2 = [],
55
- allowEmpty
56
- } = schema[tag];
57
- if (children && !allowEmpty && (0, import_is_empty.default)(node)) {
58
- if ((0, import_phrasing_content.isPhrasingContent)(node) && node.hasChildNodes()) {
59
- (0, import_unwrap.default)(node);
60
- } else {
61
- (0, import_remove.default)(node);
62
- }
63
- return;
64
- }
65
- if (node.hasAttributes()) {
66
- Array.from(node.attributes).forEach(({ name }) => {
67
- if (name !== "class" && !attributes.includes(name)) {
68
- node.removeAttribute(name);
69
- }
70
- });
71
- if (node.classList && node.classList.length) {
72
- const mattchers = classes.map((item) => {
73
- if (item === "*") {
74
- return () => true;
75
- } else if (typeof item === "string") {
76
- return (className) => className === item;
77
- } else if (item instanceof RegExp) {
78
- return (className) => item.test(className);
79
- }
80
- return noop;
81
- });
82
- Array.from(node.classList).forEach((name) => {
83
- if (!mattchers.some(
84
- (isMatch) => isMatch(name)
85
- )) {
86
- node.classList.remove(name);
87
- }
88
- });
89
- if (!node.classList.length) {
90
- node.removeAttribute("class");
91
- }
92
- }
93
- }
94
- if (node.hasChildNodes()) {
95
- if (children === "*") {
96
- return;
97
- }
98
- if (children) {
99
- if (require2.length && !node.querySelector(require2.join(","))) {
100
- cleanNodeList(
101
- node.childNodes,
102
- doc,
103
- schema,
104
- inline
105
- );
106
- (0, import_unwrap.default)(node);
107
- } else if (node.parentNode && node.parentNode.nodeName === "BODY" && (0, import_phrasing_content.isPhrasingContent)(node)) {
108
- cleanNodeList(
109
- node.childNodes,
110
- doc,
111
- schema,
112
- inline
113
- );
114
- if (Array.from(node.childNodes).some(
115
- (child) => !(0, import_phrasing_content.isPhrasingContent)(child)
116
- )) {
117
- (0, import_unwrap.default)(node);
118
- }
119
- } else {
120
- cleanNodeList(
121
- node.childNodes,
122
- doc,
123
- children,
124
- inline
125
- );
126
- }
127
- } else {
128
- while (node.firstChild) {
129
- (0, import_remove.default)(node.firstChild);
130
- }
131
- }
132
- }
133
- }
134
- } else {
135
- cleanNodeList(node.childNodes, doc, schema, inline);
136
- if (inline && !(0, import_phrasing_content.isPhrasingContent)(node) && node.nextElementSibling) {
137
- (0, import_insert_after.default)(doc.createElement("br"), node);
138
- }
139
- (0, import_unwrap.default)(node);
140
- }
141
- }
142
- );
50
+ Array.from(nodeList).forEach((node) => {
51
+ const tag = node.nodeName.toLowerCase();
52
+ if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
53
+ if ((0, __is_element_ts.default)(node)) {
54
+ const { attributes = [], classes = [], children, require: require$1 = [], allowEmpty } = schema[tag];
55
+ if (children && !allowEmpty && (0, __is_empty_ts.default)(node)) {
56
+ if ((0, ___phrasing_content_ts.isPhrasingContent)(node) && node.hasChildNodes()) (0, __unwrap_ts.default)(node);
57
+ else (0, __remove_ts.default)(node);
58
+ return;
59
+ }
60
+ if (node.hasAttributes()) {
61
+ Array.from(node.attributes).forEach(({ name }) => {
62
+ if (name !== "class" && !attributes.includes(name)) node.removeAttribute(name);
63
+ });
64
+ if (node.classList && node.classList.length) {
65
+ const mattchers = classes.map((item) => {
66
+ if (item === "*") return () => true;
67
+ else if (typeof item === "string") return (className) => className === item;
68
+ else if (item instanceof RegExp) return (className) => item.test(className);
69
+ return noop;
70
+ });
71
+ Array.from(node.classList).forEach((name) => {
72
+ if (!mattchers.some((isMatch) => isMatch(name))) node.classList.remove(name);
73
+ });
74
+ if (!node.classList.length) node.removeAttribute("class");
75
+ }
76
+ }
77
+ if (node.hasChildNodes()) {
78
+ if (children === "*") return;
79
+ if (children) {
80
+ if (require$1.length && !node.querySelector(require$1.join(","))) {
81
+ cleanNodeList(node.childNodes, doc, schema, inline);
82
+ (0, __unwrap_ts.default)(node);
83
+ } else if (node.parentNode && node.parentNode.nodeName === "BODY" && (0, ___phrasing_content_ts.isPhrasingContent)(node)) {
84
+ cleanNodeList(node.childNodes, doc, schema, inline);
85
+ if (Array.from(node.childNodes).some((child) => !(0, ___phrasing_content_ts.isPhrasingContent)(child))) (0, __unwrap_ts.default)(node);
86
+ } else cleanNodeList(node.childNodes, doc, children, inline);
87
+ } else while (node.firstChild) (0, __remove_ts.default)(node.firstChild);
88
+ }
89
+ }
90
+ } else {
91
+ cleanNodeList(node.childNodes, doc, schema, inline);
92
+ if (inline && !(0, ___phrasing_content_ts.isPhrasingContent)(node) && node.nextElementSibling) (0, __insert_after_ts.default)(doc.createElement("br"), node);
93
+ (0, __unwrap_ts.default)(node);
94
+ }
95
+ });
143
96
  }
144
- //# sourceMappingURL=clean-node-list.cjs.map
97
+ exports.default = cleanNodeList;
98
+
99
+ //# sourceMappingURL=clean-node-list.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/clean-node-list.js"],
4
- "sourcesContent": ["import isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against. Use '*' to keep all classes.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node. For phrasing content nodes that contain\n\t\t\t\t\t// only whitespace, unwrap instead to preserve the text.\n\t\t\t\t\t// See https://github.com/WordPress/gutenberg/issues/50898\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisPhrasingContent( node ) &&\n\t\t\t\t\t\t\tnode.hasChildNodes()\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAo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CAAAC,SAAa,IAAI,cAAe,IAAK,GAAG,IAAK;AAAA,QAC9C;AAEA,0BAAAF,SAAQ,IAAK;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD;",
6
- "names": ["isElement", "require", "isEmpty", "unwrap", "remove", "insertAfter"]
7
- }
1
+ {"version":3,"file":"clean-node-list.cjs","names":["isElement","isEmpty","isPhrasingContent","require"],"sources":["../../src/dom/clean-node-list.ts"],"sourcesContent":["import isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\nimport type { Schema } from './types';\n\nconst noop = () => {};\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param nodeList The nodeList to filter.\n * @param doc The document of the nodeList.\n * @param schema Schema for the HTML.\n * @param [inline] Whether to clean for inline mode.\n */\nexport default function cleanNodeList(\n\tnodeList: NodeList,\n\tdoc: Document,\n\tschema: Schema,\n\tinline?: boolean\n) {\n\tArray.from( nodeList ).forEach(\n\t\t( node: Node & { nextElementSibling?: unknown } ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node. For phrasing content nodes that contain\n\t\t\t\t\t// only whitespace, unwrap instead to preserve the text.\n\t\t\t\t\t// See https://github.com/WordPress/gutenberg/issues/50898\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisPhrasingContent( node ) &&\n\t\t\t\t\t\t\tnode.hasChildNodes()\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\tclassName === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\titem.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],"mappings":";;;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