@bobfrankston/rmfmail 1.2.276 → 1.2.278

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 (198) hide show
  1. package/.commitmsg +26 -23
  2. package/bin/build-tinymce.js +27 -0
  3. package/client/app.bundle.js +108 -0
  4. package/client/app.bundle.js.map +4 -4
  5. package/client/app.js +65 -0
  6. package/client/app.js.map +1 -1
  7. package/client/app.ts +59 -0
  8. package/client/compose/compose.bundle.js +90 -2
  9. package/client/compose/compose.bundle.js.map +4 -4
  10. package/client/compose/compose.js +26 -1
  11. package/client/compose/compose.js.map +1 -1
  12. package/client/compose/compose.ts +22 -1
  13. package/client/compose/editor.js +12 -1
  14. package/client/compose/editor.js.map +1 -1
  15. package/client/compose/editor.ts +17 -2
  16. package/client/index.html +1 -0
  17. package/client/lib/rmf-tiny.js +3 -0
  18. package/client/lib/tinymce/CHANGELOG.md +47 -0
  19. package/client/lib/tinymce/composer.json +1 -1
  20. package/client/lib/tinymce/icons/default/icons.js +13 -0
  21. package/client/lib/tinymce/icons/default/icons.min.js +1 -1
  22. package/client/lib/tinymce/langs/ar-SA.js +440 -0
  23. package/client/lib/tinymce/langs/ar.js +441 -0
  24. package/client/lib/tinymce/langs/az.js +440 -0
  25. package/client/lib/tinymce/langs/be.js +440 -0
  26. package/client/lib/tinymce/langs/bg-BG.js +440 -0
  27. package/client/lib/tinymce/langs/bn-BD.js +440 -0
  28. package/client/lib/tinymce/langs/bs.js +440 -0
  29. package/client/lib/tinymce/langs/ca.js +440 -0
  30. package/client/lib/tinymce/langs/cs.js +440 -0
  31. package/client/lib/tinymce/langs/cy.js +440 -0
  32. package/client/lib/tinymce/langs/da.js +440 -0
  33. package/client/lib/tinymce/langs/de.js +440 -0
  34. package/client/lib/tinymce/langs/el.js +440 -0
  35. package/client/lib/tinymce/langs/eo.js +440 -0
  36. package/client/lib/tinymce/langs/es-MX.js +440 -0
  37. package/client/lib/tinymce/langs/es.js +440 -0
  38. package/client/lib/tinymce/langs/et.js +440 -0
  39. package/client/lib/tinymce/langs/eu.js +440 -0
  40. package/client/lib/tinymce/langs/fa.js +441 -0
  41. package/client/lib/tinymce/langs/fi.js +440 -0
  42. package/client/lib/tinymce/langs/fr-FR.js +440 -0
  43. package/client/lib/tinymce/langs/gl.js +440 -0
  44. package/client/lib/tinymce/langs/he-IL.js +440 -0
  45. package/client/lib/tinymce/langs/hr.js +440 -0
  46. package/client/lib/tinymce/langs/hu-HU.js +440 -0
  47. package/client/lib/tinymce/langs/hy.js +440 -0
  48. package/client/lib/tinymce/langs/id.js +440 -0
  49. package/client/lib/tinymce/langs/index.json +63 -0
  50. package/client/lib/tinymce/langs/is-IS.js +440 -0
  51. package/client/lib/tinymce/langs/it.js +440 -0
  52. package/client/lib/tinymce/langs/ja.js +440 -0
  53. package/client/lib/tinymce/langs/ka-GE.js +440 -0
  54. package/client/lib/tinymce/langs/kab.js +440 -0
  55. package/client/lib/tinymce/langs/kk.js +440 -0
  56. package/client/lib/tinymce/langs/ko-KR.js +440 -0
  57. package/client/lib/tinymce/langs/lt.js +440 -0
  58. package/client/lib/tinymce/langs/lv.js +440 -0
  59. package/client/lib/tinymce/langs/nb-NO.js +440 -0
  60. package/client/lib/tinymce/langs/ne.js +440 -0
  61. package/client/lib/tinymce/langs/nl-BE.js +440 -0
  62. package/client/lib/tinymce/langs/nl.js +440 -0
  63. package/client/lib/tinymce/langs/oc.js +440 -0
  64. package/client/lib/tinymce/langs/pl.js +440 -0
  65. package/client/lib/tinymce/langs/pt-BR.js +440 -0
  66. package/client/lib/tinymce/langs/pt-PT.js +440 -0
  67. package/client/lib/tinymce/langs/ro.js +440 -0
  68. package/client/lib/tinymce/langs/ru.js +440 -0
  69. package/client/lib/tinymce/langs/sk.js +440 -0
  70. package/client/lib/tinymce/langs/sl-SI.js +440 -0
  71. package/client/lib/tinymce/langs/sr.js +440 -0
  72. package/client/lib/tinymce/langs/sv-SE.js +440 -0
  73. package/client/lib/tinymce/langs/ta.js +440 -0
  74. package/client/lib/tinymce/langs/tg.js +440 -0
  75. package/client/lib/tinymce/langs/th-TH.js +440 -0
  76. package/client/lib/tinymce/langs/tr.js +440 -0
  77. package/client/lib/tinymce/langs/ug.js +440 -0
  78. package/client/lib/tinymce/langs/uk.js +440 -0
  79. package/client/lib/tinymce/langs/vi.js +440 -0
  80. package/client/lib/tinymce/langs/zh-CN.js +440 -0
  81. package/client/lib/tinymce/langs/zh-HK.js +440 -0
  82. package/client/lib/tinymce/langs/zh-MO.js +440 -0
  83. package/client/lib/tinymce/langs/zh-TW.js +440 -0
  84. package/client/lib/tinymce/models/dom/model.js +1 -1
  85. package/client/lib/tinymce/package.json +1 -1
  86. package/client/lib/tinymce/plugins/accordion/plugin.js +1 -1
  87. package/client/lib/tinymce/plugins/advlist/plugin.js +1 -1
  88. package/client/lib/tinymce/plugins/anchor/plugin.js +1 -1
  89. package/client/lib/tinymce/plugins/autolink/plugin.js +1 -1
  90. package/client/lib/tinymce/plugins/autolink/plugin.min.js +1 -1
  91. package/client/lib/tinymce/plugins/autoresize/plugin.js +1 -1
  92. package/client/lib/tinymce/plugins/autosave/plugin.js +1 -1
  93. package/client/lib/tinymce/plugins/autosave/plugin.min.js +1 -1
  94. package/client/lib/tinymce/plugins/charmap/plugin.js +1 -1
  95. package/client/lib/tinymce/plugins/code/plugin.js +1 -1
  96. package/client/lib/tinymce/plugins/codesample/plugin.js +2 -2
  97. package/client/lib/tinymce/plugins/codesample/plugin.min.js +2 -2
  98. package/client/lib/tinymce/plugins/directionality/plugin.js +1 -1
  99. package/client/lib/tinymce/plugins/emoticons/plugin.js +5 -11
  100. package/client/lib/tinymce/plugins/emoticons/plugin.min.js +1 -1
  101. package/client/lib/tinymce/plugins/fullscreen/plugin.js +1 -1
  102. package/client/lib/tinymce/plugins/help/plugin.js +1 -1
  103. package/client/lib/tinymce/plugins/help/plugin.min.js +1 -1
  104. package/client/lib/tinymce/plugins/image/plugin.js +15 -28
  105. package/client/lib/tinymce/plugins/image/plugin.min.js +1 -1
  106. package/client/lib/tinymce/plugins/importcss/plugin.js +1 -1
  107. package/client/lib/tinymce/plugins/insertdatetime/plugin.js +1 -1
  108. package/client/lib/tinymce/plugins/link/plugin.js +3 -2
  109. package/client/lib/tinymce/plugins/link/plugin.min.js +1 -1
  110. package/client/lib/tinymce/plugins/lists/plugin.js +1 -1
  111. package/client/lib/tinymce/plugins/media/plugin.js +1 -1
  112. package/client/lib/tinymce/plugins/nonbreaking/plugin.js +1 -1
  113. package/client/lib/tinymce/plugins/pagebreak/plugin.js +1 -1
  114. package/client/lib/tinymce/plugins/preview/plugin.js +12 -2
  115. package/client/lib/tinymce/plugins/preview/plugin.min.js +1 -1
  116. package/client/lib/tinymce/plugins/quickbars/plugin.js +1 -1
  117. package/client/lib/tinymce/plugins/save/plugin.js +1 -1
  118. package/client/lib/tinymce/plugins/searchreplace/plugin.js +1 -1
  119. package/client/lib/tinymce/plugins/table/plugin.js +5 -3
  120. package/client/lib/tinymce/plugins/table/plugin.min.js +1 -1
  121. package/client/lib/tinymce/plugins/visualblocks/plugin.js +1 -1
  122. package/client/lib/tinymce/plugins/visualchars/plugin.js +1 -1
  123. package/client/lib/tinymce/plugins/wordcount/plugin.js +1 -1
  124. package/client/lib/tinymce/skins/content/dark/content.css +3 -0
  125. package/client/lib/tinymce/skins/content/dark/content.js +1 -1
  126. package/client/lib/tinymce/skins/content/dark/content.min.css +1 -1
  127. package/client/lib/tinymce/skins/ui/oxide/content.css +53 -42
  128. package/client/lib/tinymce/skins/ui/oxide/content.inline.css +53 -42
  129. package/client/lib/tinymce/skins/ui/oxide/content.inline.js +1 -1
  130. package/client/lib/tinymce/skins/ui/oxide/content.inline.min.css +1 -1
  131. package/client/lib/tinymce/skins/ui/oxide/content.inline.min.ts +2 -2
  132. package/client/lib/tinymce/skins/ui/oxide/content.inline.ts +2 -2
  133. package/client/lib/tinymce/skins/ui/oxide/content.js +1 -1
  134. package/client/lib/tinymce/skins/ui/oxide/content.min.css +1 -1
  135. package/client/lib/tinymce/skins/ui/oxide/content.min.ts +2 -2
  136. package/client/lib/tinymce/skins/ui/oxide/content.ts +2 -2
  137. package/client/lib/tinymce/skins/ui/oxide/skin.css +94 -22
  138. package/client/lib/tinymce/skins/ui/oxide/skin.js +1 -1
  139. package/client/lib/tinymce/skins/ui/oxide/skin.min.css +1 -1
  140. package/client/lib/tinymce/skins/ui/oxide/skin.min.ts +8 -3
  141. package/client/lib/tinymce/skins/ui/oxide/skin.ts +8 -3
  142. package/client/lib/tinymce/skins/ui/oxide-dark/content.css +53 -42
  143. package/client/lib/tinymce/skins/ui/oxide-dark/content.inline.css +53 -42
  144. package/client/lib/tinymce/skins/ui/oxide-dark/content.inline.js +1 -1
  145. package/client/lib/tinymce/skins/ui/oxide-dark/content.inline.min.css +1 -1
  146. package/client/lib/tinymce/skins/ui/oxide-dark/content.inline.min.ts +2 -2
  147. package/client/lib/tinymce/skins/ui/oxide-dark/content.inline.ts +2 -2
  148. package/client/lib/tinymce/skins/ui/oxide-dark/content.js +1 -1
  149. package/client/lib/tinymce/skins/ui/oxide-dark/content.min.css +1 -1
  150. package/client/lib/tinymce/skins/ui/oxide-dark/content.min.ts +2 -2
  151. package/client/lib/tinymce/skins/ui/oxide-dark/content.ts +2 -2
  152. package/client/lib/tinymce/skins/ui/oxide-dark/skin.css +94 -22
  153. package/client/lib/tinymce/skins/ui/oxide-dark/skin.js +1 -1
  154. package/client/lib/tinymce/skins/ui/oxide-dark/skin.min.css +1 -1
  155. package/client/lib/tinymce/skins/ui/oxide-dark/skin.min.ts +8 -3
  156. package/client/lib/tinymce/skins/ui/oxide-dark/skin.ts +8 -3
  157. package/client/lib/tinymce/skins/ui/tinymce-5/content.css +53 -42
  158. package/client/lib/tinymce/skins/ui/tinymce-5/content.inline.css +53 -42
  159. package/client/lib/tinymce/skins/ui/tinymce-5/content.inline.js +1 -1
  160. package/client/lib/tinymce/skins/ui/tinymce-5/content.inline.min.css +1 -1
  161. package/client/lib/tinymce/skins/ui/tinymce-5/content.inline.min.ts +2 -2
  162. package/client/lib/tinymce/skins/ui/tinymce-5/content.inline.ts +2 -2
  163. package/client/lib/tinymce/skins/ui/tinymce-5/content.js +1 -1
  164. package/client/lib/tinymce/skins/ui/tinymce-5/content.min.css +1 -1
  165. package/client/lib/tinymce/skins/ui/tinymce-5/content.min.ts +2 -2
  166. package/client/lib/tinymce/skins/ui/tinymce-5/content.ts +2 -2
  167. package/client/lib/tinymce/skins/ui/tinymce-5/skin.css +94 -22
  168. package/client/lib/tinymce/skins/ui/tinymce-5/skin.js +1 -1
  169. package/client/lib/tinymce/skins/ui/tinymce-5/skin.min.css +1 -1
  170. package/client/lib/tinymce/skins/ui/tinymce-5/skin.min.ts +8 -3
  171. package/client/lib/tinymce/skins/ui/tinymce-5/skin.ts +8 -3
  172. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.css +53 -42
  173. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.inline.css +53 -42
  174. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.inline.js +1 -1
  175. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +1 -1
  176. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.inline.min.ts +2 -2
  177. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.inline.ts +2 -2
  178. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.js +1 -1
  179. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.min.css +1 -1
  180. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.min.ts +2 -2
  181. package/client/lib/tinymce/skins/ui/tinymce-5-dark/content.ts +2 -2
  182. package/client/lib/tinymce/skins/ui/tinymce-5-dark/skin.css +94 -22
  183. package/client/lib/tinymce/skins/ui/tinymce-5-dark/skin.js +1 -1
  184. package/client/lib/tinymce/skins/ui/tinymce-5-dark/skin.min.css +1 -1
  185. package/client/lib/tinymce/skins/ui/tinymce-5-dark/skin.min.ts +8 -3
  186. package/client/lib/tinymce/skins/ui/tinymce-5-dark/skin.ts +8 -3
  187. package/client/lib/tinymce/themes/silver/theme.js +1602 -579
  188. package/client/lib/tinymce/themes/silver/theme.min.js +3 -3
  189. package/client/lib/tinymce/tinymce.js +1410 -294
  190. package/client/lib/tinymce/tinymce.min.js +5 -5
  191. package/client/lib/tinymce-langs.js +96 -0
  192. package/client/lib/tinymce-langs.js.map +1 -0
  193. package/client/lib/tinymce-langs.ts +99 -0
  194. package/docs/editor.md +29 -3
  195. package/docs/preferences.md +2 -1
  196. package/npmchanges.md +63 -0
  197. package/package.json +11 -8
  198. /package/packages/mailx-imap/{node_modules.npmglobalize-stash-59216 → node_modules.npmglobalize-stash-65048}/.package-lock.json +0 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TinyMCE version 8.6.0 (2026-06-03)
2
+ * TinyMCE version 8.8.2 (2026-07-27)
3
3
  */
4
4
 
5
5
  (function () {
@@ -2650,7 +2650,7 @@
2650
2650
  const get$8 = (element) => read$2(element, 'class');
2651
2651
  const add$3 = (element, clazz) => add$4(element, 'class', clazz);
2652
2652
  const remove$4 = (element, clazz) => remove$5(element, 'class', clazz);
2653
- const toggle$5 = (element, clazz) => {
2653
+ const toggle$4 = (element, clazz) => {
2654
2654
  if (contains$2(get$8(element), clazz)) {
2655
2655
  return remove$4(element, clazz);
2656
2656
  }
@@ -2692,8 +2692,8 @@
2692
2692
  }
2693
2693
  cleanClass(element);
2694
2694
  };
2695
- const toggle$4 = (element, clazz) => {
2696
- const result = supports(element) ? element.dom.classList.toggle(clazz) : toggle$5(element, clazz);
2695
+ const toggle$3 = (element, clazz) => {
2696
+ const result = supports(element) ? element.dom.classList.toggle(clazz) : toggle$4(element, clazz);
2697
2697
  cleanClass(element);
2698
2698
  return result;
2699
2699
  };
@@ -2713,9 +2713,9 @@
2713
2713
  remove$3(element, x);
2714
2714
  });
2715
2715
  };
2716
- const toggle$3 = (element, classes) => {
2716
+ const toggle$2 = (element, classes) => {
2717
2717
  each$1(classes, (x) => {
2718
- toggle$4(element, x);
2718
+ toggle$3(element, x);
2719
2719
  });
2720
2720
  };
2721
2721
  const hasAll = (element, classes) => forall(classes, (clazz) => has(element, clazz));
@@ -2835,7 +2835,73 @@
2835
2835
  range: range$1
2836
2836
  };
2837
2837
 
2838
+ const beforeSpecial = (element, offset) => {
2839
+ // From memory, we don't want to use <br> directly on Firefox because it locks the keyboard input.
2840
+ // It turns out that <img> directly on IE locks the keyboard as well.
2841
+ // If the offset is 0, use before. If the offset is 1, use after.
2842
+ // TBIO-3889: Firefox Situ.on <input> results in a child of the <input>; Situ.before <input> results in platform inconsistencies
2843
+ const name = name$3(element);
2844
+ if ('input' === name) {
2845
+ return Situ.after(element);
2846
+ }
2847
+ else if (!contains$2(['br', 'img'], name)) {
2848
+ return Situ.on(element, offset);
2849
+ }
2850
+ else {
2851
+ return offset === 0 ? Situ.before(element) : Situ.after(element);
2852
+ }
2853
+ };
2854
+ const preprocessExact = (start, soffset, finish, foffset) => {
2855
+ const startSitu = beforeSpecial(start, soffset);
2856
+ const finishSitu = beforeSpecial(finish, foffset);
2857
+ return SimSelection.relative(startSitu, finishSitu);
2858
+ };
2859
+
2838
2860
  const getNativeSelection = (win) => Optional.from(win.getSelection());
2861
+ const doSetNativeRange = (win, rng) => {
2862
+ getNativeSelection(win).each((selection) => {
2863
+ selection.removeAllRanges();
2864
+ selection.addRange(rng);
2865
+ });
2866
+ };
2867
+ const doSetRange = (win, start, soffset, finish, foffset) => {
2868
+ const rng = exactToNative(win, start, soffset, finish, foffset);
2869
+ doSetNativeRange(win, rng);
2870
+ };
2871
+ const setLegacyRtlRange = (win, selection, start, soffset, finish, foffset) => {
2872
+ selection.collapse(start.dom, soffset);
2873
+ selection.extend(finish.dom, foffset);
2874
+ };
2875
+ const setRangeFromRelative = (win, relative) => diagnose(win, relative).match({
2876
+ ltr: (start, soffset, finish, foffset) => {
2877
+ doSetRange(win, start, soffset, finish, foffset);
2878
+ },
2879
+ rtl: (start, soffset, finish, foffset) => {
2880
+ getNativeSelection(win).each((selection) => {
2881
+ // If this selection is backwards, then we need to use extend.
2882
+ if (selection.setBaseAndExtent) {
2883
+ selection.setBaseAndExtent(start.dom, soffset, finish.dom, foffset);
2884
+ }
2885
+ else if (selection.extend) {
2886
+ // This try catch is for older browsers (Firefox 52) as they're sometimes unable to handle setting backwards selections using selection.extend and error out.
2887
+ try {
2888
+ setLegacyRtlRange(win, selection, start, soffset, finish, foffset);
2889
+ }
2890
+ catch {
2891
+ // If it does fail, try again with ltr.
2892
+ doSetRange(win, finish, foffset, start, soffset);
2893
+ }
2894
+ }
2895
+ else {
2896
+ doSetRange(win, finish, foffset, start, soffset);
2897
+ }
2898
+ });
2899
+ }
2900
+ });
2901
+ const setExact = (win, start, soffset, finish, foffset) => {
2902
+ const relative = preprocessExact(start, soffset, finish, foffset);
2903
+ setRangeFromRelative(win, relative);
2904
+ };
2839
2905
  // NOTE: We are still reading the range because it gives subtly different behaviour
2840
2906
  // than using the anchorNode and focusNode. I'm not sure if this behaviour is any
2841
2907
  // better or worse; it's just different.
@@ -3577,6 +3643,10 @@
3577
3643
  const transitionend = constant('transitionend');
3578
3644
  const transitionstart = constant('transitionstart');
3579
3645
  const selectstart = constant('selectstart');
3646
+ const pointerdown = constant('pointerdown');
3647
+ const pointermove = constant('pointermove');
3648
+ const pointerup = constant('pointerup');
3649
+ const lostpointercapture = constant('lostpointercapture');
3580
3650
 
3581
3651
  const prefixName = (name) => constant$1('alloy.' + name);
3582
3652
  const alloy = { tap: prefixName('tap') };
@@ -4776,7 +4846,7 @@
4776
4846
  // AlloyEventKeyAndHandler type argument needs to be any here to satisfy an array of handlers
4777
4847
  // where each item can be any subtype of EventFormat we can't use <T extends EventFormat> since
4778
4848
  // then each item would have to be the same type
4779
- const events$i = (name, eventHandlers) => {
4849
+ const events$j = (name, eventHandlers) => {
4780
4850
  const events = derive$2(eventHandlers);
4781
4851
  return create$3({
4782
4852
  fields: [
@@ -4789,7 +4859,7 @@
4789
4859
  });
4790
4860
  };
4791
4861
  const config = (name, eventHandlers) => {
4792
- const me = events$i(name, eventHandlers);
4862
+ const me = events$j(name, eventHandlers);
4793
4863
  return {
4794
4864
  key: name,
4795
4865
  value: {
@@ -4850,7 +4920,7 @@
4850
4920
  };
4851
4921
  return nu$2(mod);
4852
4922
  };
4853
- const events$h = (focusConfig) => derive$2([
4923
+ const events$i = (focusConfig) => derive$2([
4854
4924
  run$1(focus$3(), (component, simulatedEvent) => {
4855
4925
  focus$2(component, focusConfig);
4856
4926
  simulatedEvent.stop();
@@ -4868,7 +4938,7 @@
4868
4938
  var ActiveFocus = /*#__PURE__*/Object.freeze({
4869
4939
  __proto__: null,
4870
4940
  exhibit: exhibit$6,
4871
- events: events$h
4941
+ events: events$i
4872
4942
  });
4873
4943
 
4874
4944
  var FocusSchema = [
@@ -5026,7 +5096,7 @@
5026
5096
  const last = items.length > 0 ? Optional.some(items[items.length - 1]) : Optional.none();
5027
5097
  return last.bind((c) => component.getSystem().getByDom(c).toOptional());
5028
5098
  };
5029
- const getDelta$2 = (component, hConfig, hState, delta) => {
5099
+ const getDelta$3 = (component, hConfig, hState, delta) => {
5030
5100
  const items = descendants(component.element, '.' + hConfig.itemClass);
5031
5101
  const current = findIndex$1(items, (item) => has(item, hConfig.highlightClass));
5032
5102
  return current.bind((selected) => {
@@ -5034,8 +5104,8 @@
5034
5104
  return component.getSystem().getByDom(items[dest]).toOptional();
5035
5105
  });
5036
5106
  };
5037
- const getPrevious = (component, hConfig, hState) => getDelta$2(component, hConfig, hState, -1);
5038
- const getNext = (component, hConfig, hState) => getDelta$2(component, hConfig, hState, +1);
5107
+ const getPrevious = (component, hConfig, hState) => getDelta$3(component, hConfig, hState, -1);
5108
+ const getNext = (component, hConfig, hState) => getDelta$3(component, hConfig, hState, +1);
5039
5109
  const getCandidates = (component, hConfig, _hState) => {
5040
5110
  const items = descendants(component.element, '.' + hConfig.itemClass);
5041
5111
  return cat(map$2(items, (i) => component.getSystem().getByDom(i).toOptional()));
@@ -5278,7 +5348,7 @@
5278
5348
  // keyup also. This does make the name confusing, though.
5279
5349
  const stopEventForFirefox = (_component, _simulatedEvent) => Optional.some(true);
5280
5350
 
5281
- const schema$y = [
5351
+ const schema$z = [
5282
5352
  defaulted('execute', defaultExecute),
5283
5353
  defaulted('useSpace', false),
5284
5354
  defaulted('useEnter', true),
@@ -5300,7 +5370,7 @@
5300
5370
  const getKeyupRules$5 = (component, _simulatedEvent, executeConfig, _executeState) => executeConfig.useSpace && !inside(component.element) ?
5301
5371
  [rule(inSet(SPACE), stopEventForFirefox)] :
5302
5372
  [];
5303
- var ExecutionType = typical(schema$y, NoState.init, getKeydownRules$5, getKeyupRules$5, () => Optional.none());
5373
+ var ExecutionType = typical(schema$z, NoState.init, getKeydownRules$5, getKeyupRules$5, () => Optional.none());
5304
5374
 
5305
5375
  const flatgrid$1 = () => {
5306
5376
  const dimensions = value$2();
@@ -5401,7 +5471,7 @@
5401
5471
  const cycleUp$1 = (values, index, numRows, numCols) => cycleVertical$1(values, index, numRows, numCols, -1);
5402
5472
  const cycleDown$1 = (values, index, numRows, numCols) => cycleVertical$1(values, index, numRows, numCols, +1);
5403
5473
 
5404
- const schema$x = [
5474
+ const schema$y = [
5405
5475
  required$1('selector'),
5406
5476
  defaulted('execute', defaultExecute),
5407
5477
  onKeyboardHandler('onEscape'),
@@ -5438,7 +5508,7 @@
5438
5508
  rule(inSet(ESCAPE), doEscape$1),
5439
5509
  rule(inSet(SPACE), stopEventForFirefox)
5440
5510
  ]);
5441
- var FlatgridType = typical(schema$x, flatgrid$1, getKeydownRules$4, getKeyupRules$4, () => Optional.some(focusIn$4));
5511
+ var FlatgridType = typical(schema$y, flatgrid$1, getKeydownRules$4, getKeyupRules$4, () => Optional.some(focusIn$4));
5442
5512
 
5443
5513
  const f = (container, selector, current, delta, getNewIndex) => {
5444
5514
  const isDisabledButton = (candidate) => name$3(candidate) === 'button' && get$g(candidate, 'disabled') === 'disabled';
@@ -5462,7 +5532,7 @@
5462
5532
  return newIndex === prevIndex ? Optional.none() : onNewIndex(newIndex);
5463
5533
  });
5464
5534
 
5465
- const schema$w = [
5535
+ const schema$x = [
5466
5536
  required$1('selector'),
5467
5537
  defaulted('getInitial', Optional.none),
5468
5538
  defaulted('execute', defaultExecute),
@@ -5501,7 +5571,7 @@
5501
5571
  rule(inSet(SPACE), stopEventForFirefox),
5502
5572
  rule(inSet(ESCAPE), doEscape)
5503
5573
  ]);
5504
- var FlowType = typical(schema$w, NoState.init, getKeydownRules$3, getKeyupRules$3, () => Optional.some(focusIn$3));
5574
+ var FlowType = typical(schema$x, NoState.init, getKeydownRules$3, getKeyupRules$3, () => Optional.some(focusIn$3));
5505
5575
 
5506
5576
  const toCell = (matrix, rowIndex, columnIndex) => Optional.from(matrix[rowIndex]).bind((row) => Optional.from(row[columnIndex]).map((cell) => ({
5507
5577
  rowIndex,
@@ -5542,7 +5612,7 @@
5542
5612
  const moveUp$1 = (matrix, startRow, startCol) => moveVertical(matrix, startCol, startRow, -1);
5543
5613
  const moveDown$1 = (matrix, startRow, startCol) => moveVertical(matrix, startCol, startRow, +1);
5544
5614
 
5545
- const schema$v = [
5615
+ const schema$w = [
5546
5616
  requiredObjOf('selectors', [
5547
5617
  required$1('row'),
5548
5618
  required$1('cell')
@@ -5591,12 +5661,11 @@
5591
5661
  const getKeyupRules$2 = constant$1([
5592
5662
  rule(inSet(SPACE), stopEventForFirefox)
5593
5663
  ]);
5594
- var MatrixType = typical(schema$v, NoState.init, getKeydownRules$2, getKeyupRules$2, () => Optional.some(focusIn$2));
5664
+ var MatrixType = typical(schema$w, NoState.init, getKeydownRules$2, getKeyupRules$2, () => Optional.some(focusIn$2));
5595
5665
 
5596
- const schema$u = [
5666
+ const schema$v = [
5597
5667
  required$1('selector'),
5598
- defaulted('execute', defaultExecute),
5599
- defaulted('moveOnTab', false)
5668
+ defaulted('execute', defaultExecute)
5600
5669
  ];
5601
5670
  const execute = (component, simulatedEvent, menuConfig) => menuConfig.focusManager.get(component).bind((focused) => menuConfig.execute(component, simulatedEvent, focused));
5602
5671
  const focusIn$1 = (component, menuConfig, _state) => {
@@ -5607,22 +5676,18 @@
5607
5676
  };
5608
5677
  const moveUp = (element, focused, info) => horizontal(element, info.selector, focused, -1);
5609
5678
  const moveDown = (element, focused, info) => horizontal(element, info.selector, focused, +1);
5610
- const fireShiftTab = (component, simulatedEvent, menuConfig, menuState) => menuConfig.moveOnTab ? move$1(moveUp)(component, simulatedEvent, menuConfig, menuState) : Optional.none();
5611
- const fireTab = (component, simulatedEvent, menuConfig, menuState) => menuConfig.moveOnTab ? move$1(moveDown)(component, simulatedEvent, menuConfig, menuState) : Optional.none();
5612
5679
  const getKeydownRules$1 = constant$1([
5613
5680
  rule(inSet(UP), move$1(moveUp)),
5614
5681
  rule(inSet(DOWN), move$1(moveDown)),
5615
- rule(and([isShift$1, inSet(TAB)]), fireShiftTab),
5616
- rule(and([isNotShift, inSet(TAB)]), fireTab),
5617
5682
  rule(inSet(ENTER), execute),
5618
5683
  rule(inSet(SPACE), execute)
5619
5684
  ]);
5620
5685
  const getKeyupRules$1 = constant$1([
5621
5686
  rule(inSet(SPACE), stopEventForFirefox)
5622
5687
  ]);
5623
- var MenuType = typical(schema$u, NoState.init, getKeydownRules$1, getKeyupRules$1, () => Optional.some(focusIn$1));
5688
+ var MenuType = typical(schema$v, NoState.init, getKeydownRules$1, getKeyupRules$1, () => Optional.some(focusIn$1));
5624
5689
 
5625
- const schema$t = [
5690
+ const schema$u = [
5626
5691
  onKeyboardHandler('onSpace'),
5627
5692
  onKeyboardHandler('onEnter'),
5628
5693
  onKeyboardHandler('onShiftEnter'),
@@ -5652,7 +5717,7 @@
5652
5717
  ...(specialInfo.stopSpaceKeyup ? [rule(inSet(SPACE), stopEventForFirefox)] : []),
5653
5718
  rule(inSet(ESCAPE), specialInfo.onEscape)
5654
5719
  ];
5655
- var SpecialType = typical(schema$t, NoState.init, getKeydownRules, getKeyupRules, (specialInfo) => specialInfo.focusIn);
5720
+ var SpecialType = typical(schema$u, NoState.init, getKeydownRules, getKeyupRules, (specialInfo) => specialInfo.focusIn);
5656
5721
 
5657
5722
  const acyclic = AcyclicType.schema();
5658
5723
  const cyclic = CyclicType.schema();
@@ -6036,7 +6101,7 @@
6036
6101
  // as the element receiving it, and it wasn't its own target, then stop the focus call
6037
6102
  // and log a warning.
6038
6103
  const isRecursive = (component, originator, target) => eq(originator, component.element) && !eq(originator, target);
6039
- const events$g = derive$2([
6104
+ const events$h = derive$2([
6040
6105
  can(focus$3(), (component, simulatedEvent) => {
6041
6106
  // originator may not always be there. Will need to check this.
6042
6107
  const event = simulatedEvent.event;
@@ -6058,7 +6123,7 @@
6058
6123
 
6059
6124
  var DefaultEvents = /*#__PURE__*/Object.freeze({
6060
6125
  __proto__: null,
6061
- events: events$g
6126
+ events: events$h
6062
6127
  });
6063
6128
 
6064
6129
  const prefix$1 = constant$1('alloy-id-');
@@ -6145,7 +6210,7 @@
6145
6210
  };
6146
6211
  };
6147
6212
  const getBehaviours$3 = (bData) => bData.list;
6148
- const getData$2 = (bData) => bData.data;
6213
+ const getData$3 = (bData) => bData.data;
6149
6214
 
6150
6215
  const byInnerKey = (data, tuple) => {
6151
6216
  const r = {};
@@ -6290,7 +6355,7 @@
6290
6355
  };
6291
6356
 
6292
6357
  const baseBehaviour = 'alloy.base.behaviour';
6293
- const schema$s = objOf([
6358
+ const schema$t = objOf([
6294
6359
  field$1('dom', 'dom', required$2(), objOf([
6295
6360
  // Note, no children.
6296
6361
  required$1('tag'),
@@ -6319,7 +6384,7 @@
6319
6384
  }), anyValue()),
6320
6385
  option$3('domModification')
6321
6386
  ]);
6322
- const toInfo = (spec) => asRaw('custom.definition', schema$s, spec);
6387
+ const toInfo = (spec) => asRaw('custom.definition', schema$t, spec);
6323
6388
  const toDefinition = (detail) =>
6324
6389
  // EFFICIENCY: Consider not merging here.
6325
6390
  ({
@@ -6464,7 +6529,7 @@
6464
6529
  const info = getOrDie(toInfo(spec));
6465
6530
  const bBlob = generate$3(spec);
6466
6531
  const bList = getBehaviours$3(bBlob);
6467
- const bData = getData$2(bBlob);
6532
+ const bData = getData$3(bBlob);
6468
6533
  const modDefinition = getDomDefinition(info, bList, bData);
6469
6534
  const item = renderToDom(modDefinition, obsoleted);
6470
6535
  const events = getEvents(info, bList, bData);
@@ -6828,7 +6893,7 @@
6828
6893
  // if we use "aria-disabled" or just "disabled"
6829
6894
  classes: disableConfig.disabled() ? disableConfig.disableClass.toArray() : []
6830
6895
  });
6831
- const events$f = (disableConfig, disableState) => derive$2([
6896
+ const events$g = (disableConfig, disableState) => derive$2([
6832
6897
  abort(execute$5(), (component, _simulatedEvent) => isDisabled$1(component, disableConfig)),
6833
6898
  loadEvent(disableConfig, disableState, onLoad$5)
6834
6899
  ]);
@@ -6836,7 +6901,7 @@
6836
6901
  var ActiveDisable = /*#__PURE__*/Object.freeze({
6837
6902
  __proto__: null,
6838
6903
  exhibit: exhibit$5,
6839
- events: events$f
6904
+ events: events$g
6840
6905
  });
6841
6906
 
6842
6907
  var DisableSchema = [
@@ -7227,7 +7292,7 @@
7227
7292
  forceDockToBottom: forceDockToBottom
7228
7293
  });
7229
7294
 
7230
- const events$e = (dockInfo, dockState) => derive$2([
7295
+ const events$f = (dockInfo, dockState) => derive$2([
7231
7296
  runOnSource(transitionend(), (component, simulatedEvent) => {
7232
7297
  dockInfo.contextual.each((contextInfo) => {
7233
7298
  if (has(component.element, contextInfo.transitionClass)) {
@@ -7251,7 +7316,7 @@
7251
7316
 
7252
7317
  var ActiveDocking = /*#__PURE__*/Object.freeze({
7253
7318
  __proto__: null,
7254
- events: events$e
7319
+ events: events$f
7255
7320
  });
7256
7321
 
7257
7322
  var DockingSchema = [
@@ -7723,11 +7788,11 @@
7723
7788
  defaulted('mustSnap', false)
7724
7789
  ]);
7725
7790
 
7726
- const schema$r = [
7791
+ const schema$s = [
7727
7792
  // Is this used?
7728
7793
  defaulted('useFixed', never),
7729
- required$1('blockerClass'),
7730
7794
  defaulted('getTarget', identity),
7795
+ defaulted('onDragStart', noop),
7731
7796
  defaulted('onDrag', noop),
7732
7797
  defaulted('repositionTarget', true),
7733
7798
  defaulted('onDrop', noop),
@@ -7817,7 +7882,12 @@
7817
7882
  };
7818
7883
  const handlers = (events) => (dragConfig, dragState) => {
7819
7884
  const updateStartState = (comp) => {
7885
+ const isBeingDragged = dragState.getStartData().isSome();
7820
7886
  dragState.setStartData(calcStartData(dragConfig, comp));
7887
+ if (!isBeingDragged) {
7888
+ const target = dragConfig.getTarget(comp.element);
7889
+ dragConfig.onDragStart(comp, target);
7890
+ }
7821
7891
  };
7822
7892
  return derive$2([
7823
7893
  run$1(windowScroll(), (comp) => {
@@ -7845,18 +7915,18 @@
7845
7915
  run$1(mouseout(), dragApi.delayDrop)
7846
7916
  ]);
7847
7917
 
7848
- const getData$1 = (event) => Optional.from(SugarPosition(event.x, event.y));
7918
+ const getData$2 = (event) => Optional.from(SugarPosition(event.x, event.y));
7849
7919
  // When dragging with the mouse, the delta is simply the difference
7850
7920
  // between the two position (previous/old and next/nu)
7851
- const getDelta$1 = (old, nu) => SugarPosition(nu.left - old.left, nu.top - old.top);
7921
+ const getDelta$2 = (old, nu) => SugarPosition(nu.left - old.left, nu.top - old.top);
7852
7922
 
7853
7923
  var MouseData = /*#__PURE__*/Object.freeze({
7854
7924
  __proto__: null,
7855
- getData: getData$1,
7856
- getDelta: getDelta$1
7925
+ getData: getData$2,
7926
+ getDelta: getDelta$2
7857
7927
  });
7858
7928
 
7859
- const events$d = (dragConfig, dragState, updateStartState) => [
7929
+ const events$e = (dragConfig, dragState, updateStartState) => [
7860
7930
  run$1(mousedown(), (component, simulatedEvent) => {
7861
7931
  const raw = simulatedEvent.event.raw;
7862
7932
  if (raw.button !== 0) {
@@ -7885,10 +7955,11 @@
7885
7955
  start();
7886
7956
  })
7887
7957
  ];
7888
- const schema$q = [
7889
- ...schema$r,
7958
+ const schema$r = [
7959
+ ...schema$s,
7960
+ required$1('blockerClass'),
7890
7961
  output$1('dragger', {
7891
- handlers: handlers(events$d)
7962
+ handlers: handlers(events$e)
7892
7963
  })
7893
7964
  ];
7894
7965
 
@@ -7911,22 +7982,22 @@
7911
7982
  const touch = touches[0];
7912
7983
  return Optional.some(SugarPosition(touch.clientX, touch.clientY));
7913
7984
  };
7914
- const getData = (event) => {
7985
+ const getData$1 = (event) => {
7915
7986
  const raw = event.raw;
7916
7987
  const touches = raw.touches;
7917
7988
  return touches.length === 1 ? getDataFrom(touches) : Optional.none();
7918
7989
  };
7919
7990
  // When dragging the touch, the delta is simply the difference
7920
7991
  // between the two touch positions (previous/old and next/nu)
7921
- const getDelta = (old, nu) => SugarPosition(nu.left - old.left, nu.top - old.top);
7992
+ const getDelta$1 = (old, nu) => SugarPosition(nu.left - old.left, nu.top - old.top);
7922
7993
 
7923
7994
  var TouchData = /*#__PURE__*/Object.freeze({
7924
7995
  __proto__: null,
7925
- getData: getData,
7926
- getDelta: getDelta
7996
+ getData: getData$1,
7997
+ getDelta: getDelta$1
7927
7998
  });
7928
7999
 
7929
- const events$c = (dragConfig, dragState, updateStartState) => {
8000
+ const events$d = (dragConfig, dragState, updateStartState) => {
7930
8001
  const blockerSingleton = value$2();
7931
8002
  const stopBlocking = (component) => {
7932
8003
  stop(component, blockerSingleton.get(), dragConfig, dragState);
@@ -7967,33 +8038,95 @@
7967
8038
  run$1(touchcancel(), stopBlocking)
7968
8039
  ];
7969
8040
  };
8041
+ const schema$q = [
8042
+ ...schema$s,
8043
+ required$1('blockerClass'),
8044
+ output$1('dragger', {
8045
+ handlers: handlers(events$d)
8046
+ })
8047
+ ];
8048
+
8049
+ const events$c = (dragConfig, dragState, updateStartState) => [
8050
+ ...events$e(dragConfig, dragState, updateStartState),
8051
+ ...events$d(dragConfig, dragState, updateStartState)
8052
+ ];
7970
8053
  const schema$p = [
7971
- ...schema$r,
8054
+ ...schema$s,
8055
+ required$1('blockerClass'),
7972
8056
  output$1('dragger', {
7973
8057
  handlers: handlers(events$c)
7974
8058
  })
7975
8059
  ];
7976
8060
 
7977
- const events$b = (dragConfig, dragState, updateStartState) => [
7978
- ...events$d(dragConfig, dragState, updateStartState),
7979
- ...events$c(dragConfig, dragState, updateStartState)
7980
- ];
8061
+ const getData = (event) => Optional.from(SugarPosition(event.x, event.y));
8062
+ const getDelta = (old, nu) => SugarPosition(nu.left - old.left, nu.top - old.top);
8063
+
8064
+ var PointerData = /*#__PURE__*/Object.freeze({
8065
+ __proto__: null,
8066
+ getData: getData,
8067
+ getDelta: getDelta
8068
+ });
8069
+
8070
+ const isLeftClick = (e) => e.button === 0;
8071
+ const events$b = (dragConfig, dragState, updateStartState) => {
8072
+ return [
8073
+ run$1(pointerdown(), (component, simulatedEvent) => {
8074
+ const raw = simulatedEvent.event.raw;
8075
+ if (!isLeftClick(raw)) {
8076
+ return;
8077
+ }
8078
+ if (dragState.getStartData().isNone()) {
8079
+ simulatedEvent.stop();
8080
+ component.element.dom.setPointerCapture(raw.pointerId);
8081
+ dragState.setActivePointerId(raw.pointerId);
8082
+ updateStartState(component);
8083
+ }
8084
+ }),
8085
+ run$1(pointermove(), (component, simulatedEvent) => {
8086
+ const pointerId = simulatedEvent.event.raw.pointerId;
8087
+ lift2(dragState.getStartData(), dragState.getActivePointerId(), (_startData, activePointerId) => {
8088
+ if (pointerId === activePointerId) {
8089
+ move(component, dragConfig, dragState, PointerData, simulatedEvent.event);
8090
+ }
8091
+ });
8092
+ }),
8093
+ run$1(pointerup(), (component, simulatedEvent) => {
8094
+ const pointerId = simulatedEvent.event.raw.pointerId;
8095
+ lift2(dragState.getStartData(), dragState.getActivePointerId(), (_startData, activePointerId) => {
8096
+ if (pointerId === activePointerId) {
8097
+ component.element.dom.releasePointerCapture(pointerId);
8098
+ stop(component, Optional.none(), dragConfig, dragState);
8099
+ }
8100
+ });
8101
+ }),
8102
+ // Safety net — if capture is lost unexpectedly.
8103
+ // It sometimes happens that pointer capture is lost without pointerup event being emitted.
8104
+ // I could observe that using touchpad in chrome
8105
+ run$1(lostpointercapture(), (component) => {
8106
+ dragState.getStartData().each(() => {
8107
+ stop(component, Optional.none(), dragConfig, dragState);
8108
+ });
8109
+ })
8110
+ ];
8111
+ };
7981
8112
  const schema$o = [
7982
- ...schema$r,
8113
+ ...schema$s,
7983
8114
  output$1('dragger', {
7984
8115
  handlers: handlers(events$b)
7985
8116
  })
7986
8117
  ];
7987
8118
 
7988
- const mouse = schema$q;
7989
- const touch = schema$p;
7990
- const mouseOrTouch = schema$o;
8119
+ const mouse = schema$r;
8120
+ const touch = schema$q;
8121
+ const mouseOrTouch = schema$p;
8122
+ const pointer = schema$o;
7991
8123
 
7992
8124
  var DraggingBranches = /*#__PURE__*/Object.freeze({
7993
8125
  __proto__: null,
7994
8126
  mouse: mouse,
7995
8127
  touch: touch,
7996
- mouseOrTouch: mouseOrTouch
8128
+ mouseOrTouch: mouseOrTouch,
8129
+ pointer: pointer
7997
8130
  });
7998
8131
 
7999
8132
  // NOTE: mode refers to the way that information is retrieved from
@@ -8002,34 +8135,45 @@
8002
8135
  // Dragging operates on the difference between the previous user
8003
8136
  // interaction and the next user interaction. Therefore, we store
8004
8137
  // the previous interaction so that we can compare it.
8005
- let previous = Optional.none();
8138
+ const previous = value$2();
8006
8139
  // Dragging requires calculating the bounds, so we store that data initially
8007
8140
  // to reduce the amount of computation each mouse movement
8008
- let startData = Optional.none();
8141
+ const startData = value$2();
8142
+ // In a multitouch environment, `pointerId` is used to distinguish pointers
8143
+ // (e.g. different fingers on a touchscreen).
8144
+ // This property is only used by pointer-event branches.
8145
+ const activePointerId = value$2();
8009
8146
  const reset = () => {
8010
- previous = Optional.none();
8011
- startData = Optional.none();
8147
+ previous.clear();
8148
+ startData.clear();
8149
+ activePointerId.clear();
8012
8150
  };
8013
8151
  // Return position delta between previous position and nu position,
8014
8152
  // or None if this is the first. Set the previous position to nu.
8015
8153
  const calculateDelta = (mode, nu) => {
8016
- const result = previous.map((old) => mode.getDelta(old, nu));
8017
- previous = Optional.some(nu);
8154
+ const result = previous.get().map((old) => mode.getDelta(old, nu));
8155
+ previous.set(nu);
8018
8156
  return result;
8019
8157
  };
8020
8158
  // NOTE: This dragEvent is the DOM touch event or mouse event
8021
8159
  const update = (mode, dragEvent) => mode.getData(dragEvent).bind((nuData) => calculateDelta(mode, nuData));
8022
8160
  const setStartData = (data) => {
8023
- startData = Optional.some(data);
8161
+ startData.set(data);
8162
+ };
8163
+ const getStartData = () => startData.get();
8164
+ const setActivePointerId = (id) => {
8165
+ activePointerId.set(id);
8024
8166
  };
8025
- const getStartData = () => startData;
8167
+ const getActivePointerId = () => activePointerId.get();
8026
8168
  const readState = constant$1({});
8027
8169
  return nu$4({
8028
8170
  readState,
8029
8171
  reset,
8030
8172
  update,
8031
8173
  getStartData,
8032
- setStartData
8174
+ setStartData,
8175
+ setActivePointerId,
8176
+ getActivePointerId
8033
8177
  });
8034
8178
  };
8035
8179
 
@@ -9057,10 +9201,12 @@
9057
9201
  if (isSimRange(sel)) {
9058
9202
  const optRect = getBounds$2(win, SimSelection.exactFromRange(sel)).orThunk(() => {
9059
9203
  const zeroWidth$1 = SugarElement.fromText(zeroWidth);
9204
+ const beforeMutation = getExact(win);
9060
9205
  before$1(sel.start, zeroWidth$1);
9061
9206
  // Certain things like <p><br/></p> with (p, 0) or <br>) as collapsed selection do not return a client rectangle
9062
9207
  const rect = getFirstRect(win, SimSelection.exact(zeroWidth$1, 0, zeroWidth$1, 1));
9063
9208
  remove$7(zeroWidth$1);
9209
+ beforeMutation.each((range) => setExact(win, range.start, range.soffset, range.finish, range.foffset));
9064
9210
  return rect;
9065
9211
  });
9066
9212
  return optRect.bind((rawRect) => {
@@ -9864,7 +10010,7 @@
9864
10010
  toggleConfig.onToggled(component, state);
9865
10011
  }
9866
10012
  };
9867
- const toggle$2 = (component, toggleConfig, toggleState) => {
10013
+ const toggle$1 = (component, toggleConfig, toggleState) => {
9868
10014
  set(component, toggleConfig, toggleState, !toggleState.get());
9869
10015
  };
9870
10016
  const on = (component, toggleConfig, toggleState) => {
@@ -9884,7 +10030,7 @@
9884
10030
  var ToggleApis = /*#__PURE__*/Object.freeze({
9885
10031
  __proto__: null,
9886
10032
  onLoad: onLoad,
9887
- toggle: toggle$2,
10033
+ toggle: toggle$1,
9888
10034
  isOn: isOn,
9889
10035
  on: on,
9890
10036
  off: off,
@@ -9893,7 +10039,7 @@
9893
10039
 
9894
10040
  const exhibit$1 = () => nu$2({});
9895
10041
  const events$3 = (toggleConfig, toggleState) => {
9896
- const execute = executeEvent(toggleConfig, toggleState, toggle$2);
10042
+ const execute = executeEvent(toggleConfig, toggleState, toggle$1);
9897
10043
  const load = loadEvent(toggleConfig, toggleState, onLoad);
9898
10044
  return derive$2(flatten([
9899
10045
  toggleConfig.toggleOnExecute ? [execute] : [],
@@ -10363,7 +10509,11 @@
10363
10509
  'mouseover',
10364
10510
  'mousemove',
10365
10511
  'mouseout',
10366
- 'click'
10512
+ 'click',
10513
+ 'pointerdown',
10514
+ 'pointermove',
10515
+ 'pointerup',
10516
+ 'lostpointercapture'
10367
10517
  ];
10368
10518
  const tapEvent = monitor(settings);
10369
10519
  // These events are just passed through ... no additional processing
@@ -11207,10 +11357,9 @@
11207
11357
  previousSelector: movementInfo.previousSelector,
11208
11358
  focusManager: detail.focusManager
11209
11359
  });
11210
- const configureMenu = (detail, movementInfo) => ({
11360
+ const configureMenu = (detail, _movementInfo) => ({
11211
11361
  mode: 'menu',
11212
11362
  selector: '.' + detail.markers.item,
11213
- moveOnTab: movementInfo.moveOnTab,
11214
11363
  focusManager: detail.focusManager
11215
11364
  });
11216
11365
  const parts$d = constant$1([
@@ -11253,12 +11402,7 @@
11253
11402
  defaulted('eventOrder', {}),
11254
11403
  field('menuBehaviours', [Highlighting, Representing, Composing, Keying]),
11255
11404
  defaultedOf('movement', {
11256
- // When you don't specify movement for a Menu, this is what you get
11257
- // a "menu" type of movement that moves on tab. If you want finer-grained
11258
- // control, like disabling moveOnTab, then you need to specify
11259
- // your entire movement configuration when creating your MenuSpec.
11260
- mode: 'menu',
11261
- moveOnTab: true
11405
+ mode: 'menu'
11262
11406
  }, choose$1('mode', {
11263
11407
  grid: [
11264
11408
  initSize(),
@@ -11270,7 +11414,6 @@
11270
11414
  defaulted('previousSelector', Optional.none),
11271
11415
  ],
11272
11416
  menu: [
11273
- defaulted('moveOnTab', true),
11274
11417
  output$1('config', configureMenu)
11275
11418
  ]
11276
11419
  })),
@@ -11837,6 +11980,8 @@
11837
11980
  onRight: keyOnItem(onRight),
11838
11981
  onLeft: keyOnItem(onLeft),
11839
11982
  onEscape: keyOnItem(onEscape),
11983
+ onTab: detail.onTab,
11984
+ onShiftTab: detail.onShiftTab,
11840
11985
  focusIn: (container, _keyInfo) => {
11841
11986
  layeredState.getPrimary().each((primary) => {
11842
11987
  dispatch(container, primary.element, focusItem());
@@ -11883,6 +12028,8 @@
11883
12028
  configFields: [
11884
12029
  onStrictKeyboardHandler('onExecute'),
11885
12030
  onStrictKeyboardHandler('onEscape'),
12031
+ onKeyboardHandler('onTab'),
12032
+ onKeyboardHandler('onShiftTab'),
11886
12033
  onStrictHandler('onOpenMenu'),
11887
12034
  onStrictHandler('onOpenSubmenu'),
11888
12035
  onHandler('onRepositionMenu'),
@@ -12006,6 +12153,15 @@
12006
12153
  const openF = (detail, mapFetch, anchor, component, sandbox, externals, highlightOnOpen) => {
12007
12154
  const futureData = fetch$1(detail, mapFetch, component);
12008
12155
  const getLazySink = getSink(component, detail);
12156
+ // When Tab or Shift+Tab bubbles up from inside an open menu, close the menu,
12157
+ // refocus the trigger, and re-emit the keydown so the trigger's parent
12158
+ // (toolbar, menubar, etc.) handles it via its own Keying config.
12159
+ const onTabOutOfMenu = (_tmenu, se) => {
12160
+ Focusing.focus(component);
12161
+ emitWith(component, 'keydown', { raw: se.event.raw });
12162
+ Sandboxing.close(sandbox);
12163
+ return Optional.some(true);
12164
+ };
12009
12165
  // TODO: Make this potentially a single menu also
12010
12166
  return futureData.map((tdata) => tdata.bind((data) => {
12011
12167
  const primaryMenu = data.menus[data.primary];
@@ -12050,7 +12206,9 @@
12050
12206
  Focusing.focus(component);
12051
12207
  Sandboxing.close(sandbox);
12052
12208
  return Optional.some(true);
12053
- }
12209
+ },
12210
+ onTab: onTabOutOfMenu,
12211
+ onShiftTab: onTabOutOfMenu
12054
12212
  }));
12055
12213
  }));
12056
12214
  };
@@ -12559,10 +12717,10 @@
12559
12717
  const shouldSkipFocus = value$2();
12560
12718
  const toggleWithoutFocusing = (button, externals) => {
12561
12719
  shouldSkipFocus.set(true);
12562
- toggle$1(button, externals);
12720
+ toggle(button, externals);
12563
12721
  shouldSkipFocus.clear();
12564
12722
  };
12565
- const toggle$1 = (button, externals) => {
12723
+ const toggle = (button, externals) => {
12566
12724
  const toolbarSandbox = Coupling.getCoupled(button, 'toolbarSandbox');
12567
12725
  if (Sandboxing.isOpen(toolbarSandbox)) {
12568
12726
  Sandboxing.close(toolbarSandbox);
@@ -12657,7 +12815,7 @@
12657
12815
  ...Button.sketch({
12658
12816
  ...externals.button(),
12659
12817
  action: (button) => {
12660
- toggle$1(button, externals);
12818
+ toggle(button, externals);
12661
12819
  },
12662
12820
  buttonBehaviours: SketchBehaviours.augment({ dump: externals.button().buttonBehaviours }, [
12663
12821
  Coupling.config({
@@ -12681,7 +12839,7 @@
12681
12839
  });
12682
12840
  },
12683
12841
  toggle: (button) => {
12684
- toggle$1(button, externals);
12842
+ toggle(button, externals);
12685
12843
  },
12686
12844
  toggleWithoutFocusing: (button) => {
12687
12845
  toggleWithoutFocusing(button, externals);
@@ -15638,19 +15796,17 @@
15638
15796
 
15639
15797
  var global$7 = tinymce.util.Tools.resolve('tinymce.Env');
15640
15798
 
15641
- var ToolbarMode$1;
15642
- (function (ToolbarMode) {
15643
- ToolbarMode["default"] = "wrap";
15644
- ToolbarMode["floating"] = "floating";
15645
- ToolbarMode["sliding"] = "sliding";
15646
- ToolbarMode["scrolling"] = "scrolling";
15647
- })(ToolbarMode$1 || (ToolbarMode$1 = {}));
15648
- var ToolbarLocation$1;
15649
- (function (ToolbarLocation) {
15650
- ToolbarLocation["auto"] = "auto";
15651
- ToolbarLocation["top"] = "top";
15652
- ToolbarLocation["bottom"] = "bottom";
15653
- })(ToolbarLocation$1 || (ToolbarLocation$1 = {}));
15799
+ const ToolbarMode$1 = {
15800
+ default: 'wrap',
15801
+ floating: 'floating',
15802
+ sliding: 'sliding',
15803
+ scrolling: 'scrolling'
15804
+ };
15805
+ const ToolbarLocation$1 = {
15806
+ auto: 'auto',
15807
+ top: 'top',
15808
+ bottom: 'bottom'
15809
+ };
15654
15810
  const option$2 = (name) => (editor) => editor.options.get(name);
15655
15811
  const wrapOptional = (fn) => (editor) => Optional.from(fn(editor));
15656
15812
  const register$f = (editor) => {
@@ -15987,63 +16143,63 @@
15987
16143
 
15988
16144
  var Options = /*#__PURE__*/Object.freeze({
15989
16145
  __proto__: null,
15990
- get ToolbarMode () { return ToolbarMode$1; },
15991
- get ToolbarLocation () { return ToolbarLocation$1; },
15992
- register: register$f,
15993
- getSkinUrl: getSkinUrl,
15994
- getSkinUrlOption: getSkinUrlOption,
15995
- isReadOnly: isReadOnly,
15996
- isDisabled: isDisabled,
15997
- getSkin: getSkin,
15998
- isSkinDisabled: isSkinDisabled,
16146
+ ToolbarMode: ToolbarMode$1,
16147
+ ToolbarLocation: ToolbarLocation$1,
16148
+ getAnchorBottom: getAnchorBottom,
16149
+ getAnchorTop: getAnchorTop,
16150
+ getContentLanguages: getContentLanguages,
16151
+ getDefaultFontStack: getDefaultFontStack,
16152
+ getFilePickerCallback: getFilePickerCallback,
16153
+ getFilePickerTypes: getFilePickerTypes,
16154
+ getFilePickerValidatorHandler: getFilePickerValidatorHandler,
16155
+ getFontSizeInputDefaultUnit: getFontSizeInputDefaultUnit,
15999
16156
  getHeightOption: getHeightOption,
16000
- getWidthOption: getWidthOption,
16001
- getMinWidthOption: getMinWidthOption,
16002
- getMinHeightOption: getMinHeightOption,
16003
- getMaxWidthOption: getMaxWidthOption,
16004
- getMaxHeightOption: getMaxHeightOption,
16005
- getUserStyleFormats: getUserStyleFormats,
16006
- shouldMergeStyleFormats: shouldMergeStyleFormats,
16007
- shouldAutoHideStyleFormats: shouldAutoHideStyleFormats,
16008
16157
  getLineHeightFormats: getLineHeightFormats,
16009
- getContentLanguages: getContentLanguages,
16158
+ getMaxHeightOption: getMaxHeightOption,
16159
+ getMaxWidthOption: getMaxWidthOption,
16160
+ getMenubar: getMenubar,
16161
+ getMenus: getMenus,
16162
+ getMinHeightOption: getMinHeightOption,
16163
+ getMinWidthOption: getMinWidthOption,
16164
+ getMultipleToolbarsOption: getMultipleToolbarsOption,
16165
+ getPasteAsText: getPasteAsText,
16010
16166
  getRemovedMenuItems: getRemovedMenuItems,
16167
+ getResize: getResize,
16168
+ getSidebarShow: getSidebarShow,
16169
+ getSkin: getSkin,
16170
+ getSkinUrl: getSkinUrl,
16171
+ getSkinUrlOption: getSkinUrlOption,
16172
+ getStickyToolbarOffset: getStickyToolbarOffset,
16173
+ getToolbar: getToolbar,
16174
+ getToolbarGroups: getToolbarGroups,
16175
+ getToolbarLocation: getToolbarLocation,
16176
+ getToolbarMode: getToolbarMode,
16177
+ getUiContainer: getUiContainer,
16178
+ getUserStyleFormats: getUserStyleFormats,
16179
+ getViewShow: getViewShow,
16180
+ getWidthOption: getWidthOption,
16181
+ isDisabled: isDisabled,
16182
+ isDistractionFree: isDistractionFree,
16183
+ isDraggableModal: isDraggableModal$1,
16011
16184
  isMenubarEnabled: isMenubarEnabled,
16012
16185
  isMultipleToolbars: isMultipleToolbars,
16013
- isToolbarEnabled: isToolbarEnabled,
16014
- isToolbarPersist: isToolbarPersist,
16015
- getMultipleToolbarsOption: getMultipleToolbarsOption,
16016
- getUiContainer: getUiContainer,
16017
- useFixedContainer: useFixedContainer,
16186
+ isReadOnly: isReadOnly,
16187
+ isSkinDisabled: isSkinDisabled,
16018
16188
  isSplitUiMode: isSplitUiMode,
16019
- getToolbarMode: getToolbarMode,
16020
- isDraggableModal: isDraggableModal$1,
16021
- isDistractionFree: isDistractionFree,
16022
16189
  isStickyToolbar: isStickyToolbar,
16023
- getStickyToolbarOffset: getStickyToolbarOffset,
16024
- getToolbarLocation: getToolbarLocation,
16190
+ isToolbarEnabled: isToolbarEnabled,
16025
16191
  isToolbarLocationBottom: isToolbarLocationBottom,
16026
- getToolbarGroups: getToolbarGroups,
16027
- getMenus: getMenus,
16028
- getMenubar: getMenubar,
16029
- getToolbar: getToolbar,
16030
- getFilePickerCallback: getFilePickerCallback,
16031
- getFilePickerTypes: getFilePickerTypes,
16032
- useTypeaheadUrls: useTypeaheadUrls,
16033
- getAnchorTop: getAnchorTop,
16034
- getAnchorBottom: getAnchorBottom,
16035
- getFilePickerValidatorHandler: getFilePickerValidatorHandler,
16036
- getFontSizeInputDefaultUnit: getFontSizeInputDefaultUnit,
16037
- useStatusBar: useStatusBar,
16038
- useElementPath: useElementPath,
16192
+ isToolbarPersist: isToolbarPersist,
16039
16193
  promotionEnabled: promotionEnabled,
16194
+ register: register$f,
16195
+ shouldAutoHideStyleFormats: shouldAutoHideStyleFormats,
16196
+ shouldMergeStyleFormats: shouldMergeStyleFormats,
16040
16197
  useBranding: useBranding,
16041
- getResize: getResize,
16042
- getPasteAsText: getPasteAsText,
16043
- getSidebarShow: getSidebarShow,
16044
- getViewShow: getViewShow,
16198
+ useElementPath: useElementPath,
16199
+ useFixedContainer: useFixedContainer,
16045
16200
  useHelpAccessibility: useHelpAccessibility,
16046
- getDefaultFontStack: getDefaultFontStack
16201
+ useStatusBar: useStatusBar,
16202
+ useTypeaheadUrls: useTypeaheadUrls
16047
16203
  });
16048
16204
 
16049
16205
  // See https://developer.mozilla.org/en-US/docs/Glossary/Scroll_container for what makes an element scrollable
@@ -16092,7 +16248,7 @@
16092
16248
  return sc.isFullscreen() ? win() : constrainByMany(box$1(sc.element), scrollableBoxes);
16093
16249
  };
16094
16250
 
16095
- /*! @license DOMPurify 3.4.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.5/LICENSE */
16251
+ /*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */
16096
16252
 
16097
16253
  function _arrayLikeToArray(r, a) {
16098
16254
  (null == a || a > r.length) && (a = r.length);
@@ -16405,7 +16561,7 @@
16405
16561
  const text$1 = freeze(['#text']);
16406
16562
 
16407
16563
  const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);
16408
- const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
16564
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dominant-baseline', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-orientation', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
16409
16565
  const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
16410
16566
  const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
16411
16567
 
@@ -16421,16 +16577,31 @@
16421
16577
  );
16422
16578
  const DOCTYPE_NAME = seal(/^html$/i);
16423
16579
  const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
16580
+ // Markup-significant character probes used by _sanitizeElements.
16581
+ // Shared module-level instances are safe despite the sticky /g flags:
16582
+ // unapply() resets lastIndex for RegExp receivers before every call.
16583
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
16584
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
16585
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
16586
+ const SELF_CLOSING_TAG = seal(/\/>/i);
16424
16587
 
16425
- /* eslint-disable @typescript-eslint/indent */
16426
16588
  // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
16427
16589
  const NODE_TYPE = {
16428
16590
  element: 1,
16591
+ attribute: 2,
16429
16592
  text: 3,
16593
+ cdataSection: 4,
16594
+ entityReference: 5,
16595
+ // Deprecated
16596
+ entityNode: 6,
16430
16597
  // Deprecated
16431
- progressingInstruction: 7,
16598
+ processingInstruction: 7,
16432
16599
  comment: 8,
16433
- document: 9};
16600
+ document: 9,
16601
+ documentType: 10,
16602
+ documentFragment: 11,
16603
+ notation: 12 // Deprecated
16604
+ };
16434
16605
  const getGlobal = function getGlobal() {
16435
16606
  return typeof window === 'undefined' ? null : window;
16436
16607
  };
@@ -16485,10 +16656,25 @@
16485
16656
  uponSanitizeShadowNode: []
16486
16657
  };
16487
16658
  };
16659
+ /**
16660
+ * Resolve a set-valued configuration option: a fresh set built from
16661
+ * cfg[key] when it is an own array property (seeded with a clone of
16662
+ * options.base when given, case-normalized via options.transform),
16663
+ * the fallback set otherwise.
16664
+ *
16665
+ * @param cfg the cloned, prototype-free configuration object
16666
+ * @param key the configuration property to read
16667
+ * @param fallback the set to use when the option is absent or not an array
16668
+ * @param options transform and optional base set to merge into
16669
+ * @returns the resolved set
16670
+ */
16671
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
16672
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
16673
+ };
16488
16674
  function createDOMPurify() {
16489
16675
  let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
16490
16676
  const DOMPurify = root => createDOMPurify(root);
16491
- DOMPurify.version = '3.4.5';
16677
+ DOMPurify.version = '3.4.12';
16492
16678
  DOMPurify.removed = [];
16493
16679
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
16494
16680
  // Not running in a browser, provide a factory function
@@ -16499,15 +16685,15 @@
16499
16685
  let document = window.document;
16500
16686
  const originalDocument = document;
16501
16687
  const currentScript = originalDocument.currentScript;
16502
- const DocumentFragment = window.DocumentFragment,
16503
- HTMLTemplateElement = window.HTMLTemplateElement,
16688
+ window.DocumentFragment;
16689
+ const HTMLTemplateElement = window.HTMLTemplateElement,
16504
16690
  Node = window.Node,
16505
16691
  Element = window.Element,
16506
16692
  NodeFilter = window.NodeFilter,
16507
- _window$NamedNodeMap = window.NamedNodeMap,
16508
- NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
16509
- HTMLFormElement = window.HTMLFormElement,
16510
- DOMParser = window.DOMParser,
16693
+ _window$NamedNodeMap = window.NamedNodeMap;
16694
+ _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
16695
+ window.HTMLFormElement;
16696
+ const DOMParser = window.DOMParser,
16511
16697
  trustedTypes = window.trustedTypes;
16512
16698
  const ElementPrototype = Element.prototype;
16513
16699
  const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
@@ -16515,7 +16701,10 @@
16515
16701
  const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
16516
16702
  const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
16517
16703
  const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
16704
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
16705
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
16518
16706
  const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
16707
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
16519
16708
  // As per issue #47, the web-components registry is inherited by a
16520
16709
  // new document created via createHTMLDocument. As per the spec
16521
16710
  // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
@@ -16530,6 +16719,54 @@
16530
16719
  }
16531
16720
  let trustedTypesPolicy;
16532
16721
  let emptyHTML = '';
16722
+ // The instance's own internal Trusted Types policy. Unlike a caller-supplied
16723
+ // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
16724
+ // on duplicate policy names — and is the only policy allowed to persist
16725
+ // across configurations and survive `clearConfig()`.
16726
+ let defaultTrustedTypesPolicy;
16727
+ let defaultTrustedTypesPolicyResolved = false;
16728
+ // Tracks whether we are already inside a call to the configured Trusted Types
16729
+ // policy (`createHTML` or `createScriptURL`). If a supplied policy callback
16730
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
16731
+ // re-enter the policy and recurse until the stack overflows. We detect that
16732
+ // re-entry and throw a clear, actionable error instead. The guard is shared
16733
+ // across both callbacks, because either one re-entering `sanitize` triggers
16734
+ // the same unbounded recursion.
16735
+ let IN_TRUSTED_TYPES_POLICY = 0;
16736
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
16737
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
16738
+ throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted ' + 'Types" section of the README.');
16739
+ }
16740
+ };
16741
+ const _createTrustedHTML = function _createTrustedHTML(html) {
16742
+ _assertNotInTrustedTypesPolicy();
16743
+ IN_TRUSTED_TYPES_POLICY++;
16744
+ try {
16745
+ return trustedTypesPolicy.createHTML(html);
16746
+ } finally {
16747
+ IN_TRUSTED_TYPES_POLICY--;
16748
+ }
16749
+ };
16750
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
16751
+ _assertNotInTrustedTypesPolicy();
16752
+ IN_TRUSTED_TYPES_POLICY++;
16753
+ try {
16754
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
16755
+ } finally {
16756
+ IN_TRUSTED_TYPES_POLICY--;
16757
+ }
16758
+ };
16759
+ // Lazily resolve (and cache) the instance's internal default policy.
16760
+ // Resolution is attempted at most once: a successful `createPolicy` cannot be
16761
+ // repeated (Trusted Types throws on duplicate names), and a failed or
16762
+ // unsupported attempt must not be retried on every parse.
16763
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
16764
+ if (!defaultTrustedTypesPolicyResolved) {
16765
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
16766
+ defaultTrustedTypesPolicyResolved = true;
16767
+ }
16768
+ return defaultTrustedTypesPolicy;
16769
+ };
16533
16770
  const _document = document,
16534
16771
  implementation = _document.implementation,
16535
16772
  createNodeIterator = _document.createNodeIterator,
@@ -16626,6 +16863,13 @@
16626
16863
  let WHOLE_DOCUMENT = false;
16627
16864
  /* Track whether config is already set on this instance of DOMPurify. */
16628
16865
  let SET_CONFIG = false;
16866
+ /* Pristine allowlist bindings captured at setConfig() time. On the
16867
+ * persistent-config path sanitize() restores the sets from these before
16868
+ * the per-walk hook clone-guard, so a hook's in-call widening cannot
16869
+ * carry across calls. Null until setConfig() is called; reset by
16870
+ * clearConfig(). */
16871
+ let SET_CONFIG_ALLOWED_TAGS = null;
16872
+ let SET_CONFIG_ALLOWED_ATTR = null;
16629
16873
  /* Decide if all elements (e.g. style, script) must be children of
16630
16874
  * document.body. By default, browsers might move them to document.head */
16631
16875
  let FORCE_BODY = false;
@@ -16668,7 +16912,17 @@
16668
16912
  let USE_PROFILES = {};
16669
16913
  /* Tags to ignore content of when KEEP_CONTENT is true */
16670
16914
  let FORBID_CONTENTS = null;
16671
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
16915
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
16916
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
16917
+ // the UA (customizable <select>) — including any on* handlers — and the
16918
+ // engine re-mirrors synchronously whenever a removal changes which
16919
+ // option/selectedcontent is current, even inside DOMPurify's inert
16920
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
16921
+ // mirror target ahead of the walk, which the engine refills, looping
16922
+ // forever (DoS) and amplifying output. Dropping its content on removal
16923
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
16924
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
16925
+ 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
16672
16926
  /* Tags that are safe for data: URIs */
16673
16927
  let DATA_URI_TAGS = null;
16674
16928
  const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
@@ -16684,8 +16938,10 @@
16684
16938
  /* Allowed XHTML+XML namespaces */
16685
16939
  let ALLOWED_NAMESPACES = null;
16686
16940
  const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
16687
- let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
16688
- let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
16941
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
16942
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
16943
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
16944
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
16689
16945
  // Certain elements are allowed in both SVG and HTML
16690
16946
  // namespace. We need to specify them explicitly
16691
16947
  // so that they don't get erroneously deleted from
@@ -16727,14 +16983,32 @@
16727
16983
  // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
16728
16984
  transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
16729
16985
  /* Set configuration parameters */
16730
- ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
16731
- ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
16732
- ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
16733
- URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
16734
- DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
16735
- FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
16736
- FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
16737
- FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
16986
+ ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
16987
+ transform: transformCaseFunc
16988
+ });
16989
+ ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
16990
+ transform: transformCaseFunc
16991
+ });
16992
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
16993
+ transform: stringToString
16994
+ });
16995
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
16996
+ transform: transformCaseFunc,
16997
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
16998
+ });
16999
+ DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
17000
+ transform: transformCaseFunc,
17001
+ base: DEFAULT_DATA_URI_TAGS
17002
+ });
17003
+ FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
17004
+ transform: transformCaseFunc
17005
+ });
17006
+ FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
17007
+ transform: transformCaseFunc
17008
+ });
17009
+ FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
17010
+ transform: transformCaseFunc
17011
+ });
16738
17012
  USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
16739
17013
  ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
16740
17014
  ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
@@ -16753,8 +17027,8 @@
16753
17027
  IN_PLACE = cfg.IN_PLACE || false; // Default false
16754
17028
  IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
16755
17029
  NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
16756
- MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); // Default built-in map
16757
- HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ['annotation-xml']); // Default built-in map
17030
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS); // Default built-in map
17031
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS); // Default built-in map
16758
17032
  const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create$1(null);
16759
17033
  CUSTOM_ELEMENT_HANDLING = create$1(null);
16760
17034
  if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
@@ -16766,6 +17040,7 @@
16766
17040
  if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
16767
17041
  CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
16768
17042
  }
17043
+ seal(CUSTOM_ELEMENT_HANDLING);
16769
17044
  if (SAFE_FOR_TEMPLATES) {
16770
17045
  ALLOW_DATA_ATTR = false;
16771
17046
  }
@@ -16849,6 +17124,13 @@
16849
17124
  addToSet(ALLOWED_TAGS, ['tbody']);
16850
17125
  delete FORBID_TAGS.tbody;
16851
17126
  }
17127
+ // Re-derive the active Trusted Types policy from this configuration on
17128
+ // every parse. The active policy must never be sticky closure state that
17129
+ // outlives the config that set it: a caller-supplied policy left in place
17130
+ // after `clearConfig()` — or after a later call that supplied none, or
17131
+ // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
17132
+ // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
17133
+ // See GHSA-vxr8-fq34-vvx9.
16852
17134
  if (cfg.TRUSTED_TYPES_POLICY) {
16853
17135
  if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
16854
17136
  throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
@@ -16856,18 +17138,45 @@
16856
17138
  if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
16857
17139
  throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
16858
17140
  }
16859
- // Overwrite existing TrustedTypes policy.
17141
+ // A caller-supplied policy applies to this configuration only.
17142
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
16860
17143
  trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
16861
- // Sign local variables required by `sanitize`.
16862
- emptyHTML = trustedTypesPolicy.createHTML('');
17144
+ // Sign local variables required by `sanitize`. If the supplied policy's
17145
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
17146
+ // throws via the re-entrancy guard. Restore the previous policy first so
17147
+ // the instance is not left in a poisoned state. See #1422.
17148
+ try {
17149
+ emptyHTML = _createTrustedHTML('');
17150
+ } catch (error) {
17151
+ trustedTypesPolicy = previousTrustedTypesPolicy;
17152
+ throw error;
17153
+ }
17154
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
17155
+ // Explicit opt-out for this call: perform no Trusted Types signing and
17156
+ // create nothing (so a strict `trusted-types` CSP that disallows a
17157
+ // `dompurify` policy can still call `sanitize` from inside its own
17158
+ // policy — see #1422). Resetting to `undefined` rather than a sticky
17159
+ // `null` also drops any previously retained caller policy, so it cannot
17160
+ // resurface on a later call, while still allowing the next config-less
17161
+ // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
17162
+ trustedTypesPolicy = undefined;
17163
+ emptyHTML = '';
16863
17164
  } else {
16864
- // Uninitialized policy, attempt to initialize the internal dompurify policy.
17165
+ // No policy supplied: keep the currently active policy if one is set — a
17166
+ // previously supplied policy is intentionally sticky across config-less
17167
+ // calls — otherwise fall back to the instance's own internal policy,
17168
+ // created at most once. (A policy supplied for a *single* call still
17169
+ // lingers by design; what must not linger is a policy whose configuration
17170
+ // has been torn down via `clearConfig()`, which restores the default.)
16865
17171
  if (trustedTypesPolicy === undefined) {
16866
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
17172
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
16867
17173
  }
16868
- // If creating the internal policy succeeded sign internal variables.
16869
- if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
16870
- emptyHTML = trustedTypesPolicy.createHTML('');
17174
+ // Sign internal variables only when a policy is active. A falsy policy
17175
+ // (Trusted Types unsupported, creation failed, or an explicit opt-out)
17176
+ // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
17177
+ // a non-policy and throw. See #1422.
17178
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
17179
+ emptyHTML = _createTrustedHTML('');
16871
17180
  }
16872
17181
  }
16873
17182
  // Prevent further manipulation of configuration.
@@ -16882,6 +17191,77 @@
16882
17191
  * correctly. */
16883
17192
  const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
16884
17193
  const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
17194
+ /**
17195
+ * Namespace rules for an element in the SVG namespace.
17196
+ *
17197
+ * @param tagName the element's lowercase tag name
17198
+ * @param parent the (possibly simulated) parent node
17199
+ * @param parentTagName the parent's lowercase tag name
17200
+ * @returns true if a spec-compliant parser could produce this element
17201
+ */
17202
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
17203
+ // The only way to switch from HTML namespace to SVG
17204
+ // is via <svg>. If it happens via any other tag, then
17205
+ // it should be killed.
17206
+ if (parent.namespaceURI === HTML_NAMESPACE) {
17207
+ return tagName === 'svg';
17208
+ }
17209
+ // The only way to switch from MathML to SVG is via <svg>
17210
+ // if the parent is either <annotation-xml> or a MathML
17211
+ // text integration point.
17212
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
17213
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
17214
+ }
17215
+ // We only allow elements that are defined in SVG
17216
+ // spec. All others are disallowed in SVG namespace.
17217
+ return Boolean(ALL_SVG_TAGS[tagName]);
17218
+ };
17219
+ /**
17220
+ * Namespace rules for an element in the MathML namespace.
17221
+ *
17222
+ * @param tagName the element's lowercase tag name
17223
+ * @param parent the (possibly simulated) parent node
17224
+ * @param parentTagName the parent's lowercase tag name
17225
+ * @returns true if a spec-compliant parser could produce this element
17226
+ */
17227
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
17228
+ // The only way to switch from HTML namespace to MathML
17229
+ // is via <math>. If it happens via any other tag, then
17230
+ // it should be killed.
17231
+ if (parent.namespaceURI === HTML_NAMESPACE) {
17232
+ return tagName === 'math';
17233
+ }
17234
+ // The only way to switch from SVG to MathML is via
17235
+ // <math> and HTML integration points
17236
+ if (parent.namespaceURI === SVG_NAMESPACE) {
17237
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
17238
+ }
17239
+ // We only allow elements that are defined in MathML
17240
+ // spec. All others are disallowed in MathML namespace.
17241
+ return Boolean(ALL_MATHML_TAGS[tagName]);
17242
+ };
17243
+ /**
17244
+ * Namespace rules for an element in the HTML namespace.
17245
+ *
17246
+ * @param tagName the element's lowercase tag name
17247
+ * @param parent the (possibly simulated) parent node
17248
+ * @param parentTagName the parent's lowercase tag name
17249
+ * @returns true if a spec-compliant parser could produce this element
17250
+ */
17251
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
17252
+ // The only way to switch from SVG to HTML is via
17253
+ // HTML integration points, and from MathML to HTML
17254
+ // is via MathML text integration points
17255
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
17256
+ return false;
17257
+ }
17258
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
17259
+ return false;
17260
+ }
17261
+ // We disallow tags that are specific for MathML
17262
+ // or SVG and should never appear in HTML namespace
17263
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
17264
+ };
16885
17265
  /**
16886
17266
  * @param element a DOM element whose namespace is being checked
16887
17267
  * @returns Return false if the element has a
@@ -16904,51 +17284,13 @@
16904
17284
  return false;
16905
17285
  }
16906
17286
  if (element.namespaceURI === SVG_NAMESPACE) {
16907
- // The only way to switch from HTML namespace to SVG
16908
- // is via <svg>. If it happens via any other tag, then
16909
- // it should be killed.
16910
- if (parent.namespaceURI === HTML_NAMESPACE) {
16911
- return tagName === 'svg';
16912
- }
16913
- // The only way to switch from MathML to SVG is via`
16914
- // svg if parent is either <annotation-xml> or MathML
16915
- // text integration points.
16916
- if (parent.namespaceURI === MATHML_NAMESPACE) {
16917
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
16918
- }
16919
- // We only allow elements that are defined in SVG
16920
- // spec. All others are disallowed in SVG namespace.
16921
- return Boolean(ALL_SVG_TAGS[tagName]);
17287
+ return _checkSvgNamespace(tagName, parent, parentTagName);
16922
17288
  }
16923
17289
  if (element.namespaceURI === MATHML_NAMESPACE) {
16924
- // The only way to switch from HTML namespace to MathML
16925
- // is via <math>. If it happens via any other tag, then
16926
- // it should be killed.
16927
- if (parent.namespaceURI === HTML_NAMESPACE) {
16928
- return tagName === 'math';
16929
- }
16930
- // The only way to switch from SVG to MathML is via
16931
- // <math> and HTML integration points
16932
- if (parent.namespaceURI === SVG_NAMESPACE) {
16933
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
16934
- }
16935
- // We only allow elements that are defined in MathML
16936
- // spec. All others are disallowed in MathML namespace.
16937
- return Boolean(ALL_MATHML_TAGS[tagName]);
17290
+ return _checkMathMlNamespace(tagName, parent, parentTagName);
16938
17291
  }
16939
17292
  if (element.namespaceURI === HTML_NAMESPACE) {
16940
- // The only way to switch from SVG to HTML is via
16941
- // HTML integration points, and from MathML to HTML
16942
- // is via MathML text integration points
16943
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
16944
- return false;
16945
- }
16946
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
16947
- return false;
16948
- }
16949
- // We disallow tags that are specific for MathML
16950
- // or SVG and should never appear in HTML namespace
16951
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
17293
+ return _checkHtmlNamespace(tagName, parent, parentTagName);
16952
17294
  }
16953
17295
  // For XHTML and XML documents that support custom namespaces
16954
17296
  if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
@@ -16973,7 +17315,81 @@
16973
17315
  // eslint-disable-next-line unicorn/prefer-dom-node-remove
16974
17316
  getParentNode(node).removeChild(node);
16975
17317
  } catch (_) {
17318
+ /* The normal detach failed — this is reached for a parentless node
17319
+ (getParentNode() is null, so .removeChild throws). Element.prototype
17320
+ .remove() is itself a spec no-op on a parentless node, so a recorded
17321
+ "removal" would otherwise hand the caller back an intact,
17322
+ payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
17323
+ the style-with-element-child rule decided to kill). Fail closed by
17324
+ throwing — exactly as a clobbered root does at the IN_PLACE entry —
17325
+ rather than trying to "neutralize" the node via its own methods.
17326
+ Neutralizing would mean calling getAttributeNames()/removeAttribute()
17327
+ on the node, both of which a <form> root can clobber via a named child
17328
+ (and _isClobbered does not even probe getAttributeNames), so the
17329
+ neutralize step could itself be silently defeated, leaving the payload
17330
+ intact. A throw touches only the cached, clobber-safe remove() and
17331
+ getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
17332
+ to every root-kill reason. REPORT-3.
17333
+ This lives inside the catch, so it never fires for a normally-removed
17334
+ in-tree node: those have a parent, removeChild() succeeds, and the
17335
+ catch is not entered. Only a kept (parentless) root reaches here. */
16976
17336
  remove(node);
17337
+ if (!getParentNode(node)) {
17338
+ throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
17339
+ }
17340
+ }
17341
+ };
17342
+ /**
17343
+ * _neutralizeRoot
17344
+ *
17345
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
17346
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
17347
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
17348
+ * parentless guard throws, or any other re-entrant engine mutation — would
17349
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
17350
+ * after the abort point still carrying its handlers. There is no safe way
17351
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
17352
+ * remove every child and every attribute, then let the caller's catch see
17353
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
17354
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
17355
+ *
17356
+ * @param root the in-place root to empty
17357
+ */
17358
+ const _neutralizeRoot = function _neutralizeRoot(root) {
17359
+ /* Strip every disallowed attribute (on* handlers included) off the whole
17360
+ subtree BEFORE detaching anything. Detaching first would hand back
17361
+ handler-bearing originals (e.g. an already-loading `<img onerror>`)
17362
+ whose queued resource event still fires in page scope after we throw.
17363
+ Clobber-safe reads; a doomed clobbered node's own attributes are
17364
+ irrelevant while its non-clobbered descendants are reached and scrubbed. */
17365
+ _neutralizeSubtree(root);
17366
+ const childNodes = getChildNodes(root);
17367
+ if (childNodes) {
17368
+ const snapshot = [];
17369
+ arrayForEach(childNodes, child => {
17370
+ arrayPush(snapshot, child);
17371
+ });
17372
+ arrayForEach(snapshot, child => {
17373
+ try {
17374
+ remove(child);
17375
+ } catch (_) {
17376
+ /* Best-effort teardown; a still-attached child is handled below */
17377
+ }
17378
+ });
17379
+ }
17380
+ const attributes = getAttributes(root);
17381
+ if (attributes) {
17382
+ for (let i = attributes.length - 1; i >= 0; --i) {
17383
+ const attribute = attributes[i];
17384
+ const name = attribute && attribute.name;
17385
+ if (typeof name === 'string') {
17386
+ try {
17387
+ root.removeAttribute(name);
17388
+ } catch (_) {
17389
+ /* Clobbered removeAttribute — ignore (fail-closed best effort) */
17390
+ }
17391
+ }
17392
+ }
16977
17393
  }
16978
17394
  };
16979
17395
  /**
@@ -17008,6 +17424,148 @@
17008
17424
  }
17009
17425
  }
17010
17426
  };
17427
+ /**
17428
+ * _stripDisallowedAttributes
17429
+ *
17430
+ * Removes every attribute the active configuration does not allow from a
17431
+ * single element, using the same allowlist as the main attribute pass (so
17432
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
17433
+ * neutralise nodes that are being discarded from an in-place tree.
17434
+ *
17435
+ * @param element the element to strip
17436
+ */
17437
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
17438
+ const attributes = getAttributes(element);
17439
+ if (!attributes) {
17440
+ return;
17441
+ }
17442
+ for (let i = attributes.length - 1; i >= 0; --i) {
17443
+ const attribute = attributes[i];
17444
+ const name = attribute && attribute.name;
17445
+ if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
17446
+ continue;
17447
+ }
17448
+ try {
17449
+ element.removeAttribute(name);
17450
+ } catch (_) {
17451
+ /* Clobbered removeAttribute on a doomed node — ignore */
17452
+ }
17453
+ }
17454
+ };
17455
+ /**
17456
+ * _neutralizeSubtree
17457
+ *
17458
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
17459
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
17460
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
17461
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
17462
+ * those dropped nodes are detached from the caller's LIVE tree but a
17463
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
17464
+ * loading) keeps its queued resource event, which fires in page scope after
17465
+ * sanitize returns. This walks a removed subtree and strips every attribute
17466
+ * the active configuration does not allow — so `on*` handlers are cancelled
17467
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
17468
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
17469
+ * queued event can fire. Hook-free by design: these nodes leave the output,
17470
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
17471
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
17472
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
17473
+ * the `<img>`, are reached and scrubbed).
17474
+ *
17475
+ * @param root the root of a removed subtree to neutralise
17476
+ */
17477
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
17478
+ const stack = [root];
17479
+ while (stack.length > 0) {
17480
+ const node = stack.pop();
17481
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
17482
+ if (nodeType === NODE_TYPE.element) {
17483
+ _stripDisallowedAttributes(node);
17484
+ }
17485
+ const childNodes = getChildNodes(node);
17486
+ if (childNodes) {
17487
+ for (let i = childNodes.length - 1; i >= 0; --i) {
17488
+ stack.push(childNodes[i]);
17489
+ }
17490
+ }
17491
+ }
17492
+ };
17493
+ /**
17494
+ * _neutralizePatchLinkage
17495
+ *
17496
+ * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
17497
+ * hardening, https://github.com/WICG/declarative-partial-updates).
17498
+ *
17499
+ * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
17500
+ * markers (PIs / markup comments) node-by-node, in document order, AS it
17501
+ * reaches each node. On a live in-place root that leaves a window: from the
17502
+ * moment the root is connected until the walk arrives at a given node, that
17503
+ * node's linkage is live. A patch applied on connection/stream can fire as
17504
+ * a microtask during the walk and inject or teleport an unsanitized DOM
17505
+ * range into a region the iterator has already passed and will not revisit,
17506
+ * so the post-return "tree is sanitized" contract is violated. Sweep the
17507
+ * whole tree once up front and sever every linkage before the walk begins,
17508
+ * closing that window.
17509
+ *
17510
+ * This CANNOT undo a patch that already fired before sanitize ran — that is
17511
+ * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
17512
+ * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
17513
+ * to group with the rest of the declarative-partial-updates handling and
17514
+ * stay overridable, consistent with the codebase.
17515
+ *
17516
+ * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
17517
+ * clobbered root cannot defeat the sweep of its non-clobbered descendants.
17518
+ *
17519
+ * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
17520
+ * .html Q1): this mirrors the existing policy of keeping `for` on
17521
+ * <label>/<output>. If the shipping feature can drive a patch through a
17522
+ * surviving `for`-on-label/output + `id` pair, this pre-pass and the
17523
+ * attribute check at _isBasicCustomElement's caller must additionally drop
17524
+ * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
17525
+ *
17526
+ * @param root the in-place root to sweep
17527
+ */
17528
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
17529
+ if (!SAFE_FOR_XML) {
17530
+ return;
17531
+ }
17532
+ const stack = [root];
17533
+ while (stack.length > 0) {
17534
+ const node = stack.pop();
17535
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
17536
+ /* Remove range markers (the target side of a patch linkage): every
17537
+ processing instruction, and any markup-bearing comment. */
17538
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
17539
+ try {
17540
+ remove(node);
17541
+ } catch (_) {
17542
+ /* Best-effort */
17543
+ }
17544
+ continue;
17545
+ }
17546
+ /* Strip patch-source attributes (the source side) off elements. */
17547
+ if (nodeType === NODE_TYPE.element) {
17548
+ const element = node;
17549
+ const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
17550
+ try {
17551
+ if (element.hasAttribute && element.hasAttribute('patchsrc')) {
17552
+ element.removeAttribute('patchsrc');
17553
+ }
17554
+ if (element.hasAttribute && element.hasAttribute('for') && lcTag !== 'label' && lcTag !== 'output') {
17555
+ element.removeAttribute('for');
17556
+ }
17557
+ } catch (_) {
17558
+ /* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */
17559
+ }
17560
+ }
17561
+ const childNodes = getChildNodes(node);
17562
+ if (childNodes) {
17563
+ for (let i = childNodes.length - 1; i >= 0; --i) {
17564
+ stack.push(childNodes[i]);
17565
+ }
17566
+ }
17567
+ }
17568
+ };
17011
17569
  /**
17012
17570
  * _initDocument
17013
17571
  *
@@ -17029,7 +17587,7 @@
17029
17587
  // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
17030
17588
  dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
17031
17589
  }
17032
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
17590
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
17033
17591
  /*
17034
17592
  * Use the DOMParser API by default, fallback later if needs be
17035
17593
  * DOMParser not work for svg when has multiple root element.
@@ -17069,6 +17627,20 @@
17069
17627
  // eslint-disable-next-line no-bitwise
17070
17628
  NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
17071
17629
  };
17630
+ /**
17631
+ * Replace template expression syntax (mustache, ERB, template
17632
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
17633
+ * sites. Order matters: mustache, then ERB, then template literal.
17634
+ *
17635
+ * @param value the string to scrub
17636
+ * @returns the scrubbed string
17637
+ */
17638
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
17639
+ value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
17640
+ value = stringReplace(value, ERB_EXPR$1, ' ');
17641
+ value = stringReplace(value, TMPLIT_EXPR$1, ' ');
17642
+ return value;
17643
+ };
17072
17644
  /**
17073
17645
  * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
17074
17646
  * character data of an element subtree. Used as the final safety net for
@@ -17088,29 +17660,100 @@
17088
17660
  *
17089
17661
  * @param node The root element whose character data should be scrubbed.
17090
17662
  */
17091
- const _scrubTemplateExpressions = function _scrubTemplateExpressions(node) {
17663
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
17664
+ var _node$querySelectorAl;
17092
17665
  node.normalize();
17093
17666
  const walker = createNodeIterator.call(node.ownerDocument || node, node,
17094
17667
  // eslint-disable-next-line no-bitwise
17095
17668
  NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
17096
17669
  let currentNode = walker.nextNode();
17097
17670
  while (currentNode) {
17098
- let data = currentNode.data;
17099
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
17100
- data = stringReplace(data, expr, ' ');
17101
- });
17102
- currentNode.data = data;
17671
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
17103
17672
  currentNode = walker.nextNode();
17104
17673
  }
17674
+ // NodeIterator does not descend into <template>.content per the DOM spec,
17675
+ // so we must explicitly recurse into each template's content fragment,
17676
+ // mirroring the approach used by _sanitizeShadowDOM.
17677
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
17678
+ if (templates) {
17679
+ arrayForEach(templates, tmpl => {
17680
+ if (_isDocumentFragment(tmpl.content)) {
17681
+ _scrubTemplateExpressions2(tmpl.content);
17682
+ }
17683
+ });
17684
+ }
17105
17685
  };
17106
17686
  /**
17107
17687
  * _isClobbered
17108
17688
  *
17689
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
17690
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
17691
+ * `name` attribute matching a prototype property shadows that property
17692
+ * on direct reads. We use this check at the IN_PLACE entry-point and
17693
+ * during attribute sanitization to refuse clobbered forms.
17694
+ *
17109
17695
  * @param element element to check for clobbering attacks
17110
17696
  * @return true if clobbered, false if safe
17111
17697
  */
17112
17698
  const _isClobbered = function _isClobbered(element) {
17113
- return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
17699
+ // Realm-independent tag-name probe. If we can't determine the tag
17700
+ // name at all, we can't reason about clobbering — return false
17701
+ // (the caller's other defences still apply).
17702
+ const realTagName = getNodeName ? getNodeName(element) : null;
17703
+ if (typeof realTagName !== 'string') {
17704
+ return false;
17705
+ }
17706
+ if (transformCaseFunc(realTagName) !== 'form') {
17707
+ return false;
17708
+ }
17709
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
17710
+ // Realm-safe NamedNodeMap detection: equality against the cached
17711
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
17712
+ // makes the direct read diverge from the cached read; a clean form
17713
+ // (same-realm OR foreign-realm) has both reads pointing at the same
17714
+ // canonical NamedNodeMap.
17715
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
17716
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
17717
+ // returns the integer 1 for any Element regardless of realm; direct
17718
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
17719
+ // the named child element. Cheap addition — nodeType is read from
17720
+ // an internal slot, no serialization cost — and removes a residual
17721
+ // clobbering surface used by several mXSS / PI / comment branches
17722
+ // in _sanitizeElements that compare currentNode.nodeType directly.
17723
+ element.nodeType !== getNodeType(element) ||
17724
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
17725
+ // "childNodes" shadows the prototype getter. Direct reads of
17726
+ // form.childNodes from a clobbered form return the named child
17727
+ // instead of the real NodeList, so any walk that reads it directly
17728
+ // skips the form's real children. Compare the direct read to the
17729
+ // cached Node.prototype getter — when the form's named-property
17730
+ // getter intercepts the read, the two values differ and we flag
17731
+ // the form. This catches every clobbering child type (input,
17732
+ // select, etc.) regardless of whether the named child happens to
17733
+ // carry a numeric .length, which a typeof-based probe would miss
17734
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
17735
+ element.childNodes !== getChildNodes(element);
17736
+ };
17737
+ /**
17738
+ * Checks whether the given value is a DocumentFragment from any realm.
17739
+ *
17740
+ * The realm-independent replacement reads `nodeType` through the cached
17741
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
17742
+ * constant (11). nodeType is a numeric value resolved from the node's
17743
+ * internal slot, identical across realms for the same kind of node.
17744
+ *
17745
+ * @param value object to check
17746
+ * @return true if value is a DocumentFragment-shaped node from any realm
17747
+ */
17748
+ const _isDocumentFragment = function _isDocumentFragment(value) {
17749
+ if (!getNodeType || typeof value !== 'object' || value === null) {
17750
+ return false;
17751
+ }
17752
+ try {
17753
+ return getNodeType(value) === NODE_TYPE.documentFragment;
17754
+ } catch (_) {
17755
+ return false;
17756
+ }
17114
17757
  };
17115
17758
  /**
17116
17759
  * Checks whether the given object is a DOM node, including nodes that
@@ -17120,12 +17763,6 @@
17120
17763
  * sanitize() to silently stringify them and reset IN_PLACE to false,
17121
17764
  * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
17122
17765
  *
17123
- * Implementation: call the cached `nodeType` getter from Node.prototype
17124
- * directly on the value. This bypasses any clobbered instance property
17125
- * (e.g. a child element named "nodeType") and works across realms
17126
- * because the WebIDL `nodeType` getter reads an internal slot that
17127
- * every real Node has, regardless of which window minted it.
17128
- *
17129
17766
  * @param value object to check whether it's a DOM node
17130
17767
  * @return true if value is a DOM node from any realm
17131
17768
  */
@@ -17140,10 +17777,110 @@
17140
17777
  }
17141
17778
  };
17142
17779
  function _executeHooks(hooks, currentNode, data) {
17780
+ if (hooks.length === 0) {
17781
+ return;
17782
+ }
17143
17783
  arrayForEach(hooks, hook => {
17144
17784
  hook.call(DOMPurify, currentNode, data, CONFIG);
17145
17785
  });
17146
17786
  }
17787
+ /**
17788
+ * Structural-threat checks that condemn a node regardless of the
17789
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
17790
+ * processing instructions, markup-bearing comments. Pure predicate;
17791
+ * the caller removes. Check order is load-bearing.
17792
+ *
17793
+ * @param currentNode the node to inspect
17794
+ * @param tagName the node's transformCaseFunc'd tag name
17795
+ * @return true if the node must be removed
17796
+ */
17797
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
17798
+ /* Detect mXSS attempts abusing namespace confusion */
17799
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
17800
+ return true;
17801
+ }
17802
+ /* Remove risky CSS construction leading to mXSS */
17803
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
17804
+ return true;
17805
+ }
17806
+ /* Remove any occurrence of processing instructions */
17807
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
17808
+ return true;
17809
+ }
17810
+ /* Remove any kind of possibly harmful comments */
17811
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
17812
+ return true;
17813
+ }
17814
+ return false;
17815
+ };
17816
+ /**
17817
+ * Handle a node whose tag is forbidden or not allowlisted: keep
17818
+ * allowed custom elements (false return exits _sanitizeElements
17819
+ * early - the namespace and fallback-tag removal checks are
17820
+ * intentionally skipped for kept custom elements), else hoist
17821
+ * content per KEEP_CONTENT and remove.
17822
+ *
17823
+ * A kept custom element is the ONLY case in which this function
17824
+ * returns false, so the caller uses that return value to run the
17825
+ * afterSanitizeElements hook on the kept element and keep the
17826
+ * element-hook lifecycle consistent with normal allowlisted
17827
+ * elements (GHSA-c2j3-45gr-mqc4).
17828
+ *
17829
+ * @param currentNode the disallowed node
17830
+ * @param tagName the node's transformCaseFunc'd tag name
17831
+ * @return true if the node was removed, false if kept
17832
+ */
17833
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {
17834
+ /* Check if we have a custom element to handle */
17835
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
17836
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
17837
+ return false;
17838
+ }
17839
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
17840
+ return false;
17841
+ }
17842
+ }
17843
+ /* Keep content except for bad-listed elements.
17844
+ Use the cached prototype getters exclusively — the previous code
17845
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
17846
+ fallbacks, but the cached getters always return the canonical
17847
+ value (or null for a real parent-less node), so the fallback
17848
+ path was dead in safe cases and a clobbering surface in unsafe
17849
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
17850
+ parentNode)` check already gates correctly. */
17851
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
17852
+ const parentNode = getParentNode(currentNode);
17853
+ const childNodes = getChildNodes(currentNode);
17854
+ if (childNodes && parentNode) {
17855
+ const childCount = childNodes.length;
17856
+ /* In-place: hoist the *original* children so the iterator visits
17857
+ and sanitises them through the same allowlist pass as every other
17858
+ node. The caller built the tree in the live document, so the
17859
+ originals carry already-queued resource events (`<img onerror>`,
17860
+ `<video>`/`<audio>` error, lazy/`onload`, …); cloning would leave
17861
+ those originals detached but still armed, firing in page scope
17862
+ while the returned tree looked clean. Moving is safe in-place: the
17863
+ root is pre-validated as an allowed tag and so is never the node
17864
+ being removed, which keeps `parentNode` inside the iterator root
17865
+ and the relocated child inside the serialised tree.
17866
+ Otherwise (string / DOM-copy paths): clone. The iterator is rooted
17867
+ at — and the result serialised from — `body`, so a restrictive
17868
+ ALLOWED_TAGS that removes `body` itself must leave its content in
17869
+ place, which only cloning does; and those paths parse into an
17870
+ inert document, so their discarded originals never had a queued
17871
+ event to neutralise.
17872
+ `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
17873
+ valid whether we move (drops the trailing entry) or clone (leaves
17874
+ the list intact). */
17875
+ for (let i = childCount - 1; i >= 0; --i) {
17876
+ const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
17877
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
17878
+ }
17879
+ }
17880
+ }
17881
+ _forceRemove(currentNode);
17882
+ return true;
17883
+ };
17147
17884
  /**
17148
17885
  * _sanitizeElements
17149
17886
  *
@@ -17153,85 +17890,89 @@
17153
17890
  * @param currentNode to check for permission to exist
17154
17891
  * @return true if node was killed, false if left alive
17155
17892
  */
17156
- const _sanitizeElements = function _sanitizeElements(currentNode) {
17157
- let content = null;
17893
+ // eslint-disable-next-line complexity
17894
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
17158
17895
  /* Execute a hook if present */
17159
17896
  _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
17897
+ /* A hook may have detached the node — treat it as removed (see the
17898
+ detached-node comment after the uponSanitizeElement hook below). */
17899
+ if (currentNode !== root && getParentNode(currentNode) === null) {
17900
+ return true;
17901
+ }
17160
17902
  /* Check if element is clobbered or can clobber */
17161
17903
  if (_isClobbered(currentNode)) {
17162
17904
  _forceRemove(currentNode);
17163
17905
  return true;
17164
17906
  }
17165
17907
  /* Now let's check the element's type and name */
17166
- const tagName = transformCaseFunc(currentNode.nodeName);
17908
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
17167
17909
  /* Execute a hook if present */
17168
17910
  _executeHooks(hooks.uponSanitizeElement, currentNode, {
17169
17911
  tagName,
17170
17912
  allowedTags: ALLOWED_TAGS
17171
17913
  });
17172
- /* Detect mXSS attempts abusing namespace confusion */
17173
- if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
17174
- _forceRemove(currentNode);
17914
+ /* A hook may have detached the node from the tree — a long-standing
17915
+ user pattern (issue #469; draw.io-style foreignObject filtering).
17916
+ Per the cached, unclobberable parentNode getter the node is
17917
+ genuinely out of the tree, so it can reach neither the serialized
17918
+ output nor an IN_PLACE live tree; treat it as removed and stop
17919
+ processing it. Without this guard, the unsafe-node / namespace
17920
+ checks below would call _forceRemove on a parentless node and hit
17921
+ the REPORT-3 fail-closed throw — which exists for nodes DOMPurify
17922
+ wants gone but *cannot* detach (clobbered / parentless roots), the
17923
+ opposite of a node that is already safely gone. The walk root is
17924
+ exempt: a detached IN_PLACE root is legitimate input and must still
17925
+ be fully sanitized, and a kill-decision on it must keep hitting the
17926
+ REPORT-3 throw. Nodes detached by hooks are the hook's
17927
+ responsibility: they are not recorded in DOMPurify.removed and are
17928
+ not neutralized by the post-walk IN_PLACE pass. */
17929
+ if (currentNode !== root && getParentNode(currentNode) === null) {
17175
17930
  return true;
17176
17931
  }
17177
- /* Remove risky CSS construction leading to mXSS */
17178
- if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
17179
- _forceRemove(currentNode);
17180
- return true;
17181
- }
17182
- /* Remove any occurrence of processing instructions */
17183
- if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
17184
- _forceRemove(currentNode);
17185
- return true;
17186
- }
17187
- /* Remove any kind of possibly harmful comments */
17188
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
17932
+ /* Remove mXSS vectors, processing instructions and risky comments */
17933
+ if (_isUnsafeNode(currentNode, tagName)) {
17189
17934
  _forceRemove(currentNode);
17190
17935
  return true;
17191
17936
  }
17192
17937
  /* Remove element if anything forbids its presence */
17193
17938
  if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
17194
- /* Check if we have a custom element to handle */
17195
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
17196
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
17197
- return false;
17198
- }
17199
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
17200
- return false;
17201
- }
17939
+ const removed = _sanitizeDisallowedNode(currentNode, tagName);
17940
+ /* A false return means the node is a custom element kept via
17941
+ CUSTOM_ELEMENT_HANDLING - the only keep path through
17942
+ _sanitizeDisallowedNode. Run afterSanitizeElements on it so the
17943
+ element-hook lifecycle matches normal allowlisted elements: a
17944
+ security policy applied in this hook (e.g. stripping an attribute
17945
+ from every surviving element) must not silently skip kept custom
17946
+ elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element
17947
+ tail below - the hook runs, then the walker's subsequent
17948
+ _sanitizeAttributes pass sanitizes the element's attributes. The
17949
+ deliberately skipped namespace and fallback-tag removal checks stay
17950
+ skipped; they are removal decisions, not the hook contract. */
17951
+ if (removed === false) {
17952
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
17202
17953
  }
17203
- /* Keep content except for bad-listed elements */
17204
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
17205
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
17206
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
17207
- if (childNodes && parentNode) {
17208
- const childCount = childNodes.length;
17209
- for (let i = childCount - 1; i >= 0; --i) {
17210
- const childClone = cloneNode(childNodes[i], true);
17211
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
17212
- }
17213
- }
17214
- }
17215
- _forceRemove(currentNode);
17216
- return true;
17217
- }
17218
- /* Check whether element has a valid namespace */
17219
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
17954
+ return removed;
17955
+ }
17956
+ /* Check whether element has a valid namespace.
17957
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
17958
+ nodeType getter rather than `instanceof Element`, which is realm-
17959
+ bound and short-circuits to false for any node minted in a different
17960
+ realm letting a foreign-realm element with a forbidden namespace
17961
+ slip past the namespace check entirely. */
17962
+ const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
17963
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
17220
17964
  _forceRemove(currentNode);
17221
17965
  return true;
17222
17966
  }
17223
17967
  /* Make sure that older browsers don't get fallback-tag mXSS */
17224
- if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
17968
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
17225
17969
  _forceRemove(currentNode);
17226
17970
  return true;
17227
17971
  }
17228
17972
  /* Sanitize element content to be template-safe */
17229
17973
  if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
17230
17974
  /* Get the element's text content */
17231
- content = currentNode.textContent;
17232
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
17233
- content = stringReplace(content, expr, ' ');
17234
- });
17975
+ const content = _stripTemplateExpressions(currentNode.textContent);
17235
17976
  if (currentNode.textContent !== content) {
17236
17977
  arrayPush(DOMPurify.removed, {
17237
17978
  element: currentNode.cloneNode()
@@ -17257,6 +17998,33 @@
17257
17998
  if (FORBID_ATTR[lcName]) {
17258
17999
  return false;
17259
18000
  }
18001
+ /* Reject declarative-partial-updates patch-linkage attributes
18002
+ (https://github.com/WICG/declarative-partial-updates).
18003
+ Empirical note (Chrome 150, verified — see
18004
+ test/declarative-patch-probe-v3.html): expansion is NOT applied after
18005
+ sanitization. For the string path it fires during sanitize()'s own
18006
+ parse, so the walk sees and sanitizes the fully materialized expanded
18007
+ tree — teleports into MathML/SVG integration points included; a
18008
+ weaponized `<template for>`->`<img onerror>` comes back with the handler
18009
+ stripped. For the IN_PLACE path it fires on connection, before the walk.
18010
+ Either way DOMPurify is NOT blind to the patch.
18011
+ This removal is therefore defense-in-depth rather than the sole barrier:
18012
+ it prevents live linkage from surviving into the OUTPUT and re-expanding
18013
+ in the caller's context, and keeps behaviour deterministic if a future
18014
+ engine defers expansion. `for` is legitimate only on <label>/<output>;
18015
+ anywhere else (notably <template for>) it links the element to a patch
18016
+ target and teleports or removes an arbitrary DOM range by id/marker name.
18017
+ `patchsrc` fetches remote markup and is treated as a script-loading
18018
+ mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the
18019
+ other structural-threat checks and stays overridable, consistent with
18020
+ the rest of the codebase. PI range markers are already removed by
18021
+ _isUnsafeNode. */
18022
+ if (SAFE_FOR_XML && lcName === 'patchsrc') {
18023
+ return false;
18024
+ }
18025
+ if (SAFE_FOR_XML && lcName === 'for' && lcTag !== 'label' && lcTag !== 'output') {
18026
+ return false;
18027
+ }
17260
18028
  /* Make sure attribute cannot clobber */
17261
18029
  if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
17262
18030
  return false;
@@ -17266,7 +18034,7 @@
17266
18034
  (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
17267
18035
  XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
17268
18036
  We don't need to check the value; it's always URI safe. */
17269
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
18037
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
17270
18038
  if (
17271
18039
  // First condition does a very basic check if a) it's basically a valid custom element tagname AND
17272
18040
  // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
@@ -17298,6 +18066,63 @@
17298
18066
  const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
17299
18067
  return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
17300
18068
  };
18069
+ /**
18070
+ * Wrap an attribute value in the matching Trusted Types object when
18071
+ * the active policy requires it. Namespaced attributes pass through
18072
+ * unchanged (no TT support yet, see
18073
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
18074
+ *
18075
+ * @param lcTag lowercase tag name of the containing element
18076
+ * @param lcName lowercase attribute name
18077
+ * @param namespaceURI the attribute's namespace, if any
18078
+ * @param value the attribute value to wrap
18079
+ * @return the value, wrapped when Trusted Types demand it
18080
+ */
18081
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
18082
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
18083
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
18084
+ case 'TrustedHTML':
18085
+ {
18086
+ return _createTrustedHTML(value);
18087
+ }
18088
+ case 'TrustedScriptURL':
18089
+ {
18090
+ return _createTrustedScriptURL(value);
18091
+ }
18092
+ }
18093
+ }
18094
+ return value;
18095
+ };
18096
+ /**
18097
+ * Write a modified attribute value back onto the element. On
18098
+ * success, re-probe for clobbering introduced by the new value and
18099
+ * remove the element when found; otherwise pop the removal entry
18100
+ * recorded by the earlier _removeAttribute (long-standing pairing
18101
+ * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
18102
+ * failure, remove the attribute instead.
18103
+ *
18104
+ * @param currentNode the element carrying the attribute
18105
+ * @param name the attribute name as present on the element
18106
+ * @param namespaceURI the attribute's namespace, if any
18107
+ * @param value the new attribute value
18108
+ */
18109
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
18110
+ try {
18111
+ if (namespaceURI) {
18112
+ currentNode.setAttributeNS(namespaceURI, name, value);
18113
+ } else {
18114
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
18115
+ currentNode.setAttribute(name, value);
18116
+ }
18117
+ if (_isClobbered(currentNode)) {
18118
+ _forceRemove(currentNode);
18119
+ } else {
18120
+ arrayPop(DOMPurify.removed);
18121
+ }
18122
+ } catch (_) {
18123
+ _removeAttribute(name, currentNode);
18124
+ }
18125
+ };
17301
18126
  /**
17302
18127
  * _sanitizeAttributes
17303
18128
  *
@@ -17324,6 +18149,7 @@
17324
18149
  forceKeepAttr: undefined
17325
18150
  };
17326
18151
  let l = attributes.length;
18152
+ const lcTag = transformCaseFunc(currentNode.nodeName);
17327
18153
  /* Go backwards over all attributes; safely remove bad ones */
17328
18154
  while (l--) {
17329
18155
  const attr = attributes[l];
@@ -17361,7 +18187,7 @@
17361
18187
  _removeAttribute(name, currentNode);
17362
18188
  continue;
17363
18189
  }
17364
- /* Did the hooks approve of the attribute? */
18190
+ /* Did the hooks force-keep the attribute? */
17365
18191
  if (hookEvent.forceKeepAttr) {
17366
18192
  continue;
17367
18193
  }
@@ -17371,56 +18197,24 @@
17371
18197
  continue;
17372
18198
  }
17373
18199
  /* Work around a security issue in jQuery 3.0 */
17374
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
18200
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
17375
18201
  _removeAttribute(name, currentNode);
17376
18202
  continue;
17377
18203
  }
17378
18204
  /* Sanitize attribute content to be template-safe */
17379
18205
  if (SAFE_FOR_TEMPLATES) {
17380
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
17381
- value = stringReplace(value, expr, ' ');
17382
- });
18206
+ value = _stripTemplateExpressions(value);
17383
18207
  }
17384
18208
  /* Is `value` valid for this attribute? */
17385
- const lcTag = transformCaseFunc(currentNode.nodeName);
17386
18209
  if (!_isValidAttribute(lcTag, lcName, value)) {
17387
18210
  _removeAttribute(name, currentNode);
17388
18211
  continue;
17389
18212
  }
17390
18213
  /* Handle attributes that require Trusted Types */
17391
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
17392
- if (namespaceURI) ; else {
17393
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
17394
- case 'TrustedHTML':
17395
- {
17396
- value = trustedTypesPolicy.createHTML(value);
17397
- break;
17398
- }
17399
- case 'TrustedScriptURL':
17400
- {
17401
- value = trustedTypesPolicy.createScriptURL(value);
17402
- break;
17403
- }
17404
- }
17405
- }
17406
- }
18214
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
17407
18215
  /* Handle invalid data-* attribute set by try-catching it */
17408
18216
  if (value !== initValue) {
17409
- try {
17410
- if (namespaceURI) {
17411
- currentNode.setAttributeNS(namespaceURI, name, value);
17412
- } else {
17413
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
17414
- currentNode.setAttribute(name, value);
17415
- }
17416
- if (_isClobbered(currentNode)) {
17417
- _forceRemove(currentNode);
17418
- } else {
17419
- arrayPop(DOMPurify.removed);
17420
- }
17421
- } catch (_) {
17422
- _removeAttribute(name, currentNode);
17423
- }
18217
+ _setAttributeValue(currentNode, name, namespaceURI, value);
17424
18218
  }
17425
18219
  }
17426
18220
  /* Execute a hook if present */
@@ -17440,13 +18234,34 @@
17440
18234
  /* Execute a hook if present */
17441
18235
  _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
17442
18236
  /* Sanitize tags and elements */
17443
- _sanitizeElements(shadowNode);
18237
+ _sanitizeElements(shadowNode, fragment);
17444
18238
  /* Check attributes next */
17445
18239
  _sanitizeAttributes(shadowNode);
17446
- /* Deep shadow DOM detected */
17447
- if (shadowNode.content instanceof DocumentFragment) {
18240
+ /* Deep shadow DOM detected.
18241
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
18242
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
18243
+ recurse into <template>.content from foreign realms too. */
18244
+ if (_isDocumentFragment(shadowNode.content)) {
17448
18245
  _sanitizeShadowDOM2(shadowNode.content);
17449
18246
  }
18247
+ /* An element iterated here may itself host an attached
18248
+ shadow root. The default NodeIterator does not enter shadow
18249
+ trees, so a shadow root nested inside template.content was
18250
+ previously reached by no walk at all (the pre-pass at
18251
+ _sanitizeAttachedShadowRoots descends via childNodes, which
18252
+ doesn't enter template.content; the template-content recursion
18253
+ above iterates the content but never inspected shadowRoot).
18254
+ Walk it explicitly. The nodeType guard avoids reading
18255
+ shadowRoot off text / comment / CDATA / PI nodes that the
18256
+ iterator also surfaces. */
18257
+ const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
18258
+ if (shadowNodeType === NODE_TYPE.element) {
18259
+ const innerSr = getShadowRoot(shadowNode);
18260
+ if (_isDocumentFragment(innerSr)) {
18261
+ _sanitizeAttachedShadowRoots(innerSr);
18262
+ _sanitizeShadowDOM2(innerSr);
18263
+ }
18264
+ }
17450
18265
  }
17451
18266
  /* Execute a hook if present */
17452
18267
  _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
@@ -17470,28 +18285,83 @@
17470
18285
  *
17471
18286
  * @param root the subtree root to walk for attached shadow roots
17472
18287
  */
17473
- const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
17474
- if (root.nodeType === NODE_TYPE.element && root.shadowRoot instanceof DocumentFragment) {
17475
- const sr = root.shadowRoot;
17476
- // Recurse first so that nested shadow roots are reached even if
17477
- // _sanitizeShadowDOM removes hosts at this level.
17478
- _sanitizeAttachedShadowRoots2(sr);
17479
- _sanitizeShadowDOM2(sr);
17480
- }
17481
- // Snapshot children before recursing. Sanitization of one subtree
17482
- // (e.g. via an uponSanitizeShadowNode hook) may detach siblings,
17483
- // and naive nextSibling traversal would silently skip the rest of
17484
- // the list once a node is detached.
17485
- const childNodes = root.childNodes;
17486
- if (!childNodes) {
17487
- return;
17488
- }
17489
- const snapshot = [];
17490
- arrayForEach(childNodes, child => {
17491
- arrayPush(snapshot, child);
17492
- });
17493
- for (const child of snapshot) {
17494
- _sanitizeAttachedShadowRoots2(child);
18288
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
18289
+ /* Iterative (explicit stack) rather than per-child recursion. DOM APIs
18290
+ impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
18291
+ built straight into the DOM the IN_PLACE surface) deeper than the JS
18292
+ call-stack budget would otherwise overflow native recursion here and
18293
+ throw at the IN_PLACE entry pre-pass, before a single node is
18294
+ sanitized, leaving the caller's live tree untouched (fail-open). See
18295
+ campaign-3 F4. A heap stack keeps depth off the call stack.
18296
+ Each work item is either a node to descend into, or a deferred
18297
+ `_sanitizeShadowDOM` for an already-walked shadow root. The deferred
18298
+ form preserves the original post-order discipline: a shadow root's
18299
+ nested shadow roots are discovered before the outer shadow is
18300
+ sanitized (which may remove hosts). Pushes are in reverse of the
18301
+ desired processing order (LIFO): template content, then children, then
18302
+ the shadow-sanitize, then the shadow walk — so the order matches the
18303
+ previous recursion exactly. */
18304
+ const stack = [{
18305
+ node: root,
18306
+ shadow: null
18307
+ }];
18308
+ while (stack.length > 0) {
18309
+ const item = stack.pop();
18310
+ /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
18311
+ if (item.shadow) {
18312
+ _sanitizeShadowDOM2(item.shadow);
18313
+ continue;
18314
+ }
18315
+ const node = item.node;
18316
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
18317
+ const isElement = nodeType === NODE_TYPE.element;
18318
+ /* (pushed last → processed first) Children, snapshotted in reverse so
18319
+ the first child is processed first. Snapshotting matters because a
18320
+ hook may detach siblings mid-walk. */
18321
+ const childNodes = getChildNodes(node);
18322
+ if (childNodes) {
18323
+ for (let i = childNodes.length - 1; i >= 0; --i) {
18324
+ stack.push({
18325
+ node: childNodes[i],
18326
+ shadow: null
18327
+ });
18328
+ }
18329
+ }
18330
+ /* (pushed before children → processed after them, matching the old
18331
+ "template content last" order) When the node is a <template>,
18332
+ descend into its content. */
18333
+ if (isElement) {
18334
+ const rootName = getNodeName ? getNodeName(node) : null;
18335
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
18336
+ const content = node.content;
18337
+ if (_isDocumentFragment(content)) {
18338
+ stack.push({
18339
+ node: content,
18340
+ shadow: null
18341
+ });
18342
+ }
18343
+ }
18344
+ }
18345
+ /* Shadow root (processed first): walk its subtree, then sanitise it.
18346
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
18347
+ rather than `instanceof DocumentFragment`, which is realm-bound and
18348
+ silently skipped foreign-realm shadow roots (e.g.
18349
+ iframe.contentDocument attachShadow). */
18350
+ if (isElement) {
18351
+ const sr = getShadowRoot(node);
18352
+ if (_isDocumentFragment(sr)) {
18353
+ /* Push the deferred sanitise first so it pops after the shadow
18354
+ walk we push next, i.e. nested shadow roots are discovered
18355
+ before this one is sanitised. */
18356
+ stack.push({
18357
+ node: null,
18358
+ shadow: sr
18359
+ }, {
18360
+ node: sr,
18361
+ shadow: null
18362
+ });
18363
+ }
18364
+ }
17495
18365
  }
17496
18366
  };
17497
18367
  // eslint-disable-next-line complexity
@@ -17520,27 +18390,89 @@
17520
18390
  return dirty;
17521
18391
  }
17522
18392
  /* Assign config vars */
17523
- if (!SET_CONFIG) {
18393
+ if (SET_CONFIG) {
18394
+ /* Persistent setConfig() path: _parseConfig is skipped, so the sets are
18395
+ * not re-derived per call. Restore them from the pristine bindings
18396
+ * captured at setConfig() time so a previous call's hook clone (mutated
18397
+ * below) does not carry over. */
18398
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
18399
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
18400
+ } else {
17524
18401
  _parseConfig(cfg);
17525
18402
  }
18403
+ /* Clone the hook-mutable allowlists before the walk whenever an
18404
+ * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
18405
+ * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
18406
+ * a hook that widens them would otherwise mutate the shared set
18407
+ * permanently: across later calls and across every element. Cloning per
18408
+ * walk keeps documented in-call widening working while scoping it to the
18409
+ * call. A single guard for both config paths - the per-call path rebinds
18410
+ * the sets in _parseConfig each call, the persistent path restores them
18411
+ * from the captured bindings just above - so the two cannot diverge. */
18412
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
18413
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
18414
+ }
18415
+ if (hooks.uponSanitizeAttribute.length > 0) {
18416
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
18417
+ }
17526
18418
  /* Clean up removed elements */
17527
18419
  DOMPurify.removed = [];
17528
- /* Check if dirty is correctly typed for IN_PLACE */
17529
- if (typeof dirty === 'string') {
17530
- IN_PLACE = false;
17531
- }
17532
- if (IN_PLACE) {
17533
- /* Do some early pre-sanitization to avoid unsafe root nodes */
17534
- const nn = dirty.nodeName;
18420
+ /* Resolve IN_PLACE for this call without mutating persistent config.
18421
+ Writing the IN_PLACE closure variable here leaks under setConfig(),
18422
+ where _parseConfig is skipped on later calls: a single string call would
18423
+ disable in-place mode for every subsequent node call, returning a
18424
+ sanitized copy while leaving the caller's node — which in-place callers
18425
+ keep using and whose return value they ignore unsanitized. REPORT-2. */
18426
+ const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
18427
+ if (inPlace) {
18428
+ /* Declarative-partial-updates / streaming pre-pass: sever every patch
18429
+ linkage across the live tree BEFORE the walk, so no patch can fire
18430
+ mid-walk and inject into an already-processed region. Runs first, so
18431
+ it also covers the forbidden/clobbered roots that throw below. */
18432
+ _neutralizePatchLinkage(dirty);
18433
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
18434
+ Read nodeName through the cached prototype getter — a clobbering
18435
+ child named "nodeName" on the form root would otherwise shadow
18436
+ the property and let this check skip the root-allowlist
18437
+ validation entirely. */
18438
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
17535
18439
  if (typeof nn === 'string') {
17536
18440
  const tagName = transformCaseFunc(nn);
17537
18441
  if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
18442
+ /* Fail closed on a live root: neutralize handlers/children before
18443
+ throwing, exactly as the mid-walk abort path does. */
18444
+ _neutralizeRoot(dirty);
17538
18445
  throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
17539
18446
  }
17540
18447
  }
18448
+ /* Pre-flight the root through _isClobbered. The iterator-driven
18449
+ removal path can not detach a parent-less root: _forceRemove
18450
+ falls through to Element.prototype.remove(), which per spec
18451
+ is a no-op on a node with no parent. A clobbered root would
18452
+ then survive the main loop with its attributes uninspected,
18453
+ because _sanitizeAttributes early-returns on _isClobbered. The
18454
+ result would be an attacker-controlled form, complete with any
18455
+ event-handler attributes the caller passed in, handed back to
18456
+ the application unsanitized. Refuse to sanitize such a root
18457
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
18458
+ if (_isClobbered(dirty)) {
18459
+ /* Fail closed on a live clobbered root before throwing.
18460
+ _neutralizeRoot's reads are clobber-safe (cached getters); the
18461
+ form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */
18462
+ _neutralizeRoot(dirty);
18463
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
18464
+ }
17541
18465
  /* Sanitize attached shadow roots before the main iterator runs.
17542
- The iterator does not descend into shadow trees. */
17543
- _sanitizeAttachedShadowRoots2(dirty);
18466
+ The iterator does not descend into shadow trees. Same fail-closed
18467
+ barrier as the main walk (campaign-3 F2): a custom-element reaction
18468
+ inside a shadow root could abort this pre-pass before the walk runs,
18469
+ which would otherwise leave the entire live tree unsanitized. */
18470
+ try {
18471
+ _sanitizeAttachedShadowRoots(dirty);
18472
+ } catch (error) {
18473
+ _neutralizeRoot(dirty);
18474
+ throw error;
18475
+ }
17544
18476
  } else if (_isNode(dirty)) {
17545
18477
  /* If dirty is a DOM element, append to an empty document to avoid
17546
18478
  elements being stripped by the parser */
@@ -17557,14 +18489,16 @@
17557
18489
  }
17558
18490
  /* Clonable shadow roots are deep-cloned by importNode(); sanitize
17559
18491
  them before the main iterator runs, since the iterator does not
17560
- descend into shadow trees. */
17561
- _sanitizeAttachedShadowRoots2(importedNode);
18492
+ descend into shadow trees. The walk routes every read through a
18493
+ cached prototype getter so clobbering descendants on a form root
18494
+ cannot hide a shadow host from this pass. */
18495
+ _sanitizeAttachedShadowRoots(importedNode);
17562
18496
  } else {
17563
18497
  /* Exit directly if we have nothing to do */
17564
18498
  if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
17565
18499
  // eslint-disable-next-line unicorn/prefer-includes
17566
18500
  dirty.indexOf('<') === -1) {
17567
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
18501
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
17568
18502
  }
17569
18503
  /* Initialize the document to work on */
17570
18504
  body = _initDocument(dirty);
@@ -17578,29 +18512,68 @@
17578
18512
  _forceRemove(body.firstChild);
17579
18513
  }
17580
18514
  /* Get node iterator */
17581
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
17582
- /* Now start iterating over the created document */
17583
- while (currentNode = nodeIterator.nextNode()) {
17584
- /* Sanitize tags and elements */
17585
- _sanitizeElements(currentNode);
17586
- /* Check attributes next */
17587
- _sanitizeAttributes(currentNode);
17588
- /* Shadow DOM detected, sanitize it */
17589
- if (currentNode.content instanceof DocumentFragment) {
17590
- _sanitizeShadowDOM2(currentNode.content);
18515
+ const walkRoot = inPlace ? dirty : body;
18516
+ const nodeIterator = _createNodeIterator(walkRoot);
18517
+ /* Now start iterating over the created document.
18518
+ The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
18519
+ engine/custom-element mutation can detach a node mid-walk so
18520
+ `_forceRemove`'s parentless guard throws, aborting the loop. Without the
18521
+ barrier the caller's in-place tree would be left half-sanitized with the
18522
+ unvisited tail still armed. On any throw we fail closed — strip the
18523
+ in-place root bare then rethrow so the existing throw contract is
18524
+ preserved. (String/DOM-copy paths never return the partial body, so the
18525
+ propagating throw is already fail-closed there.) */
18526
+ try {
18527
+ while (currentNode = nodeIterator.nextNode()) {
18528
+ /* Sanitize tags and elements */
18529
+ _sanitizeElements(currentNode, walkRoot);
18530
+ /* Check attributes next */
18531
+ _sanitizeAttributes(currentNode);
18532
+ /* Shadow DOM detected, sanitize it.
18533
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
18534
+ instead of instanceof, so foreign-realm <template>.content is
18535
+ walked correctly. */
18536
+ if (_isDocumentFragment(currentNode.content)) {
18537
+ _sanitizeShadowDOM2(currentNode.content);
18538
+ }
17591
18539
  }
18540
+ } catch (error) {
18541
+ if (inPlace) {
18542
+ _neutralizeRoot(dirty);
18543
+ /* Nodes _forceRemove'd earlier in the aborted walk are already
18544
+ detached from the root, so _neutralizeRoot's subtree pass does not
18545
+ reach them. Defuse them too, mirroring the success-path loop below. */
18546
+ arrayForEach(DOMPurify.removed, entry => {
18547
+ if (entry.element) {
18548
+ _neutralizeSubtree(entry.element);
18549
+ }
18550
+ });
18551
+ }
18552
+ throw error;
17592
18553
  }
17593
18554
  /* If we sanitized `dirty` in-place, return it. */
17594
- if (IN_PLACE) {
18555
+ if (inPlace) {
18556
+ /* Fail-closed completion of the audit-5 F1 fix: every node removed from
18557
+ the caller's live tree is detached but may still hold a queued
18558
+ resource-event handler that fires in page scope after we return. The
18559
+ move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
18560
+ non-allow-listed attributes off every other removed subtree (clobber,
18561
+ mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
18562
+ cancelled before any event can fire. Runs synchronously, pre-return. */
18563
+ arrayForEach(DOMPurify.removed, entry => {
18564
+ if (entry.element) {
18565
+ _neutralizeSubtree(entry.element);
18566
+ }
18567
+ });
17595
18568
  if (SAFE_FOR_TEMPLATES) {
17596
- _scrubTemplateExpressions(dirty);
18569
+ _scrubTemplateExpressions2(dirty);
17597
18570
  }
17598
18571
  return dirty;
17599
18572
  }
17600
18573
  /* Return sanitized string or DOM */
17601
18574
  if (RETURN_DOM) {
17602
18575
  if (SAFE_FOR_TEMPLATES) {
17603
- _scrubTemplateExpressions(body);
18576
+ _scrubTemplateExpressions2(body);
17604
18577
  }
17605
18578
  if (RETURN_DOM_FRAGMENT) {
17606
18579
  returnNode = createDocumentFragment.call(body.ownerDocument);
@@ -17630,20 +18603,28 @@
17630
18603
  }
17631
18604
  /* Sanitize final string template-safe */
17632
18605
  if (SAFE_FOR_TEMPLATES) {
17633
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
17634
- serializedHTML = stringReplace(serializedHTML, expr, ' ');
17635
- });
18606
+ serializedHTML = _stripTemplateExpressions(serializedHTML);
17636
18607
  }
17637
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
18608
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
17638
18609
  };
17639
18610
  DOMPurify.setConfig = function () {
17640
18611
  let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17641
18612
  _parseConfig(cfg);
17642
18613
  SET_CONFIG = true;
18614
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
18615
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
17643
18616
  };
17644
18617
  DOMPurify.clearConfig = function () {
17645
18618
  CONFIG = null;
17646
18619
  SET_CONFIG = false;
18620
+ SET_CONFIG_ALLOWED_TAGS = null;
18621
+ SET_CONFIG_ALLOWED_ATTR = null;
18622
+ // Drop any caller-supplied Trusted Types policy so it cannot poison later
18623
+ // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
18624
+ // never recreated — Trusted Types throws on duplicate names) is restored by
18625
+ // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
18626
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
18627
+ emptyHTML = '';
17647
18628
  };
17648
18629
  DOMPurify.isValidAttribute = function (tag, attr, value) {
17649
18630
  /* Initialize shared config vars if necessary. */
@@ -17658,9 +18639,19 @@
17658
18639
  if (typeof hookFunction !== 'function') {
17659
18640
  return;
17660
18641
  }
18642
+ /* Reject unknown entry points. Without this, a non-hook key (e.g.
18643
+ * '__proto__') indexes off the prototype chain rather than a real
18644
+ * hook array, and arrayPush then writes to Object.prototype. Guard
18645
+ * with an own-property check against the known hook names. */
18646
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
18647
+ return;
18648
+ }
17661
18649
  arrayPush(hooks[entryPoint], hookFunction);
17662
18650
  };
17663
18651
  DOMPurify.removeHook = function (entryPoint, hookFunction) {
18652
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
18653
+ return undefined;
18654
+ }
17664
18655
  if (hookFunction !== undefined) {
17665
18656
  const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
17666
18657
  return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
@@ -17668,6 +18659,9 @@
17668
18659
  return arrayPop(hooks[entryPoint]);
17669
18660
  };
17670
18661
  DOMPurify.removeHooks = function (entryPoint) {
18662
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
18663
+ return;
18664
+ }
17671
18665
  hooks[entryPoint] = [];
17672
18666
  };
17673
18667
  DOMPurify.removeAllHooks = function () {
@@ -19149,7 +20143,8 @@
19149
20143
  ];
19150
20144
  const tabPanelFields = [
19151
20145
  type,
19152
- requiredArrayOfObj('tabs', tabFields)
20146
+ requiredArrayOfObj('tabs', tabFields),
20147
+ defaultedBoolean('dynamicHeight', false)
19153
20148
  ];
19154
20149
  const tabPanelSchema = objOf(tabPanelFields);
19155
20150
 
@@ -20155,58 +21150,6 @@
20155
21150
  }, structure, itemResponse, sharedBackstage.providers);
20156
21151
  };
20157
21152
 
20158
- const render$2 = (items, extras) => map$2(items, (item) => {
20159
- switch (item.type) {
20160
- case 'cardcontainer':
20161
- return renderContainer(item, render$2(item.items, extras));
20162
- case 'cardimage':
20163
- return renderImage(item.src, item.classes, item.alt);
20164
- case 'cardtext':
20165
- // Only highlight targeted text components
20166
- const shouldHighlight = item.name.exists((name) => contains$2(extras.cardText.highlightOn, name));
20167
- const matchText = shouldHighlight ? Optional.from(extras.cardText.matchText).getOr('') : '';
20168
- return renderHtml(replaceText(item.text, matchText), item.classes);
20169
- }
20170
- });
20171
- const renderCardMenuItem = (spec, itemResponse, sharedBackstage, extras) => {
20172
- const getApi = (component) => ({
20173
- isEnabled: () => !Disabling.isDisabled(component),
20174
- setEnabled: (state) => {
20175
- Disabling.set(component, !state);
20176
- // Disable sub components
20177
- each$1(descendants(component.element, '*'), (elm) => {
20178
- component.getSystem().getByDom(elm).each((comp) => {
20179
- if (comp.hasConfigured(Disabling)) {
20180
- Disabling.set(comp, !state);
20181
- }
20182
- });
20183
- });
20184
- }
20185
- });
20186
- const structure = {
20187
- dom: renderItemDomStructure(spec.label, []),
20188
- optComponents: [
20189
- Optional.some({
20190
- dom: {
20191
- tag: 'div',
20192
- classes: [containerClass, containerRowClass]
20193
- },
20194
- components: render$2(spec.items, extras)
20195
- })
20196
- ]
20197
- };
20198
- return renderCommonItem({
20199
- context: 'mode:design',
20200
- data: buildData({ text: Optional.none(), ...spec }),
20201
- enabled: spec.enabled,
20202
- getApi,
20203
- onAction: spec.onAction,
20204
- onSetup: spec.onSetup,
20205
- triggersSubmenu: false,
20206
- itemBehaviours: Optional.from(extras.itemBehaviours).getOr([])
20207
- }, structure, itemResponse, sharedBackstage.providers);
20208
- };
20209
-
20210
21153
  const renderChoiceItem = (spec, useText, presets, onItemValueHandler, isSelected, itemResponse, providersBackstage, renderIcons = true) => {
20211
21154
  const getApi = (component) => ({
20212
21155
  setActive: (state) => {
@@ -20260,6 +21203,125 @@
20260
21203
  });
20261
21204
  };
20262
21205
 
21206
+ const renderSeparatorItem = (spec) => ({
21207
+ type: 'separator',
21208
+ dom: {
21209
+ tag: 'div',
21210
+ classes: [selectableClass, groupHeadingClass]
21211
+ },
21212
+ components: spec.text.map(text$2).toArray()
21213
+ });
21214
+
21215
+ // Note, this does not create a valid SketchSpec.
21216
+ const renderNormalItem = (spec, itemResponse, providersBackstage, renderIcons = true) => {
21217
+ const getApi = (component) => ({
21218
+ isEnabled: () => !Disabling.isDisabled(component),
21219
+ setEnabled: (state) => Disabling.set(component, !state)
21220
+ });
21221
+ const structure = renderItemStructure({
21222
+ presets: 'normal',
21223
+ iconContent: spec.icon,
21224
+ textContent: spec.text,
21225
+ htmlContent: Optional.none(),
21226
+ labelContent: Optional.none(),
21227
+ ariaLabel: spec.text,
21228
+ caret: Optional.none(),
21229
+ checkMark: Optional.none(),
21230
+ shortcutContent: spec.shortcut
21231
+ }, providersBackstage, renderIcons);
21232
+ return renderCommonItem({
21233
+ context: spec.context,
21234
+ data: buildData(spec),
21235
+ getApi,
21236
+ enabled: spec.enabled,
21237
+ onAction: spec.onAction,
21238
+ onSetup: spec.onSetup,
21239
+ triggersSubmenu: false,
21240
+ itemBehaviours: []
21241
+ }, structure, itemResponse, providersBackstage);
21242
+ };
21243
+
21244
+ // Note, this does not create a valid SketchSpec.
21245
+ const renderNestedItem = (spec, itemResponse, providersBackstage, renderIcons = true, downwardsCaret = false) => {
21246
+ const caret = downwardsCaret ? renderDownwardsCaret(providersBackstage.icons) : renderSubmenuCaret(providersBackstage.icons);
21247
+ const getApi = (component) => ({
21248
+ isEnabled: () => !Disabling.isDisabled(component),
21249
+ setEnabled: (state) => Disabling.set(component, !state),
21250
+ setIconFill: (id, value) => {
21251
+ descendant(component.element, `svg path[class="${id}"], rect[class="${id}"]`).each((underlinePath) => {
21252
+ set$9(underlinePath, 'fill', value);
21253
+ });
21254
+ },
21255
+ setTooltip: (tooltip) => {
21256
+ const translatedTooltip = providersBackstage.translate(tooltip);
21257
+ set$9(component.element, 'aria-label', translatedTooltip);
21258
+ }
21259
+ });
21260
+ const structure = renderItemStructure({
21261
+ presets: 'normal',
21262
+ iconContent: spec.icon,
21263
+ textContent: spec.text,
21264
+ htmlContent: Optional.none(),
21265
+ ariaLabel: spec.text,
21266
+ labelContent: Optional.none(),
21267
+ caret: Optional.some(caret),
21268
+ checkMark: Optional.none(),
21269
+ shortcutContent: spec.shortcut
21270
+ }, providersBackstage, renderIcons);
21271
+ return renderCommonItem({
21272
+ context: spec.context,
21273
+ data: buildData(spec),
21274
+ getApi,
21275
+ enabled: spec.enabled,
21276
+ onAction: noop,
21277
+ onSetup: spec.onSetup,
21278
+ triggersSubmenu: true,
21279
+ itemBehaviours: []
21280
+ }, structure, itemResponse, providersBackstage);
21281
+ };
21282
+
21283
+ const renderToggleMenuItem = (spec, itemResponse, providersBackstage, renderIcons = true) => {
21284
+ const getApi = (component) => ({
21285
+ setActive: (state) => {
21286
+ Toggling.set(component, state);
21287
+ },
21288
+ isActive: () => Toggling.isOn(component),
21289
+ isEnabled: () => !Disabling.isDisabled(component),
21290
+ setEnabled: (state) => Disabling.set(component, !state)
21291
+ });
21292
+ // BespokeSelects use meta to pass through styling information. Bespokes should only
21293
+ // be togglemenuitems hence meta is only passed through in this MenuItem.
21294
+ const structure = renderItemStructure({
21295
+ iconContent: spec.icon,
21296
+ textContent: spec.text,
21297
+ htmlContent: Optional.none(),
21298
+ labelContent: Optional.none(),
21299
+ ariaLabel: spec.text,
21300
+ checkMark: Optional.some(renderCheckmark(providersBackstage.icons)),
21301
+ caret: Optional.none(),
21302
+ shortcutContent: spec.shortcut,
21303
+ presets: 'normal',
21304
+ meta: spec.meta
21305
+ }, providersBackstage, renderIcons);
21306
+ return deepMerge(renderCommonItem({
21307
+ context: spec.context,
21308
+ data: buildData(spec),
21309
+ enabled: spec.enabled,
21310
+ getApi,
21311
+ onAction: spec.onAction,
21312
+ onSetup: spec.onSetup,
21313
+ triggersSubmenu: false,
21314
+ itemBehaviours: []
21315
+ }, structure, itemResponse, providersBackstage), {
21316
+ toggling: {
21317
+ toggleClass: tickedClass,
21318
+ toggleOnExecute: false,
21319
+ selected: spec.active
21320
+ },
21321
+ role: spec.role.getOrUndefined()
21322
+ });
21323
+ };
21324
+
20263
21325
  const hexColour = (value) => ({
20264
21326
  value: normalizeHex(value)
20265
21327
  });
@@ -21080,7 +22142,7 @@
21080
22142
  const deriveMenuMovement = (columns, presets) => {
21081
22143
  const menuMarkers = markers(presets);
21082
22144
  if (columns === 1) {
21083
- return { mode: 'menu', moveOnTab: true };
22145
+ return { mode: 'menu' };
21084
22146
  }
21085
22147
  else if (columns === 'auto') {
21086
22148
  return {
@@ -21115,7 +22177,6 @@
21115
22177
  if (columns === 1) {
21116
22178
  return {
21117
22179
  mode: 'menu',
21118
- moveOnTab: false,
21119
22180
  selector: '.tox-collection__item'
21120
22181
  };
21121
22182
  }
@@ -21321,133 +22382,58 @@
21321
22382
  };
21322
22383
  const renderFancyMenuItem = (spec, backstage) => get$h(fancyMenuItems, spec.fancytype).map((render) => render(spec, backstage));
21323
22384
 
21324
- // Note, this does not create a valid SketchSpec.
21325
- const renderNestedItem = (spec, itemResponse, providersBackstage, renderIcons = true, downwardsCaret = false) => {
21326
- const caret = downwardsCaret ? renderDownwardsCaret(providersBackstage.icons) : renderSubmenuCaret(providersBackstage.icons);
22385
+ const render$2 = (items, extras) => map$2(items, (item) => {
22386
+ switch (item.type) {
22387
+ case 'cardcontainer':
22388
+ return renderContainer(item, render$2(item.items, extras));
22389
+ case 'cardimage':
22390
+ return renderImage(item.src, item.classes, item.alt);
22391
+ case 'cardtext':
22392
+ // Only highlight targeted text components
22393
+ const shouldHighlight = item.name.exists((name) => contains$2(extras.cardText.highlightOn, name));
22394
+ const matchText = shouldHighlight ? Optional.from(extras.cardText.matchText).getOr('') : '';
22395
+ return renderHtml(replaceText(item.text, matchText), item.classes);
22396
+ }
22397
+ });
22398
+ const renderCardMenuItem = (spec, itemResponse, sharedBackstage, extras) => {
21327
22399
  const getApi = (component) => ({
21328
22400
  isEnabled: () => !Disabling.isDisabled(component),
21329
- setEnabled: (state) => Disabling.set(component, !state),
21330
- setIconFill: (id, value) => {
21331
- descendant(component.element, `svg path[class="${id}"], rect[class="${id}"]`).each((underlinePath) => {
21332
- set$9(underlinePath, 'fill', value);
22401
+ setEnabled: (state) => {
22402
+ Disabling.set(component, !state);
22403
+ // Disable sub components
22404
+ each$1(descendants(component.element, '*'), (elm) => {
22405
+ component.getSystem().getByDom(elm).each((comp) => {
22406
+ if (comp.hasConfigured(Disabling)) {
22407
+ Disabling.set(comp, !state);
22408
+ }
22409
+ });
21333
22410
  });
21334
- },
21335
- setTooltip: (tooltip) => {
21336
- const translatedTooltip = providersBackstage.translate(tooltip);
21337
- set$9(component.element, 'aria-label', translatedTooltip);
21338
22411
  }
21339
22412
  });
21340
- const structure = renderItemStructure({
21341
- presets: 'normal',
21342
- iconContent: spec.icon,
21343
- textContent: spec.text,
21344
- htmlContent: Optional.none(),
21345
- ariaLabel: spec.text,
21346
- labelContent: Optional.none(),
21347
- caret: Optional.some(caret),
21348
- checkMark: Optional.none(),
21349
- shortcutContent: spec.shortcut
21350
- }, providersBackstage, renderIcons);
21351
- return renderCommonItem({
21352
- context: spec.context,
21353
- data: buildData(spec),
21354
- getApi,
21355
- enabled: spec.enabled,
21356
- onAction: noop,
21357
- onSetup: spec.onSetup,
21358
- triggersSubmenu: true,
21359
- itemBehaviours: []
21360
- }, structure, itemResponse, providersBackstage);
21361
- };
21362
-
21363
- // Note, this does not create a valid SketchSpec.
21364
- const renderNormalItem = (spec, itemResponse, providersBackstage, renderIcons = true) => {
21365
- const getApi = (component) => ({
21366
- isEnabled: () => !Disabling.isDisabled(component),
21367
- setEnabled: (state) => Disabling.set(component, !state)
21368
- });
21369
- const structure = renderItemStructure({
21370
- presets: 'normal',
21371
- iconContent: spec.icon,
21372
- textContent: spec.text,
21373
- htmlContent: Optional.none(),
21374
- labelContent: Optional.none(),
21375
- ariaLabel: spec.text,
21376
- caret: Optional.none(),
21377
- checkMark: Optional.none(),
21378
- shortcutContent: spec.shortcut
21379
- }, providersBackstage, renderIcons);
22413
+ const structure = {
22414
+ dom: renderItemDomStructure(spec.label, []),
22415
+ optComponents: [
22416
+ Optional.some({
22417
+ dom: {
22418
+ tag: 'div',
22419
+ classes: [containerClass, containerRowClass]
22420
+ },
22421
+ components: render$2(spec.items, extras)
22422
+ })
22423
+ ]
22424
+ };
21380
22425
  return renderCommonItem({
21381
- context: spec.context,
21382
- data: buildData(spec),
21383
- getApi,
21384
- enabled: spec.enabled,
21385
- onAction: spec.onAction,
21386
- onSetup: spec.onSetup,
21387
- triggersSubmenu: false,
21388
- itemBehaviours: []
21389
- }, structure, itemResponse, providersBackstage);
21390
- };
21391
-
21392
- const renderSeparatorItem = (spec) => ({
21393
- type: 'separator',
21394
- dom: {
21395
- tag: 'div',
21396
- classes: [selectableClass, groupHeadingClass]
21397
- },
21398
- components: spec.text.map(text$2).toArray()
21399
- });
21400
-
21401
- const renderToggleMenuItem = (spec, itemResponse, providersBackstage, renderIcons = true) => {
21402
- const getApi = (component) => ({
21403
- setActive: (state) => {
21404
- Toggling.set(component, state);
21405
- },
21406
- isActive: () => Toggling.isOn(component),
21407
- isEnabled: () => !Disabling.isDisabled(component),
21408
- setEnabled: (state) => Disabling.set(component, !state)
21409
- });
21410
- // BespokeSelects use meta to pass through styling information. Bespokes should only
21411
- // be togglemenuitems hence meta is only passed through in this MenuItem.
21412
- const structure = renderItemStructure({
21413
- iconContent: spec.icon,
21414
- textContent: spec.text,
21415
- htmlContent: Optional.none(),
21416
- labelContent: Optional.none(),
21417
- ariaLabel: spec.text,
21418
- checkMark: Optional.some(renderCheckmark(providersBackstage.icons)),
21419
- caret: Optional.none(),
21420
- shortcutContent: spec.shortcut,
21421
- presets: 'normal',
21422
- meta: spec.meta
21423
- }, providersBackstage, renderIcons);
21424
- return deepMerge(renderCommonItem({
21425
- context: spec.context,
21426
- data: buildData(spec),
22426
+ context: 'mode:design',
22427
+ data: buildData({ text: Optional.none(), ...spec }),
21427
22428
  enabled: spec.enabled,
21428
22429
  getApi,
21429
22430
  onAction: spec.onAction,
21430
22431
  onSetup: spec.onSetup,
21431
22432
  triggersSubmenu: false,
21432
- itemBehaviours: []
21433
- }, structure, itemResponse, providersBackstage), {
21434
- toggling: {
21435
- toggleClass: tickedClass,
21436
- toggleOnExecute: false,
21437
- selected: spec.active
21438
- },
21439
- role: spec.role.getOrUndefined()
21440
- });
22433
+ itemBehaviours: Optional.from(extras.itemBehaviours).getOr([])
22434
+ }, structure, itemResponse, sharedBackstage.providers);
21441
22435
  };
21442
22436
 
21443
- const autocomplete = renderAutocompleteItem;
21444
- const separator$3 = renderSeparatorItem;
21445
- const normal = renderNormalItem;
21446
- const nested = renderNestedItem;
21447
- const toggle = renderToggleMenuItem;
21448
- const fancy = renderFancyMenuItem;
21449
- const card = renderCardMenuItem;
21450
-
21451
22437
  const identifyMenuLayout = (searchMode) => {
21452
22438
  switch (searchMode.searchMode) {
21453
22439
  case 'no-search': {
@@ -21564,17 +22550,17 @@
21564
22550
  });
21565
22551
  switch (item.type) {
21566
22552
  case 'menuitem':
21567
- return createMenuItem(item).fold(handleError, (d) => Optional.some(normal(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons)));
22553
+ return createMenuItem(item).fold(handleError, (d) => Optional.some(renderNormalItem(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons)));
21568
22554
  case 'nestedmenuitem':
21569
- return createNestedMenuItem(item).fold(handleError, (d) => Optional.some(nested(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons, isHorizontalMenu)));
22555
+ return createNestedMenuItem(item).fold(handleError, (d) => Optional.some(renderNestedItem(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons, isHorizontalMenu)));
21570
22556
  case 'togglemenuitem':
21571
- return createToggleMenuItem(item).fold(handleError, (d) => Optional.some(toggle(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons)));
22557
+ return createToggleMenuItem(item).fold(handleError, (d) => Optional.some(renderToggleMenuItem(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons)));
21572
22558
  case 'separator':
21573
- return createSeparatorMenuItem(item).fold(handleError, (d) => Optional.some(separator$3(d)));
22559
+ return createSeparatorMenuItem(item).fold(handleError, (d) => Optional.some(renderSeparatorItem(d)));
21574
22560
  case 'fancymenuitem':
21575
22561
  return createFancyMenuItem(item).fold(handleError,
21576
22562
  // Fancy menu items don't have shortcuts or icons
21577
- (d) => fancy(d, backstage));
22563
+ (d) => renderFancyMenuItem(d, backstage));
21578
22564
  default: {
21579
22565
  // eslint-disable-next-line no-console
21580
22566
  console.error('Unknown item in general menu', item);
@@ -21589,9 +22575,9 @@
21589
22575
  return cat(map$2(items, (item) => {
21590
22576
  switch (item.type) {
21591
22577
  case 'separator':
21592
- return createSeparatorItem(item).fold(handleError, (d) => Optional.some(separator$3(d)));
22578
+ return createSeparatorItem(item).fold(handleError, (d) => Optional.some(renderSeparatorItem(d)));
21593
22579
  case 'cardmenuitem':
21594
- return createCardMenuItem(item).fold(handleError, (d) => Optional.some(card({
22580
+ return createCardMenuItem(item).fold(handleError, (d) => Optional.some(renderCardMenuItem({
21595
22581
  ...d,
21596
22582
  // Intercept action
21597
22583
  onAction: (api) => {
@@ -21607,7 +22593,7 @@
21607
22593
  })));
21608
22594
  case 'autocompleteitem':
21609
22595
  default:
21610
- return createAutocompleterItem(item).fold(handleError, (d) => Optional.some(autocomplete(d, matchText, renderText, 'normal', onItemValueHandler, itemResponse, sharedBackstage, renderIcons)));
22596
+ return createAutocompleterItem(item).fold(handleError, (d) => Optional.some(renderAutocompleteItem(d, matchText, renderText, 'normal', onItemValueHandler, itemResponse, sharedBackstage, renderIcons)));
21611
22597
  }
21612
22598
  }));
21613
22599
  };
@@ -23672,7 +24658,7 @@
23672
24658
  Keying.config({
23673
24659
  mode: 'special',
23674
24660
  onLeft: onLeftOrRightInMenu,
23675
- onRight: onLeftOrRightInMenu
24661
+ onRight: onLeftOrRightInMenu,
23676
24662
  }),
23677
24663
  config('dropdown-sandbox-events', [
23678
24664
  run$1(refetchTriggerEvent, (originalSandboxComp, se) => {
@@ -30957,8 +31943,8 @@
30957
31943
  return {
30958
31944
  bubble: nu$6(bubbleSize$1, 0, bubbleAlignments$1),
30959
31945
  layouts: {
30960
- onLtr: () => [east$2],
30961
- onRtl: () => [west$2]
31946
+ onLtr: () => [east$2, west$2],
31947
+ onRtl: () => [west$2, east$2]
30962
31948
  },
30963
31949
  overrides: anchorOverrides
30964
31950
  };
@@ -32532,6 +33518,7 @@
32532
33518
  return dimensions;
32533
33519
  };
32534
33520
 
33521
+ const keyboardResizeStepInPx = 20;
32535
33522
  const getResizeType = (editor) => {
32536
33523
  const resize = getResize(editor);
32537
33524
  if (resize === false) {
@@ -32549,14 +33536,22 @@
32549
33536
  ? global$6.translate([`Editor's height: {0} pixels, Editor's width: {1} pixels`, dimensions.height, dimensions.width])
32550
33537
  : global$6.translate([`Editor's height: {0} pixels`, dimensions.height]);
32551
33538
  };
32552
- const setAriaValuetext = (comp, dimensions, resizeType) => {
33539
+ const setAriaDimensions = (comp, dimensions, resizeType, minHeight, maxHeight) => {
32553
33540
  set$9(comp.element, 'aria-valuetext', getAriaValuetext(dimensions, resizeType));
32554
- };
32555
- const keyboardHandler = (editor, comp, resizeType, x, y) => {
32556
- const scale = 20;
32557
- const delta = SugarPosition(x * scale, y * scale);
33541
+ // aria-valuenow/valuemin/valuemax are single numeric values, so they can only
33542
+ // meaningfully represent one dimension. In 'both' mode the handle resizes both
33543
+ // width and height, which has no sensible single-value representation, so we only
33544
+ // set these attributes for vertical resizing and rely on aria-valuetext otherwise.
33545
+ if (resizeType === ResizeTypes.Vertical) {
33546
+ set$9(comp.element, 'aria-valuenow', dimensions.height);
33547
+ set$9(comp.element, 'aria-valuemin', minHeight.getOr(0));
33548
+ set$9(comp.element, 'aria-valuemax', maxHeight.getOr(dimensions.height + keyboardResizeStepInPx));
33549
+ }
33550
+ };
33551
+ const keyboardHandler = (editor, comp, resizeType, x, y, minHeight, maxHeight) => {
33552
+ const delta = SugarPosition(x * keyboardResizeStepInPx, y * keyboardResizeStepInPx);
32558
33553
  const newDimentions = resize(editor, delta, resizeType);
32559
- setAriaValuetext(comp, newDimentions, resizeType);
33554
+ setAriaDimensions(comp, newDimentions, resizeType, minHeight, maxHeight);
32560
33555
  return Optional.some(true);
32561
33556
  };
32562
33557
  const renderResizeHandler = (editor, providersBackstage) => {
@@ -32564,6 +33559,8 @@
32564
33559
  if (resizeType === ResizeTypes.None) {
32565
33560
  return Optional.none();
32566
33561
  }
33562
+ const minHeight = getMinHeightOption(editor);
33563
+ const maxHeight = getMaxHeightOption(editor);
32567
33564
  const resizeLabel = resizeType === ResizeTypes.Both
32568
33565
  ? global$6.translate('Press the arrow keys to resize the editor.')
32569
33566
  : global$6.translate('Press the Up and Down arrow keys to resize the editor.');
@@ -32580,20 +33577,26 @@
32580
33577
  },
32581
33578
  behaviours: [
32582
33579
  Dragging.config({
32583
- mode: 'mouse',
33580
+ mode: 'pointer',
32584
33581
  repositionTarget: false,
33582
+ onDragStart: (comp) => {
33583
+ Tooltipping.immediateOpenClose(comp, false);
33584
+ Tooltipping.setEnabled(comp, false);
33585
+ },
32585
33586
  onDrag: (comp, _target, delta) => {
32586
33587
  const newDimentions = resize(editor, delta, resizeType);
32587
- setAriaValuetext(comp, newDimentions, resizeType);
33588
+ setAriaDimensions(comp, newDimentions, resizeType, minHeight, maxHeight);
33589
+ },
33590
+ onDrop: (comp) => {
33591
+ Tooltipping.setEnabled(comp, true);
32588
33592
  },
32589
- blockerClass: 'tox-blocker'
32590
33593
  }),
32591
33594
  Keying.config({
32592
33595
  mode: 'special',
32593
- onLeft: (comp) => keyboardHandler(editor, comp, resizeType, -1, 0),
32594
- onRight: (comp) => keyboardHandler(editor, comp, resizeType, 1, 0),
32595
- onUp: (comp) => keyboardHandler(editor, comp, resizeType, 0, -1),
32596
- onDown: (comp) => keyboardHandler(editor, comp, resizeType, 0, 1),
33596
+ onLeft: (comp) => keyboardHandler(editor, comp, resizeType, -1, 0, minHeight, maxHeight),
33597
+ onRight: (comp) => keyboardHandler(editor, comp, resizeType, 1, 0, minHeight, maxHeight),
33598
+ onUp: (comp) => keyboardHandler(editor, comp, resizeType, 0, -1, minHeight, maxHeight),
33599
+ onDown: (comp) => keyboardHandler(editor, comp, resizeType, 0, 1, minHeight, maxHeight),
32597
33600
  }),
32598
33601
  Tabstopping.config({}),
32599
33602
  Focusing.config({}),
@@ -32603,7 +33606,7 @@
32603
33606
  config('set-aria-valuetext', [
32604
33607
  runOnAttached((comp) => {
32605
33608
  const setInitialValuetext = () => {
32606
- setAriaValuetext(comp, getOriginalDimensions(editor), resizeType);
33609
+ setAriaDimensions(comp, getOriginalDimensions(editor), resizeType, minHeight, maxHeight);
32607
33610
  };
32608
33611
  if (editor._skinLoaded) {
32609
33612
  setInitialValuetext();
@@ -32941,6 +33944,14 @@
32941
33944
  ]
32942
33945
  };
32943
33946
  };
33947
+ // TINY-14384: we want to restrict the bounds to the host element, rather than the entire window when the sink is attached in a ShadowDOM (ie: webcomponent)
33948
+ const getSinkBounds = (sinkOpt) => sinkOpt.bind(({ sink }) => {
33949
+ const rootNode = getRootNode(sink.element);
33950
+ if (isShadowRoot(rootNode)) {
33951
+ return Optional.some(box$1(getShadowHost(rootNode)));
33952
+ }
33953
+ return Optional.none();
33954
+ }).getOr(win());
32944
33955
  const renderDialogUi = () => {
32945
33956
  const uiContainer = getUiContainer(editor);
32946
33957
  // TINY-3321: When the body is using a grid layout, we need to ensure the sink width is manually set
@@ -32955,8 +33966,9 @@
32955
33966
  },
32956
33967
  behaviours: derive$1([
32957
33968
  Positioning.config({
32958
- useFixed: () => header.isDocked(lazyHeader)
32959
- })
33969
+ useFixed: () => header.isDocked(lazyHeader),
33970
+ getBounds: () => getSinkBounds(lazyUiRefs.dialogUi.get())
33971
+ }),
32960
33972
  ])
32961
33973
  };
32962
33974
  const reactiveWidthSpec = {
@@ -33379,6 +34391,15 @@
33379
34391
  selectFirst
33380
34392
  };
33381
34393
  };
34394
+ // Set tab heights within a dialog to vary according to their contents
34395
+ const naiveMode = (_allTabs) => {
34396
+ const extraEvents = [];
34397
+ const selectFirst = true;
34398
+ return {
34399
+ extraEvents,
34400
+ selectFirst
34401
+ };
34402
+ };
33382
34403
 
33383
34404
  const SendDataToSectionChannel = 'send-data-to-section';
33384
34405
  const SendDataToViewChannel = 'send-data-to-view';
@@ -33447,7 +34468,9 @@
33447
34468
  };
33448
34469
  });
33449
34470
  // Assign fixed height or variable height to the tabs
33450
- const tabMode = smartMode(allTabs);
34471
+ const tabMode = spec.dynamicHeight
34472
+ ? naiveMode() // Height is determined by the content of the tab, which may cause layout shifts when switching tabs.
34473
+ : smartMode(allTabs); // Height is determined by the tallest tab, which prevents layout shifts but may cause excessive whitespace in shorter tabs.
33451
34474
  return TabSection.sketch({
33452
34475
  dom: {
33453
34476
  tag: 'div',
@@ -33892,7 +34915,7 @@
33892
34915
  const dialogBody = SugarElement.fromDom(comp.element.dom);
33893
34916
  const classes = get$7(dialogBody);
33894
34917
  const currentSizeClass = find$5(classes, (c) => c === largeDialogClass || c === mediumDialogClass).or(getDialogSizeClass(currentSize));
33895
- toggle$3(dialogBody, [fullscreenClass, ...currentSizeClass.toArray()]);
34918
+ toggle$2(dialogBody, [fullscreenClass, ...currentSizeClass.toArray()]);
33896
34919
  };
33897
34920
  const renderModalDialog = (spec, dialogEvents, backstage) => build$1(renderDialog$1({
33898
34921
  ...spec,