@knime/kds-table 0.6.1 → 0.6.3

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 (29) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.css +69 -75
  3. package/dist/index.js +2388 -50
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/components/TableUI.vue.d.ts +76 -60
  6. package/dist/src/components/TableUI.vue.d.ts.map +1 -1
  7. package/dist/src/components/TableUIWithAutoSizeCalculation.vue.d.ts +161 -75
  8. package/dist/src/components/TableUIWithAutoSizeCalculation.vue.d.ts.map +1 -1
  9. package/dist/src/components/control/PageControls.vue.d.ts +22 -14
  10. package/dist/src/components/control/PageControls.vue.d.ts.map +1 -1
  11. package/dist/src/components/control/TableActionBar.vue.d.ts +10 -2
  12. package/dist/src/components/control/TableActionBar.vue.d.ts.map +1 -1
  13. package/dist/src/components/control/actionbar/FilterControl.vue.d.ts +10 -2
  14. package/dist/src/components/control/actionbar/FilterControl.vue.d.ts.map +1 -1
  15. package/dist/src/components/control/actionbar/SortControl.vue.d.ts +10 -2
  16. package/dist/src/components/control/actionbar/SortControl.vue.d.ts.map +1 -1
  17. package/dist/src/components/layout/Cell.vue.d.ts +2 -2
  18. package/dist/src/components/layout/Cell.vue.d.ts.map +1 -1
  19. package/dist/src/components/layout/CellRenderer.vue.d.ts.map +1 -1
  20. package/dist/src/components/layout/CellRendererProps.d.ts +1 -1
  21. package/dist/src/components/layout/CellRendererProps.d.ts.map +1 -1
  22. package/dist/src/components/layout/Header.vue.d.ts +12 -12
  23. package/dist/src/components/layout/HeaderCell.vue.d.ts +12 -9
  24. package/dist/src/components/layout/HeaderCell.vue.d.ts.map +1 -1
  25. package/dist/src/components/layout/Row.vue.d.ts +16 -16
  26. package/dist/src/components/layout/Row.vue.d.ts.map +1 -1
  27. package/dist/src/types/TableConfig.d.ts +1 -1
  28. package/dist/src/types/TableConfig.d.ts.map +1 -1
  29. package/package.json +7 -9
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { computed, unref, watch, ref, isRef, watchEffect, getCurrentScope, onScopeDispose, getCurrentInstance, onMounted, inject, provide, defineComponent, openBlock, createElementBlock, withModifiers, renderSlot, toRef, normalizeStyle, normalizeClass, createCommentVNode, createVNode, Fragment, renderList, createElementVNode, createBlock, nextTick, withCtx, onBeforeUnmount, reactive, onUnmounted, toDisplayString, resolveComponent, useTemplateRef, createTextVNode, shallowRef, toValue, shallowReadonly, withKeys, mergeProps, useSlots, createSlots, normalizeProps, guardReactiveProps } from 'vue';
2
- import { KdsCheckbox, KdsLoadingSkeleton, KdsButton, KdsMenuButton, KdsDropdown, KdsTextInput, KdsMultiSelectDropdown, KdsToggleButton, KdsPopover, KdsIcon, KdsSearchInput, KdsMissingValueIcon } from '@knime/kds-components';
1
+ import { computed, unref, watch, ref, isRef, watchEffect, getCurrentScope, onScopeDispose, getCurrentInstance, onMounted, inject, provide, defineComponent, openBlock, createElementBlock, withModifiers, renderSlot, toRef, normalizeStyle, normalizeClass, createCommentVNode, createVNode, Fragment, renderList, createElementVNode, createBlock, nextTick, withCtx, onBeforeUnmount, reactive, onUnmounted, toDisplayString, resolveComponent, useTemplateRef, createTextVNode, shallowRef, toValue, shallowReadonly, withKeys, withDirectives, mergeProps, useSlots, createSlots, normalizeProps, guardReactiveProps } from 'vue';
2
+ import { KdsCheckbox, KdsLoadingSkeleton, KdsButton, KdsMenuButton, KdsDropdown, KdsTextInput, KdsMultiSelectDropdown, KdsToggleButton, KdsPopover, KdsIcon, KdsSearchInput, vKdsTooltip, KdsMissingValueIcon } from '@knime/kds-components';
3
3
 
4
4
  import './index.css';const defaultPageSize = 10;
5
5
  const filterComponents = {
@@ -397,12 +397,2348 @@ class oe extends b {
397
397
  }
398
398
  }
399
399
 
400
+ /*! @license DOMPurify 3.4.11 | (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.11/LICENSE */
401
+
402
+ function _arrayLikeToArray(r, a) {
403
+ (null == a || a > r.length) && (a = r.length);
404
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
405
+ return n;
406
+ }
407
+ function _arrayWithHoles(r) {
408
+ if (Array.isArray(r)) return r;
409
+ }
410
+ function _iterableToArrayLimit(r, l) {
411
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
412
+ if (null != t) {
413
+ var e,
414
+ n,
415
+ i,
416
+ u,
417
+ a = [],
418
+ f = true,
419
+ o = false;
420
+ try {
421
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
422
+ } catch (r) {
423
+ o = true, n = r;
424
+ } finally {
425
+ try {
426
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
427
+ } finally {
428
+ if (o) throw n;
429
+ }
430
+ }
431
+ return a;
432
+ }
433
+ }
434
+ function _nonIterableRest() {
435
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
436
+ }
437
+ function _slicedToArray(r, e) {
438
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
439
+ }
440
+ function _unsupportedIterableToArray(r, a) {
441
+ if (r) {
442
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
443
+ var t = {}.toString.call(r).slice(8, -1);
444
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
445
+ }
446
+ }
447
+
448
+ const entries = Object.entries,
449
+ setPrototypeOf = Object.setPrototypeOf,
450
+ isFrozen = Object.isFrozen,
451
+ getPrototypeOf = Object.getPrototypeOf,
452
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
453
+ let freeze = Object.freeze,
454
+ seal = Object.seal,
455
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
456
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
457
+ apply = _ref.apply,
458
+ construct = _ref.construct;
459
+ if (!freeze) {
460
+ freeze = function freeze(x) {
461
+ return x;
462
+ };
463
+ }
464
+ if (!seal) {
465
+ seal = function seal(x) {
466
+ return x;
467
+ };
468
+ }
469
+ if (!apply) {
470
+ apply = function apply(func, thisArg) {
471
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
472
+ args[_key - 2] = arguments[_key];
473
+ }
474
+ return func.apply(thisArg, args);
475
+ };
476
+ }
477
+ if (!construct) {
478
+ construct = function construct(Func) {
479
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
480
+ args[_key2 - 1] = arguments[_key2];
481
+ }
482
+ return new Func(...args);
483
+ };
484
+ }
485
+ const arrayForEach = unapply(Array.prototype.forEach);
486
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
487
+ const arrayPop = unapply(Array.prototype.pop);
488
+ const arrayPush = unapply(Array.prototype.push);
489
+ const arraySplice = unapply(Array.prototype.splice);
490
+ const arrayIsArray = Array.isArray;
491
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
492
+ const stringToString = unapply(String.prototype.toString);
493
+ const stringMatch = unapply(String.prototype.match);
494
+ const stringReplace = unapply(String.prototype.replace);
495
+ const stringIndexOf = unapply(String.prototype.indexOf);
496
+ const stringTrim = unapply(String.prototype.trim);
497
+ const numberToString = unapply(Number.prototype.toString);
498
+ const booleanToString = unapply(Boolean.prototype.toString);
499
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
500
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
501
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
502
+ const objectToString = unapply(Object.prototype.toString);
503
+ const regExpTest = unapply(RegExp.prototype.test);
504
+ const typeErrorCreate = unconstruct(TypeError);
505
+ /**
506
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
507
+ *
508
+ * @param func - The function to be wrapped and called.
509
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
510
+ */
511
+ function unapply(func) {
512
+ return function (thisArg) {
513
+ if (thisArg instanceof RegExp) {
514
+ thisArg.lastIndex = 0;
515
+ }
516
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
517
+ args[_key3 - 1] = arguments[_key3];
518
+ }
519
+ return apply(func, thisArg, args);
520
+ };
521
+ }
522
+ /**
523
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
524
+ *
525
+ * @param func - The constructor function to be wrapped and called.
526
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
527
+ */
528
+ function unconstruct(Func) {
529
+ return function () {
530
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
531
+ args[_key4] = arguments[_key4];
532
+ }
533
+ return construct(Func, args);
534
+ };
535
+ }
536
+ /**
537
+ * Add properties to a lookup table
538
+ *
539
+ * @param set - The set to which elements will be added.
540
+ * @param array - The array containing elements to be added to the set.
541
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
542
+ * @returns The modified set with added elements.
543
+ */
544
+ function addToSet(set, array) {
545
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
546
+ if (setPrototypeOf) {
547
+ // Make 'in' and truthy checks like Boolean(set.constructor)
548
+ // independent of any properties defined on Object.prototype.
549
+ // Prevent prototype setters from intercepting set as a this value.
550
+ setPrototypeOf(set, null);
551
+ }
552
+ if (!arrayIsArray(array)) {
553
+ return set;
554
+ }
555
+ let l = array.length;
556
+ while (l--) {
557
+ let element = array[l];
558
+ if (typeof element === 'string') {
559
+ const lcElement = transformCaseFunc(element);
560
+ if (lcElement !== element) {
561
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
562
+ if (!isFrozen(array)) {
563
+ array[l] = lcElement;
564
+ }
565
+ element = lcElement;
566
+ }
567
+ }
568
+ set[element] = true;
569
+ }
570
+ return set;
571
+ }
572
+ /**
573
+ * Clean up an array to harden against CSPP
574
+ *
575
+ * @param array - The array to be cleaned.
576
+ * @returns The cleaned version of the array
577
+ */
578
+ function cleanArray(array) {
579
+ for (let index = 0; index < array.length; index++) {
580
+ const isPropertyExist = objectHasOwnProperty(array, index);
581
+ if (!isPropertyExist) {
582
+ array[index] = null;
583
+ }
584
+ }
585
+ return array;
586
+ }
587
+ /**
588
+ * Shallow clone an object
589
+ *
590
+ * @param object - The object to be cloned.
591
+ * @returns A new object that copies the original.
592
+ */
593
+ function clone(object) {
594
+ const newObject = create(null);
595
+ for (const _ref2 of entries(object)) {
596
+ var _ref3 = _slicedToArray(_ref2, 2);
597
+ const property = _ref3[0];
598
+ const value = _ref3[1];
599
+ const isPropertyExist = objectHasOwnProperty(object, property);
600
+ if (isPropertyExist) {
601
+ if (arrayIsArray(value)) {
602
+ newObject[property] = cleanArray(value);
603
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
604
+ newObject[property] = clone(value);
605
+ } else {
606
+ newObject[property] = value;
607
+ }
608
+ }
609
+ }
610
+ return newObject;
611
+ }
612
+ /**
613
+ * Convert non-node values into strings without depending on direct property access.
614
+ *
615
+ * @param value - The value to stringify.
616
+ * @returns A string representation of the provided value.
617
+ */
618
+ function stringifyValue(value) {
619
+ switch (typeof value) {
620
+ case 'string':
621
+ {
622
+ return value;
623
+ }
624
+ case 'number':
625
+ {
626
+ return numberToString(value);
627
+ }
628
+ case 'boolean':
629
+ {
630
+ return booleanToString(value);
631
+ }
632
+ case 'bigint':
633
+ {
634
+ return bigintToString ? bigintToString(value) : '0';
635
+ }
636
+ case 'symbol':
637
+ {
638
+ return symbolToString ? symbolToString(value) : 'Symbol()';
639
+ }
640
+ case 'undefined':
641
+ {
642
+ return objectToString(value);
643
+ }
644
+ case 'function':
645
+ case 'object':
646
+ {
647
+ if (value === null) {
648
+ return objectToString(value);
649
+ }
650
+ const valueAsRecord = value;
651
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
652
+ if (typeof valueToString === 'function') {
653
+ const stringified = valueToString(valueAsRecord);
654
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
655
+ }
656
+ return objectToString(value);
657
+ }
658
+ default:
659
+ {
660
+ return objectToString(value);
661
+ }
662
+ }
663
+ }
664
+ /**
665
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
666
+ *
667
+ * @param object - The object to look up the getter function in its prototype chain.
668
+ * @param prop - The property name for which to find the getter function.
669
+ * @returns The getter function found in the prototype chain or a fallback function.
670
+ */
671
+ function lookupGetter(object, prop) {
672
+ while (object !== null) {
673
+ const desc = getOwnPropertyDescriptor(object, prop);
674
+ if (desc) {
675
+ if (desc.get) {
676
+ return unapply(desc.get);
677
+ }
678
+ if (typeof desc.value === 'function') {
679
+ return unapply(desc.value);
680
+ }
681
+ }
682
+ object = getPrototypeOf(object);
683
+ }
684
+ function fallbackValue() {
685
+ return null;
686
+ }
687
+ return fallbackValue;
688
+ }
689
+ function isRegex(value) {
690
+ try {
691
+ regExpTest(value, '');
692
+ return true;
693
+ } catch (_unused) {
694
+ return false;
695
+ }
696
+ }
697
+
698
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
699
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
700
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
701
+ // List of SVG elements that are disallowed by default.
702
+ // We still need to know them so that we can do namespace
703
+ // checks properly in case one wants to add them to
704
+ // allow-list.
705
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
706
+ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
707
+ // Similarly to SVG, we want to know all MathML elements,
708
+ // even those that we disallow by default.
709
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
710
+ const text = freeze(['#text']);
711
+
712
+ 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']);
713
+ 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']);
714
+ 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']);
715
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
716
+
717
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
718
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
719
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
720
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
721
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
722
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
723
+ );
724
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
725
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
726
+ );
727
+ const DOCTYPE_NAME = seal(/^html$/i);
728
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
729
+ // Markup-significant character probes used by _sanitizeElements.
730
+ // Shared module-level instances are safe despite the sticky /g flags:
731
+ // unapply() resets lastIndex for RegExp receivers before every call.
732
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
733
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
734
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
735
+ const SELF_CLOSING_TAG = seal(/\/>/i);
736
+
737
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
738
+ const NODE_TYPE = {
739
+ element: 1,
740
+ attribute: 2,
741
+ text: 3,
742
+ cdataSection: 4,
743
+ entityReference: 5,
744
+ // Deprecated
745
+ entityNode: 6,
746
+ // Deprecated
747
+ processingInstruction: 7,
748
+ comment: 8,
749
+ document: 9,
750
+ documentType: 10,
751
+ documentFragment: 11,
752
+ notation: 12 // Deprecated
753
+ };
754
+ const getGlobal = function getGlobal() {
755
+ return typeof window === 'undefined' ? null : window;
756
+ };
757
+ /**
758
+ * Creates a no-op policy for internal use only.
759
+ * Don't export this function outside this module!
760
+ * @param trustedTypes The policy factory.
761
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
762
+ * @return The policy created (or null, if Trusted Types
763
+ * are not supported or creating the policy failed).
764
+ */
765
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
766
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
767
+ return null;
768
+ }
769
+ // Allow the callers to control the unique policy name
770
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
771
+ // Policy creation with duplicate names throws in Trusted Types.
772
+ let suffix = null;
773
+ const ATTR_NAME = 'data-tt-policy-suffix';
774
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
775
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
776
+ }
777
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
778
+ try {
779
+ return trustedTypes.createPolicy(policyName, {
780
+ createHTML(html) {
781
+ return html;
782
+ },
783
+ createScriptURL(scriptUrl) {
784
+ return scriptUrl;
785
+ }
786
+ });
787
+ } catch (_) {
788
+ // Policy creation failed (most likely another DOMPurify script has
789
+ // already run). Skip creating the policy, as this will only cause errors
790
+ // if TT are enforced.
791
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
792
+ return null;
793
+ }
794
+ };
795
+ const _createHooksMap = function _createHooksMap() {
796
+ return {
797
+ afterSanitizeAttributes: [],
798
+ afterSanitizeElements: [],
799
+ afterSanitizeShadowDOM: [],
800
+ beforeSanitizeAttributes: [],
801
+ beforeSanitizeElements: [],
802
+ beforeSanitizeShadowDOM: [],
803
+ uponSanitizeAttribute: [],
804
+ uponSanitizeElement: [],
805
+ uponSanitizeShadowNode: []
806
+ };
807
+ };
808
+ /**
809
+ * Resolve a set-valued configuration option: a fresh set built from
810
+ * cfg[key] when it is an own array property (seeded with a clone of
811
+ * options.base when given, case-normalized via options.transform),
812
+ * the fallback set otherwise.
813
+ *
814
+ * @param cfg the cloned, prototype-free configuration object
815
+ * @param key the configuration property to read
816
+ * @param fallback the set to use when the option is absent or not an array
817
+ * @param options transform and optional base set to merge into
818
+ * @returns the resolved set
819
+ */
820
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
821
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
822
+ };
823
+ function createDOMPurify() {
824
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
825
+ const DOMPurify = root => createDOMPurify(root);
826
+ DOMPurify.version = '3.4.11';
827
+ DOMPurify.removed = [];
828
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
829
+ // Not running in a browser, provide a factory function
830
+ // so that you can pass your own Window
831
+ DOMPurify.isSupported = false;
832
+ return DOMPurify;
833
+ }
834
+ let document = window.document;
835
+ const originalDocument = document;
836
+ const currentScript = originalDocument.currentScript;
837
+ window.DocumentFragment;
838
+ const HTMLTemplateElement = window.HTMLTemplateElement,
839
+ Node = window.Node,
840
+ Element = window.Element,
841
+ NodeFilter = window.NodeFilter,
842
+ _window$NamedNodeMap = window.NamedNodeMap;
843
+ _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
844
+ window.HTMLFormElement;
845
+ const DOMParser = window.DOMParser,
846
+ trustedTypes = window.trustedTypes;
847
+ const ElementPrototype = Element.prototype;
848
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
849
+ const remove = lookupGetter(ElementPrototype, 'remove');
850
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
851
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
852
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
853
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
854
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
855
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
856
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
857
+ // As per issue #47, the web-components registry is inherited by a
858
+ // new document created via createHTMLDocument. As per the spec
859
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
860
+ // a new empty registry is used when creating a template contents owner
861
+ // document, so we use that as our parent document to ensure nothing
862
+ // is inherited.
863
+ if (typeof HTMLTemplateElement === 'function') {
864
+ const template = document.createElement('template');
865
+ if (template.content && template.content.ownerDocument) {
866
+ document = template.content.ownerDocument;
867
+ }
868
+ }
869
+ let trustedTypesPolicy;
870
+ let emptyHTML = '';
871
+ // The instance's own internal Trusted Types policy. Unlike a caller-supplied
872
+ // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
873
+ // on duplicate policy names — and is the only policy allowed to persist
874
+ // across configurations and survive `clearConfig()`.
875
+ let defaultTrustedTypesPolicy;
876
+ let defaultTrustedTypesPolicyResolved = false;
877
+ // Tracks whether we are already inside a call to the configured Trusted Types
878
+ // policy (`createHTML` or `createScriptURL`). If a supplied policy callback
879
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
880
+ // re-enter the policy and recurse until the stack overflows. We detect that
881
+ // re-entry and throw a clear, actionable error instead. The guard is shared
882
+ // across both callbacks, because either one re-entering `sanitize` triggers
883
+ // the same unbounded recursion.
884
+ let IN_TRUSTED_TYPES_POLICY = 0;
885
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
886
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
887
+ 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.');
888
+ }
889
+ };
890
+ const _createTrustedHTML = function _createTrustedHTML(html) {
891
+ _assertNotInTrustedTypesPolicy();
892
+ IN_TRUSTED_TYPES_POLICY++;
893
+ try {
894
+ return trustedTypesPolicy.createHTML(html);
895
+ } finally {
896
+ IN_TRUSTED_TYPES_POLICY--;
897
+ }
898
+ };
899
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
900
+ _assertNotInTrustedTypesPolicy();
901
+ IN_TRUSTED_TYPES_POLICY++;
902
+ try {
903
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
904
+ } finally {
905
+ IN_TRUSTED_TYPES_POLICY--;
906
+ }
907
+ };
908
+ // Lazily resolve (and cache) the instance's internal default policy.
909
+ // Resolution is attempted at most once: a successful `createPolicy` cannot be
910
+ // repeated (Trusted Types throws on duplicate names), and a failed or
911
+ // unsupported attempt must not be retried on every parse.
912
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
913
+ if (!defaultTrustedTypesPolicyResolved) {
914
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
915
+ defaultTrustedTypesPolicyResolved = true;
916
+ }
917
+ return defaultTrustedTypesPolicy;
918
+ };
919
+ const _document = document,
920
+ implementation = _document.implementation,
921
+ createNodeIterator = _document.createNodeIterator,
922
+ createDocumentFragment = _document.createDocumentFragment,
923
+ getElementsByTagName = _document.getElementsByTagName;
924
+ const importNode = originalDocument.importNode;
925
+ let hooks = _createHooksMap();
926
+ /**
927
+ * Expose whether this browser supports running the full DOMPurify.
928
+ */
929
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
930
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
931
+ ERB_EXPR$1 = ERB_EXPR,
932
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
933
+ DATA_ATTR$1 = DATA_ATTR,
934
+ ARIA_ATTR$1 = ARIA_ATTR,
935
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
936
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
937
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
938
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
939
+ /**
940
+ * We consider the elements and attributes below to be safe. Ideally
941
+ * don't add any new ones but feel free to remove unwanted ones.
942
+ */
943
+ /* allowed element names */
944
+ let ALLOWED_TAGS = null;
945
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
946
+ /* Allowed attribute names */
947
+ let ALLOWED_ATTR = null;
948
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
949
+ /*
950
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
951
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
952
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
953
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
954
+ */
955
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
956
+ tagNameCheck: {
957
+ writable: true,
958
+ configurable: false,
959
+ enumerable: true,
960
+ value: null
961
+ },
962
+ attributeNameCheck: {
963
+ writable: true,
964
+ configurable: false,
965
+ enumerable: true,
966
+ value: null
967
+ },
968
+ allowCustomizedBuiltInElements: {
969
+ writable: true,
970
+ configurable: false,
971
+ enumerable: true,
972
+ value: false
973
+ }
974
+ }));
975
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
976
+ let FORBID_TAGS = null;
977
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
978
+ let FORBID_ATTR = null;
979
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
980
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
981
+ tagCheck: {
982
+ writable: true,
983
+ configurable: false,
984
+ enumerable: true,
985
+ value: null
986
+ },
987
+ attributeCheck: {
988
+ writable: true,
989
+ configurable: false,
990
+ enumerable: true,
991
+ value: null
992
+ }
993
+ }));
994
+ /* Decide if ARIA attributes are okay */
995
+ let ALLOW_ARIA_ATTR = true;
996
+ /* Decide if custom data attributes are okay */
997
+ let ALLOW_DATA_ATTR = true;
998
+ /* Decide if unknown protocols are okay */
999
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1000
+ /* Decide if self-closing tags in attributes are allowed.
1001
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
1002
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1003
+ /* Output should be safe for common template engines.
1004
+ * This means, DOMPurify removes data attributes, mustaches and ERB
1005
+ */
1006
+ let SAFE_FOR_TEMPLATES = false;
1007
+ /* Output should be safe even for XML used within HTML and alike.
1008
+ * This means, DOMPurify removes comments when containing risky content.
1009
+ */
1010
+ let SAFE_FOR_XML = true;
1011
+ /* Decide if document with <html>... should be returned */
1012
+ let WHOLE_DOCUMENT = false;
1013
+ /* Track whether config is already set on this instance of DOMPurify. */
1014
+ let SET_CONFIG = false;
1015
+ /* Pristine allowlist bindings captured at setConfig() time. On the
1016
+ * persistent-config path sanitize() restores the sets from these before
1017
+ * the per-walk hook clone-guard, so a hook's in-call widening cannot
1018
+ * carry across calls. Null until setConfig() is called; reset by
1019
+ * clearConfig(). */
1020
+ let SET_CONFIG_ALLOWED_TAGS = null;
1021
+ let SET_CONFIG_ALLOWED_ATTR = null;
1022
+ /* Decide if all elements (e.g. style, script) must be children of
1023
+ * document.body. By default, browsers might move them to document.head */
1024
+ let FORCE_BODY = false;
1025
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
1026
+ * string (or a TrustedHTML object if Trusted Types are supported).
1027
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
1028
+ */
1029
+ let RETURN_DOM = false;
1030
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
1031
+ * string (or a TrustedHTML object if Trusted Types are supported) */
1032
+ let RETURN_DOM_FRAGMENT = false;
1033
+ /* Try to return a Trusted Type object instead of a string, return a string in
1034
+ * case Trusted Types are not supported */
1035
+ let RETURN_TRUSTED_TYPE = false;
1036
+ /* Output should be free from DOM clobbering attacks?
1037
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
1038
+ */
1039
+ let SANITIZE_DOM = true;
1040
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
1041
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
1042
+ *
1043
+ * HTML/DOM spec rules that enable DOM Clobbering:
1044
+ * - Named Access on Window (§7.3.3)
1045
+ * - DOM Tree Accessors (§3.1.5)
1046
+ * - Form Element Parent-Child Relations (§4.10.3)
1047
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
1048
+ * - HTMLCollection (§4.2.10.2)
1049
+ *
1050
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
1051
+ * with a constant string, i.e., `user-content-`
1052
+ */
1053
+ let SANITIZE_NAMED_PROPS = false;
1054
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
1055
+ /* Keep element content when removing element? */
1056
+ let KEEP_CONTENT = true;
1057
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
1058
+ * of importing it into a new Document and returning a sanitized copy */
1059
+ let IN_PLACE = false;
1060
+ /* Allow usage of profiles like html, svg and mathMl */
1061
+ let USE_PROFILES = {};
1062
+ /* Tags to ignore content of when KEEP_CONTENT is true */
1063
+ let FORBID_CONTENTS = null;
1064
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
1065
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
1066
+ // the UA (customizable <select>) — including any on* handlers — and the
1067
+ // engine re-mirrors synchronously whenever a removal changes which
1068
+ // option/selectedcontent is current, even inside DOMPurify's inert
1069
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
1070
+ // mirror target ahead of the walk, which the engine refills, looping
1071
+ // forever (DoS) and amplifying output. Dropping its content on removal
1072
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
1073
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
1074
+ 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
1075
+ /* Tags that are safe for data: URIs */
1076
+ let DATA_URI_TAGS = null;
1077
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
1078
+ /* Attributes safe for values like "javascript:" */
1079
+ let URI_SAFE_ATTRIBUTES = null;
1080
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
1081
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1082
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1083
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1084
+ /* Document namespace */
1085
+ let NAMESPACE = HTML_NAMESPACE;
1086
+ let IS_EMPTY_INPUT = false;
1087
+ /* Allowed XHTML+XML namespaces */
1088
+ let ALLOWED_NAMESPACES = null;
1089
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1090
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
1091
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1092
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
1093
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1094
+ // Certain elements are allowed in both SVG and HTML
1095
+ // namespace. We need to specify them explicitly
1096
+ // so that they don't get erroneously deleted from
1097
+ // HTML namespace.
1098
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1099
+ /* Parsing of strict XHTML documents */
1100
+ let PARSER_MEDIA_TYPE = null;
1101
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1102
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1103
+ let transformCaseFunc = null;
1104
+ /* Keep a reference to config to pass to hooks */
1105
+ let CONFIG = null;
1106
+ /* Ideally, do not touch anything below this line */
1107
+ /* ______________________________________________ */
1108
+ const formElement = document.createElement('form');
1109
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1110
+ return testValue instanceof RegExp || testValue instanceof Function;
1111
+ };
1112
+ /**
1113
+ * _parseConfig
1114
+ *
1115
+ * @param cfg optional config literal
1116
+ */
1117
+ // eslint-disable-next-line complexity
1118
+ const _parseConfig = function _parseConfig() {
1119
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1120
+ if (CONFIG && CONFIG === cfg) {
1121
+ return;
1122
+ }
1123
+ /* Shield configuration object from tampering */
1124
+ if (!cfg || typeof cfg !== 'object') {
1125
+ cfg = {};
1126
+ }
1127
+ /* Shield configuration object from prototype pollution */
1128
+ cfg = clone(cfg);
1129
+ PARSER_MEDIA_TYPE =
1130
+ // eslint-disable-next-line unicorn/prefer-includes
1131
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1132
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1133
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1134
+ /* Set configuration parameters */
1135
+ ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
1136
+ transform: transformCaseFunc
1137
+ });
1138
+ ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
1139
+ transform: transformCaseFunc
1140
+ });
1141
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
1142
+ transform: stringToString
1143
+ });
1144
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
1145
+ transform: transformCaseFunc,
1146
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1147
+ });
1148
+ DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
1149
+ transform: transformCaseFunc,
1150
+ base: DEFAULT_DATA_URI_TAGS
1151
+ });
1152
+ FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
1153
+ transform: transformCaseFunc
1154
+ });
1155
+ FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
1156
+ transform: transformCaseFunc
1157
+ });
1158
+ FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
1159
+ transform: transformCaseFunc
1160
+ });
1161
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1162
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1163
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1164
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1165
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1166
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1167
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
1168
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1169
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1170
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1171
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1172
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1173
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1174
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1175
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1176
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
1177
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
1178
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
1179
+ 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
1180
+ 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
1181
+ const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
1182
+ CUSTOM_ELEMENT_HANDLING = create(null);
1183
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
1184
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
1185
+ }
1186
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
1187
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
1188
+ }
1189
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
1190
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
1191
+ }
1192
+ seal(CUSTOM_ELEMENT_HANDLING);
1193
+ if (SAFE_FOR_TEMPLATES) {
1194
+ ALLOW_DATA_ATTR = false;
1195
+ }
1196
+ if (RETURN_DOM_FRAGMENT) {
1197
+ RETURN_DOM = true;
1198
+ }
1199
+ /* Parse profile info */
1200
+ if (USE_PROFILES) {
1201
+ ALLOWED_TAGS = addToSet({}, text);
1202
+ ALLOWED_ATTR = create(null);
1203
+ if (USE_PROFILES.html === true) {
1204
+ addToSet(ALLOWED_TAGS, html$1);
1205
+ addToSet(ALLOWED_ATTR, html);
1206
+ }
1207
+ if (USE_PROFILES.svg === true) {
1208
+ addToSet(ALLOWED_TAGS, svg$1);
1209
+ addToSet(ALLOWED_ATTR, svg);
1210
+ addToSet(ALLOWED_ATTR, xml);
1211
+ }
1212
+ if (USE_PROFILES.svgFilters === true) {
1213
+ addToSet(ALLOWED_TAGS, svgFilters);
1214
+ addToSet(ALLOWED_ATTR, svg);
1215
+ addToSet(ALLOWED_ATTR, xml);
1216
+ }
1217
+ if (USE_PROFILES.mathMl === true) {
1218
+ addToSet(ALLOWED_TAGS, mathMl$1);
1219
+ addToSet(ALLOWED_ATTR, mathMl);
1220
+ addToSet(ALLOWED_ATTR, xml);
1221
+ }
1222
+ }
1223
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
1224
+ * leaking across calls when switching from function to array config */
1225
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
1226
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
1227
+ /* Merge configuration parameters */
1228
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
1229
+ if (typeof cfg.ADD_TAGS === 'function') {
1230
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
1231
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
1232
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1233
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
1234
+ }
1235
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1236
+ }
1237
+ }
1238
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
1239
+ if (typeof cfg.ADD_ATTR === 'function') {
1240
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
1241
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
1242
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1243
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
1244
+ }
1245
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1246
+ }
1247
+ }
1248
+ if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
1249
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1250
+ }
1251
+ if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
1252
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1253
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1254
+ }
1255
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1256
+ }
1257
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
1258
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1259
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1260
+ }
1261
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
1262
+ }
1263
+ /* Add #text in case KEEP_CONTENT is set to true */
1264
+ if (KEEP_CONTENT) {
1265
+ ALLOWED_TAGS['#text'] = true;
1266
+ }
1267
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1268
+ if (WHOLE_DOCUMENT) {
1269
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1270
+ }
1271
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1272
+ if (ALLOWED_TAGS.table) {
1273
+ addToSet(ALLOWED_TAGS, ['tbody']);
1274
+ delete FORBID_TAGS.tbody;
1275
+ }
1276
+ // Re-derive the active Trusted Types policy from this configuration on
1277
+ // every parse. The active policy must never be sticky closure state that
1278
+ // outlives the config that set it: a caller-supplied policy left in place
1279
+ // after `clearConfig()` — or after a later call that supplied none, or
1280
+ // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
1281
+ // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
1282
+ // See GHSA-vxr8-fq34-vvx9.
1283
+ if (cfg.TRUSTED_TYPES_POLICY) {
1284
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1285
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1286
+ }
1287
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1288
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1289
+ }
1290
+ // A caller-supplied policy applies to this configuration only.
1291
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1292
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1293
+ // Sign local variables required by `sanitize`. If the supplied policy's
1294
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
1295
+ // throws via the re-entrancy guard. Restore the previous policy first so
1296
+ // the instance is not left in a poisoned state. See #1422.
1297
+ try {
1298
+ emptyHTML = _createTrustedHTML('');
1299
+ } catch (error) {
1300
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1301
+ throw error;
1302
+ }
1303
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1304
+ // Explicit opt-out for this call: perform no Trusted Types signing and
1305
+ // create nothing (so a strict `trusted-types` CSP that disallows a
1306
+ // `dompurify` policy can still call `sanitize` from inside its own
1307
+ // policy — see #1422). Resetting to `undefined` rather than a sticky
1308
+ // `null` also drops any previously retained caller policy, so it cannot
1309
+ // resurface on a later call, while still allowing the next config-less
1310
+ // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
1311
+ trustedTypesPolicy = undefined;
1312
+ emptyHTML = '';
1313
+ } else {
1314
+ // No policy supplied: keep the currently active policy if one is set — a
1315
+ // previously supplied policy is intentionally sticky across config-less
1316
+ // calls — otherwise fall back to the instance's own internal policy,
1317
+ // created at most once. (A policy supplied for a *single* call still
1318
+ // lingers by design; what must not linger is a policy whose configuration
1319
+ // has been torn down via `clearConfig()`, which restores the default.)
1320
+ if (trustedTypesPolicy === undefined) {
1321
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1322
+ }
1323
+ // Sign internal variables only when a policy is active. A falsy policy
1324
+ // (Trusted Types unsupported, creation failed, or an explicit opt-out)
1325
+ // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
1326
+ // a non-policy and throw. See #1422.
1327
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
1328
+ emptyHTML = _createTrustedHTML('');
1329
+ }
1330
+ }
1331
+ // Prevent further manipulation of configuration.
1332
+ // Not available in IE8, Safari 5, etc.
1333
+ if (freeze) {
1334
+ freeze(cfg);
1335
+ }
1336
+ CONFIG = cfg;
1337
+ };
1338
+ /* Keep track of all possible SVG and MathML tags
1339
+ * so that we can perform the namespace checks
1340
+ * correctly. */
1341
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1342
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1343
+ /**
1344
+ * Namespace rules for an element in the SVG namespace.
1345
+ *
1346
+ * @param tagName the element's lowercase tag name
1347
+ * @param parent the (possibly simulated) parent node
1348
+ * @param parentTagName the parent's lowercase tag name
1349
+ * @returns true if a spec-compliant parser could produce this element
1350
+ */
1351
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
1352
+ // The only way to switch from HTML namespace to SVG
1353
+ // is via <svg>. If it happens via any other tag, then
1354
+ // it should be killed.
1355
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1356
+ return tagName === 'svg';
1357
+ }
1358
+ // The only way to switch from MathML to SVG is via <svg>
1359
+ // if the parent is either <annotation-xml> or a MathML
1360
+ // text integration point.
1361
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1362
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1363
+ }
1364
+ // We only allow elements that are defined in SVG
1365
+ // spec. All others are disallowed in SVG namespace.
1366
+ return Boolean(ALL_SVG_TAGS[tagName]);
1367
+ };
1368
+ /**
1369
+ * Namespace rules for an element in the MathML namespace.
1370
+ *
1371
+ * @param tagName the element's lowercase tag name
1372
+ * @param parent the (possibly simulated) parent node
1373
+ * @param parentTagName the parent's lowercase tag name
1374
+ * @returns true if a spec-compliant parser could produce this element
1375
+ */
1376
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
1377
+ // The only way to switch from HTML namespace to MathML
1378
+ // is via <math>. If it happens via any other tag, then
1379
+ // it should be killed.
1380
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1381
+ return tagName === 'math';
1382
+ }
1383
+ // The only way to switch from SVG to MathML is via
1384
+ // <math> and HTML integration points
1385
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1386
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1387
+ }
1388
+ // We only allow elements that are defined in MathML
1389
+ // spec. All others are disallowed in MathML namespace.
1390
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1391
+ };
1392
+ /**
1393
+ * Namespace rules for an element in the HTML namespace.
1394
+ *
1395
+ * @param tagName the element's lowercase tag name
1396
+ * @param parent the (possibly simulated) parent node
1397
+ * @param parentTagName the parent's lowercase tag name
1398
+ * @returns true if a spec-compliant parser could produce this element
1399
+ */
1400
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1401
+ // The only way to switch from SVG to HTML is via
1402
+ // HTML integration points, and from MathML to HTML
1403
+ // is via MathML text integration points
1404
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1405
+ return false;
1406
+ }
1407
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1408
+ return false;
1409
+ }
1410
+ // We disallow tags that are specific for MathML
1411
+ // or SVG and should never appear in HTML namespace
1412
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1413
+ };
1414
+ /**
1415
+ * @param element a DOM element whose namespace is being checked
1416
+ * @returns Return false if the element has a
1417
+ * namespace that a spec-compliant parser would never
1418
+ * return. Return true otherwise.
1419
+ */
1420
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1421
+ let parent = getParentNode(element);
1422
+ // In JSDOM, if we're inside shadow DOM, then parentNode
1423
+ // can be null. We just simulate parent in this case.
1424
+ if (!parent || !parent.tagName) {
1425
+ parent = {
1426
+ namespaceURI: NAMESPACE,
1427
+ tagName: 'template'
1428
+ };
1429
+ }
1430
+ const tagName = stringToLowerCase(element.tagName);
1431
+ const parentTagName = stringToLowerCase(parent.tagName);
1432
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1433
+ return false;
1434
+ }
1435
+ if (element.namespaceURI === SVG_NAMESPACE) {
1436
+ return _checkSvgNamespace(tagName, parent, parentTagName);
1437
+ }
1438
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1439
+ return _checkMathMlNamespace(tagName, parent, parentTagName);
1440
+ }
1441
+ if (element.namespaceURI === HTML_NAMESPACE) {
1442
+ return _checkHtmlNamespace(tagName, parent, parentTagName);
1443
+ }
1444
+ // For XHTML and XML documents that support custom namespaces
1445
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1446
+ return true;
1447
+ }
1448
+ // The code should never reach this place (this means
1449
+ // that the element somehow got namespace that is not
1450
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1451
+ // Return false just in case.
1452
+ return false;
1453
+ };
1454
+ /**
1455
+ * _forceRemove
1456
+ *
1457
+ * @param node a DOM node
1458
+ */
1459
+ const _forceRemove = function _forceRemove(node) {
1460
+ arrayPush(DOMPurify.removed, {
1461
+ element: node
1462
+ });
1463
+ try {
1464
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
1465
+ getParentNode(node).removeChild(node);
1466
+ } catch (_) {
1467
+ /* The normal detach failed — this is reached for a parentless node
1468
+ (getParentNode() is null, so .removeChild throws). Element.prototype
1469
+ .remove() is itself a spec no-op on a parentless node, so a recorded
1470
+ "removal" would otherwise hand the caller back an intact,
1471
+ payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
1472
+ the style-with-element-child rule decided to kill). Fail closed by
1473
+ throwing — exactly as a clobbered root does at the IN_PLACE entry —
1474
+ rather than trying to "neutralize" the node via its own methods.
1475
+ Neutralizing would mean calling getAttributeNames()/removeAttribute()
1476
+ on the node, both of which a <form> root can clobber via a named child
1477
+ (and _isClobbered does not even probe getAttributeNames), so the
1478
+ neutralize step could itself be silently defeated, leaving the payload
1479
+ intact. A throw touches only the cached, clobber-safe remove() and
1480
+ getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
1481
+ to every root-kill reason. REPORT-3.
1482
+ This lives inside the catch, so it never fires for a normally-removed
1483
+ in-tree node: those have a parent, removeChild() succeeds, and the
1484
+ catch is not entered. Only a kept (parentless) root reaches here. */
1485
+ remove(node);
1486
+ if (!getParentNode(node)) {
1487
+ throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
1488
+ }
1489
+ }
1490
+ };
1491
+ /**
1492
+ * _neutralizeRoot
1493
+ *
1494
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
1495
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
1496
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
1497
+ * parentless guard throws, or any other re-entrant engine mutation — would
1498
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
1499
+ * after the abort point still carrying its handlers. There is no safe way
1500
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
1501
+ * remove every child and every attribute, then let the caller's catch see
1502
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
1503
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
1504
+ *
1505
+ * @param root the in-place root to empty
1506
+ */
1507
+ const _neutralizeRoot = function _neutralizeRoot(root) {
1508
+ const childNodes = getChildNodes(root);
1509
+ if (childNodes) {
1510
+ const snapshot = [];
1511
+ arrayForEach(childNodes, child => {
1512
+ arrayPush(snapshot, child);
1513
+ });
1514
+ arrayForEach(snapshot, child => {
1515
+ try {
1516
+ remove(child);
1517
+ } catch (_) {
1518
+ /* Best-effort teardown; a still-attached child is handled below */
1519
+ }
1520
+ });
1521
+ }
1522
+ const attributes = getAttributes(root);
1523
+ if (attributes) {
1524
+ for (let i = attributes.length - 1; i >= 0; --i) {
1525
+ const attribute = attributes[i];
1526
+ const name = attribute && attribute.name;
1527
+ if (typeof name === 'string') {
1528
+ try {
1529
+ root.removeAttribute(name);
1530
+ } catch (_) {
1531
+ /* Clobbered removeAttribute — ignore (fail-closed best effort) */
1532
+ }
1533
+ }
1534
+ }
1535
+ }
1536
+ };
1537
+ /**
1538
+ * _removeAttribute
1539
+ *
1540
+ * @param name an Attribute name
1541
+ * @param element a DOM node
1542
+ */
1543
+ const _removeAttribute = function _removeAttribute(name, element) {
1544
+ try {
1545
+ arrayPush(DOMPurify.removed, {
1546
+ attribute: element.getAttributeNode(name),
1547
+ from: element
1548
+ });
1549
+ } catch (_) {
1550
+ arrayPush(DOMPurify.removed, {
1551
+ attribute: null,
1552
+ from: element
1553
+ });
1554
+ }
1555
+ element.removeAttribute(name);
1556
+ // We void attribute values for unremovable "is" attributes
1557
+ if (name === 'is') {
1558
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1559
+ try {
1560
+ _forceRemove(element);
1561
+ } catch (_) {}
1562
+ } else {
1563
+ try {
1564
+ element.setAttribute(name, '');
1565
+ } catch (_) {}
1566
+ }
1567
+ }
1568
+ };
1569
+ /**
1570
+ * _stripDisallowedAttributes
1571
+ *
1572
+ * Removes every attribute the active configuration does not allow from a
1573
+ * single element, using the same allowlist as the main attribute pass (so
1574
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
1575
+ * neutralise nodes that are being discarded from an in-place tree.
1576
+ *
1577
+ * @param element the element to strip
1578
+ */
1579
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
1580
+ const attributes = getAttributes(element);
1581
+ if (!attributes) {
1582
+ return;
1583
+ }
1584
+ for (let i = attributes.length - 1; i >= 0; --i) {
1585
+ const attribute = attributes[i];
1586
+ const name = attribute && attribute.name;
1587
+ if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
1588
+ continue;
1589
+ }
1590
+ try {
1591
+ element.removeAttribute(name);
1592
+ } catch (_) {
1593
+ /* Clobbered removeAttribute on a doomed node — ignore */
1594
+ }
1595
+ }
1596
+ };
1597
+ /**
1598
+ * _neutralizeSubtree
1599
+ *
1600
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
1601
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
1602
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
1603
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
1604
+ * those dropped nodes are detached from the caller's LIVE tree but a
1605
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
1606
+ * loading) keeps its queued resource event, which fires in page scope after
1607
+ * sanitize returns. This walks a removed subtree and strips every attribute
1608
+ * the active configuration does not allow — so `on*` handlers are cancelled
1609
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
1610
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
1611
+ * queued event can fire. Hook-free by design: these nodes leave the output,
1612
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
1613
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
1614
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
1615
+ * the `<img>`, are reached and scrubbed).
1616
+ *
1617
+ * @param root the root of a removed subtree to neutralise
1618
+ */
1619
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
1620
+ const stack = [root];
1621
+ while (stack.length > 0) {
1622
+ const node = stack.pop();
1623
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
1624
+ if (nodeType === NODE_TYPE.element) {
1625
+ _stripDisallowedAttributes(node);
1626
+ }
1627
+ const childNodes = getChildNodes(node);
1628
+ if (childNodes) {
1629
+ for (let i = childNodes.length - 1; i >= 0; --i) {
1630
+ stack.push(childNodes[i]);
1631
+ }
1632
+ }
1633
+ }
1634
+ };
1635
+ /**
1636
+ * _initDocument
1637
+ *
1638
+ * @param dirty - a string of dirty markup
1639
+ * @return a DOM, filled with the dirty markup
1640
+ */
1641
+ const _initDocument = function _initDocument(dirty) {
1642
+ /* Create a HTML document */
1643
+ let doc = null;
1644
+ let leadingWhitespace = null;
1645
+ if (FORCE_BODY) {
1646
+ dirty = '<remove></remove>' + dirty;
1647
+ } else {
1648
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1649
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1650
+ leadingWhitespace = matches && matches[0];
1651
+ }
1652
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1653
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1654
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1655
+ }
1656
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
1657
+ /*
1658
+ * Use the DOMParser API by default, fallback later if needs be
1659
+ * DOMParser not work for svg when has multiple root element.
1660
+ */
1661
+ if (NAMESPACE === HTML_NAMESPACE) {
1662
+ try {
1663
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1664
+ } catch (_) {}
1665
+ }
1666
+ /* Use createHTMLDocument in case DOMParser is not available */
1667
+ if (!doc || !doc.documentElement) {
1668
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
1669
+ try {
1670
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1671
+ } catch (_) {
1672
+ // Syntax error if dirtyPayload is invalid xml
1673
+ }
1674
+ }
1675
+ const body = doc.body || doc.documentElement;
1676
+ if (dirty && leadingWhitespace) {
1677
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1678
+ }
1679
+ /* Work on whole document or just its body */
1680
+ if (NAMESPACE === HTML_NAMESPACE) {
1681
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1682
+ }
1683
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1684
+ };
1685
+ /**
1686
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1687
+ *
1688
+ * @param root The root element or node to start traversing on.
1689
+ * @return The created NodeIterator
1690
+ */
1691
+ const _createNodeIterator = function _createNodeIterator(root) {
1692
+ return createNodeIterator.call(root.ownerDocument || root, root,
1693
+ // eslint-disable-next-line no-bitwise
1694
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1695
+ };
1696
+ /**
1697
+ * Replace template expression syntax (mustache, ERB, template
1698
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
1699
+ * sites. Order matters: mustache, then ERB, then template literal.
1700
+ *
1701
+ * @param value the string to scrub
1702
+ * @returns the scrubbed string
1703
+ */
1704
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
1705
+ value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
1706
+ value = stringReplace(value, ERB_EXPR$1, ' ');
1707
+ value = stringReplace(value, TMPLIT_EXPR$1, ' ');
1708
+ return value;
1709
+ };
1710
+ /**
1711
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
1712
+ * character data of an element subtree. Used as the final safety net for
1713
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
1714
+ * which only form after text-node normalization (e.g. fragments split across
1715
+ * stripped elements) cannot survive into a template-evaluating framework.
1716
+ *
1717
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
1718
+ * in place rather than round-tripping through innerHTML. This preserves
1719
+ * descendant node references (important for IN_PLACE callers), avoids a
1720
+ * serialize/reparse cycle, and reads literal character data — which means
1721
+ * `<%...%>` in text content matches the ERB regex against its real bytes
1722
+ * instead of the HTML-entity-escaped form innerHTML would produce.
1723
+ *
1724
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
1725
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
1726
+ *
1727
+ * @param node The root element whose character data should be scrubbed.
1728
+ */
1729
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1730
+ var _node$querySelectorAl;
1731
+ node.normalize();
1732
+ const walker = createNodeIterator.call(node.ownerDocument || node, node,
1733
+ // eslint-disable-next-line no-bitwise
1734
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
1735
+ let currentNode = walker.nextNode();
1736
+ while (currentNode) {
1737
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
1738
+ currentNode = walker.nextNode();
1739
+ }
1740
+ // NodeIterator does not descend into <template>.content per the DOM spec,
1741
+ // so we must explicitly recurse into each template's content fragment,
1742
+ // mirroring the approach used by _sanitizeShadowDOM.
1743
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
1744
+ if (templates) {
1745
+ arrayForEach(templates, tmpl => {
1746
+ if (_isDocumentFragment(tmpl.content)) {
1747
+ _scrubTemplateExpressions2(tmpl.content);
1748
+ }
1749
+ });
1750
+ }
1751
+ };
1752
+ /**
1753
+ * _isClobbered
1754
+ *
1755
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
1756
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
1757
+ * `name` attribute matching a prototype property shadows that property
1758
+ * on direct reads. We use this check at the IN_PLACE entry-point and
1759
+ * during attribute sanitization to refuse clobbered forms.
1760
+ *
1761
+ * @param element element to check for clobbering attacks
1762
+ * @return true if clobbered, false if safe
1763
+ */
1764
+ const _isClobbered = function _isClobbered(element) {
1765
+ // Realm-independent tag-name probe. If we can't determine the tag
1766
+ // name at all, we can't reason about clobbering — return false
1767
+ // (the caller's other defences still apply).
1768
+ const realTagName = getNodeName ? getNodeName(element) : null;
1769
+ if (typeof realTagName !== 'string') {
1770
+ return false;
1771
+ }
1772
+ if (transformCaseFunc(realTagName) !== 'form') {
1773
+ return false;
1774
+ }
1775
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
1776
+ // Realm-safe NamedNodeMap detection: equality against the cached
1777
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
1778
+ // makes the direct read diverge from the cached read; a clean form
1779
+ // (same-realm OR foreign-realm) has both reads pointing at the same
1780
+ // canonical NamedNodeMap.
1781
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
1782
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
1783
+ // returns the integer 1 for any Element regardless of realm; direct
1784
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
1785
+ // the named child element. Cheap addition — nodeType is read from
1786
+ // an internal slot, no serialization cost — and removes a residual
1787
+ // clobbering surface used by several mXSS / PI / comment branches
1788
+ // in _sanitizeElements that compare currentNode.nodeType directly.
1789
+ element.nodeType !== getNodeType(element) ||
1790
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
1791
+ // "childNodes" shadows the prototype getter. Direct reads of
1792
+ // form.childNodes from a clobbered form return the named child
1793
+ // instead of the real NodeList, so any walk that reads it directly
1794
+ // skips the form's real children. Compare the direct read to the
1795
+ // cached Node.prototype getter — when the form's named-property
1796
+ // getter intercepts the read, the two values differ and we flag
1797
+ // the form. This catches every clobbering child type (input,
1798
+ // select, etc.) regardless of whether the named child happens to
1799
+ // carry a numeric .length, which a typeof-based probe would miss
1800
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
1801
+ element.childNodes !== getChildNodes(element);
1802
+ };
1803
+ /**
1804
+ * Checks whether the given value is a DocumentFragment from any realm.
1805
+ *
1806
+ * The realm-independent replacement reads `nodeType` through the cached
1807
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
1808
+ * constant (11). nodeType is a numeric value resolved from the node's
1809
+ * internal slot, identical across realms for the same kind of node.
1810
+ *
1811
+ * @param value object to check
1812
+ * @return true if value is a DocumentFragment-shaped node from any realm
1813
+ */
1814
+ const _isDocumentFragment = function _isDocumentFragment(value) {
1815
+ if (!getNodeType || typeof value !== 'object' || value === null) {
1816
+ return false;
1817
+ }
1818
+ try {
1819
+ return getNodeType(value) === NODE_TYPE.documentFragment;
1820
+ } catch (_) {
1821
+ return false;
1822
+ }
1823
+ };
1824
+ /**
1825
+ * Checks whether the given object is a DOM node, including nodes that
1826
+ * originate from a different window/realm (e.g. an iframe's
1827
+ * contentDocument). The previous `value instanceof Node` check was
1828
+ * realm-bound: nodes from a different window failed it, causing
1829
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
1830
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
1831
+ *
1832
+ * @param value object to check whether it's a DOM node
1833
+ * @return true if value is a DOM node from any realm
1834
+ */
1835
+ const _isNode = function _isNode(value) {
1836
+ if (!getNodeType || typeof value !== 'object' || value === null) {
1837
+ return false;
1838
+ }
1839
+ try {
1840
+ return typeof getNodeType(value) === 'number';
1841
+ } catch (_) {
1842
+ return false;
1843
+ }
1844
+ };
1845
+ function _executeHooks(hooks, currentNode, data) {
1846
+ if (hooks.length === 0) {
1847
+ return;
1848
+ }
1849
+ arrayForEach(hooks, hook => {
1850
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1851
+ });
1852
+ }
1853
+ /**
1854
+ * Structural-threat checks that condemn a node regardless of the
1855
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
1856
+ * processing instructions, markup-bearing comments. Pure predicate;
1857
+ * the caller removes. Check order is load-bearing.
1858
+ *
1859
+ * @param currentNode the node to inspect
1860
+ * @param tagName the node's transformCaseFunc'd tag name
1861
+ * @return true if the node must be removed
1862
+ */
1863
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
1864
+ /* Detect mXSS attempts abusing namespace confusion */
1865
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
1866
+ return true;
1867
+ }
1868
+ /* Remove risky CSS construction leading to mXSS */
1869
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
1870
+ return true;
1871
+ }
1872
+ /* Remove any occurrence of processing instructions */
1873
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
1874
+ return true;
1875
+ }
1876
+ /* Remove any kind of possibly harmful comments */
1877
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
1878
+ return true;
1879
+ }
1880
+ return false;
1881
+ };
1882
+ /**
1883
+ * Handle a node whose tag is forbidden or not allowlisted: keep
1884
+ * allowed custom elements (false return exits _sanitizeElements
1885
+ * early - namespace/fallback checks and the afterSanitizeElements
1886
+ * hook are intentionally skipped for kept custom elements), else
1887
+ * hoist content per KEEP_CONTENT and remove.
1888
+ *
1889
+ * @param currentNode the disallowed node
1890
+ * @param tagName the node's transformCaseFunc'd tag name
1891
+ * @return true if the node was removed, false if kept
1892
+ */
1893
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {
1894
+ /* Check if we have a custom element to handle */
1895
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1896
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1897
+ return false;
1898
+ }
1899
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1900
+ return false;
1901
+ }
1902
+ }
1903
+ /* Keep content except for bad-listed elements.
1904
+ Use the cached prototype getters exclusively — the previous code
1905
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
1906
+ fallbacks, but the cached getters always return the canonical
1907
+ value (or null for a real parent-less node), so the fallback
1908
+ path was dead in safe cases and a clobbering surface in unsafe
1909
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
1910
+ parentNode)` check already gates correctly. */
1911
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1912
+ const parentNode = getParentNode(currentNode);
1913
+ const childNodes = getChildNodes(currentNode);
1914
+ if (childNodes && parentNode) {
1915
+ const childCount = childNodes.length;
1916
+ /* In-place: hoist the *original* children so the iterator visits
1917
+ and sanitises them through the same allowlist pass as every other
1918
+ node. The caller built the tree in the live document, so the
1919
+ originals carry already-queued resource events (`<img onerror>`,
1920
+ `<video>`/`<audio>` error, lazy/`onload`, …); cloning would leave
1921
+ those originals detached but still armed, firing in page scope
1922
+ while the returned tree looked clean. Moving is safe in-place: the
1923
+ root is pre-validated as an allowed tag and so is never the node
1924
+ being removed, which keeps `parentNode` inside the iterator root
1925
+ and the relocated child inside the serialised tree.
1926
+ Otherwise (string / DOM-copy paths): clone. The iterator is rooted
1927
+ at — and the result serialised from — `body`, so a restrictive
1928
+ ALLOWED_TAGS that removes `body` itself must leave its content in
1929
+ place, which only cloning does; and those paths parse into an
1930
+ inert document, so their discarded originals never had a queued
1931
+ event to neutralise.
1932
+ `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
1933
+ valid whether we move (drops the trailing entry) or clone (leaves
1934
+ the list intact). */
1935
+ for (let i = childCount - 1; i >= 0; --i) {
1936
+ const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
1937
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
1938
+ }
1939
+ }
1940
+ }
1941
+ _forceRemove(currentNode);
1942
+ return true;
1943
+ };
1944
+ /**
1945
+ * _sanitizeElements
1946
+ *
1947
+ * @protect nodeName
1948
+ * @protect textContent
1949
+ * @protect removeChild
1950
+ * @param currentNode to check for permission to exist
1951
+ * @return true if node was killed, false if left alive
1952
+ */
1953
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1954
+ /* Execute a hook if present */
1955
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1956
+ /* Check if element is clobbered or can clobber */
1957
+ if (_isClobbered(currentNode)) {
1958
+ _forceRemove(currentNode);
1959
+ return true;
1960
+ }
1961
+ /* Now let's check the element's type and name */
1962
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
1963
+ /* Execute a hook if present */
1964
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
1965
+ tagName,
1966
+ allowedTags: ALLOWED_TAGS
1967
+ });
1968
+ /* Remove mXSS vectors, processing instructions and risky comments */
1969
+ if (_isUnsafeNode(currentNode, tagName)) {
1970
+ _forceRemove(currentNode);
1971
+ return true;
1972
+ }
1973
+ /* Remove element if anything forbids its presence */
1974
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1975
+ return _sanitizeDisallowedNode(currentNode, tagName);
1976
+ }
1977
+ /* Check whether element has a valid namespace.
1978
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
1979
+ nodeType getter rather than `instanceof Element`, which is realm-
1980
+ bound and short-circuits to false for any node minted in a different
1981
+ realm — letting a foreign-realm element with a forbidden namespace
1982
+ slip past the namespace check entirely. */
1983
+ const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
1984
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
1985
+ _forceRemove(currentNode);
1986
+ return true;
1987
+ }
1988
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1989
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
1990
+ _forceRemove(currentNode);
1991
+ return true;
1992
+ }
1993
+ /* Sanitize element content to be template-safe */
1994
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1995
+ /* Get the element's text content */
1996
+ const content = _stripTemplateExpressions(currentNode.textContent);
1997
+ if (currentNode.textContent !== content) {
1998
+ arrayPush(DOMPurify.removed, {
1999
+ element: currentNode.cloneNode()
2000
+ });
2001
+ currentNode.textContent = content;
2002
+ }
2003
+ }
2004
+ /* Execute a hook if present */
2005
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2006
+ return false;
2007
+ };
2008
+ /**
2009
+ * _isValidAttribute
2010
+ *
2011
+ * @param lcTag Lowercase tag name of containing element.
2012
+ * @param lcName Lowercase attribute name.
2013
+ * @param value Attribute value.
2014
+ * @return Returns true if `value` is valid, otherwise false.
2015
+ */
2016
+ // eslint-disable-next-line complexity
2017
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
2018
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
2019
+ if (FORBID_ATTR[lcName]) {
2020
+ return false;
2021
+ }
2022
+ /* Make sure attribute cannot clobber */
2023
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
2024
+ return false;
2025
+ }
2026
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
2027
+ /* Allow valid data-* attributes: At least one character after "-"
2028
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
2029
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
2030
+ We don't need to check the value; it's always URI safe. */
2031
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
2032
+ if (
2033
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
2034
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2035
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
2036
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) ||
2037
+ // Alternative, second condition checks if it's an `is`-attribute, AND
2038
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2039
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
2040
+ return false;
2041
+ }
2042
+ /* Check value is safe. First, is attr inert? If so, is safe */
2043
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (value) {
2044
+ return false;
2045
+ } else ;
2046
+ return true;
2047
+ };
2048
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
2049
+ * never be treated as basic custom elements even when a permissive
2050
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
2051
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
2052
+ /**
2053
+ * _isBasicCustomElement
2054
+ * checks if at least one dash is included in tagName, and it's not the first char
2055
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
2056
+ *
2057
+ * @param tagName name of the tag of the node to sanitize
2058
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
2059
+ */
2060
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
2061
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
2062
+ };
2063
+ /**
2064
+ * Wrap an attribute value in the matching Trusted Types object when
2065
+ * the active policy requires it. Namespaced attributes pass through
2066
+ * unchanged (no TT support yet, see
2067
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
2068
+ *
2069
+ * @param lcTag lowercase tag name of the containing element
2070
+ * @param lcName lowercase attribute name
2071
+ * @param namespaceURI the attribute's namespace, if any
2072
+ * @param value the attribute value to wrap
2073
+ * @return the value, wrapped when Trusted Types demand it
2074
+ */
2075
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
2076
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
2077
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2078
+ case 'TrustedHTML':
2079
+ {
2080
+ return _createTrustedHTML(value);
2081
+ }
2082
+ case 'TrustedScriptURL':
2083
+ {
2084
+ return _createTrustedScriptURL(value);
2085
+ }
2086
+ }
2087
+ }
2088
+ return value;
2089
+ };
2090
+ /**
2091
+ * Write a modified attribute value back onto the element. On
2092
+ * success, re-probe for clobbering introduced by the new value and
2093
+ * remove the element when found; otherwise pop the removal entry
2094
+ * recorded by the earlier _removeAttribute (long-standing pairing
2095
+ * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
2096
+ * failure, remove the attribute instead.
2097
+ *
2098
+ * @param currentNode the element carrying the attribute
2099
+ * @param name the attribute name as present on the element
2100
+ * @param namespaceURI the attribute's namespace, if any
2101
+ * @param value the new attribute value
2102
+ */
2103
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2104
+ try {
2105
+ if (namespaceURI) {
2106
+ currentNode.setAttributeNS(namespaceURI, name, value);
2107
+ } else {
2108
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
2109
+ currentNode.setAttribute(name, value);
2110
+ }
2111
+ if (_isClobbered(currentNode)) {
2112
+ _forceRemove(currentNode);
2113
+ } else {
2114
+ arrayPop(DOMPurify.removed);
2115
+ }
2116
+ } catch (_) {
2117
+ _removeAttribute(name, currentNode);
2118
+ }
2119
+ };
2120
+ /**
2121
+ * _sanitizeAttributes
2122
+ *
2123
+ * @protect attributes
2124
+ * @protect nodeName
2125
+ * @protect removeAttribute
2126
+ * @protect setAttribute
2127
+ *
2128
+ * @param currentNode to sanitize
2129
+ */
2130
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
2131
+ /* Execute a hook if present */
2132
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2133
+ const attributes = currentNode.attributes;
2134
+ /* Check if we have attributes; if not we might have a text node */
2135
+ if (!attributes || _isClobbered(currentNode)) {
2136
+ return;
2137
+ }
2138
+ const hookEvent = {
2139
+ attrName: '',
2140
+ attrValue: '',
2141
+ keepAttr: true,
2142
+ allowedAttributes: ALLOWED_ATTR,
2143
+ forceKeepAttr: undefined
2144
+ };
2145
+ let l = attributes.length;
2146
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2147
+ /* Go backwards over all attributes; safely remove bad ones */
2148
+ while (l--) {
2149
+ const attr = attributes[l];
2150
+ const name = attr.name,
2151
+ namespaceURI = attr.namespaceURI,
2152
+ attrValue = attr.value;
2153
+ const lcName = transformCaseFunc(name);
2154
+ const initValue = attrValue;
2155
+ let value = name === 'value' ? initValue : stringTrim(initValue);
2156
+ /* Execute a hook if present */
2157
+ hookEvent.attrName = lcName;
2158
+ hookEvent.attrValue = value;
2159
+ hookEvent.keepAttr = true;
2160
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
2161
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2162
+ value = hookEvent.attrValue;
2163
+ /* Full DOM Clobbering protection via namespace isolation,
2164
+ * Prefix id and name attributes with `user-content-`
2165
+ */
2166
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2167
+ // Remove the attribute with this value
2168
+ _removeAttribute(name, currentNode);
2169
+ // Prefix the value and later re-create the attribute with the sanitized value
2170
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2171
+ }
2172
+ // Else: already prefixed, leave the attribute alone — the prefix is
2173
+ // itself the clobbering protection, and re-applying it is incorrect.
2174
+ /* Work around a security issue with comments inside attributes */
2175
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
2176
+ _removeAttribute(name, currentNode);
2177
+ continue;
2178
+ }
2179
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
2180
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
2181
+ _removeAttribute(name, currentNode);
2182
+ continue;
2183
+ }
2184
+ /* Did the hooks force-keep the attribute? */
2185
+ if (hookEvent.forceKeepAttr) {
2186
+ continue;
2187
+ }
2188
+ /* Did the hooks approve of the attribute? */
2189
+ if (!hookEvent.keepAttr) {
2190
+ _removeAttribute(name, currentNode);
2191
+ continue;
2192
+ }
2193
+ /* Work around a security issue in jQuery 3.0 */
2194
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
2195
+ _removeAttribute(name, currentNode);
2196
+ continue;
2197
+ }
2198
+ /* Sanitize attribute content to be template-safe */
2199
+ if (SAFE_FOR_TEMPLATES) {
2200
+ value = _stripTemplateExpressions(value);
2201
+ }
2202
+ /* Is `value` valid for this attribute? */
2203
+ if (!_isValidAttribute(lcTag, lcName, value)) {
2204
+ _removeAttribute(name, currentNode);
2205
+ continue;
2206
+ }
2207
+ /* Handle attributes that require Trusted Types */
2208
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
2209
+ /* Handle invalid data-* attribute set by try-catching it */
2210
+ if (value !== initValue) {
2211
+ _setAttributeValue(currentNode, name, namespaceURI, value);
2212
+ }
2213
+ }
2214
+ /* Execute a hook if present */
2215
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2216
+ };
2217
+ /**
2218
+ * _sanitizeShadowDOM
2219
+ *
2220
+ * @param fragment to iterate over recursively
2221
+ */
2222
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
2223
+ let shadowNode = null;
2224
+ const shadowIterator = _createNodeIterator(fragment);
2225
+ /* Execute a hook if present */
2226
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2227
+ while (shadowNode = shadowIterator.nextNode()) {
2228
+ /* Execute a hook if present */
2229
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2230
+ /* Sanitize tags and elements */
2231
+ _sanitizeElements(shadowNode);
2232
+ /* Check attributes next */
2233
+ _sanitizeAttributes(shadowNode);
2234
+ /* Deep shadow DOM detected.
2235
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
2236
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
2237
+ recurse into <template>.content from foreign realms too. */
2238
+ if (_isDocumentFragment(shadowNode.content)) {
2239
+ _sanitizeShadowDOM2(shadowNode.content);
2240
+ }
2241
+ /* An element iterated here may itself host an attached
2242
+ shadow root. The default NodeIterator does not enter shadow
2243
+ trees, so a shadow root nested inside template.content was
2244
+ previously reached by no walk at all (the pre-pass at
2245
+ _sanitizeAttachedShadowRoots descends via childNodes, which
2246
+ doesn't enter template.content; the template-content recursion
2247
+ above iterates the content but never inspected shadowRoot).
2248
+ Walk it explicitly. The nodeType guard avoids reading
2249
+ shadowRoot off text / comment / CDATA / PI nodes that the
2250
+ iterator also surfaces. */
2251
+ const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
2252
+ if (shadowNodeType === NODE_TYPE.element) {
2253
+ const innerSr = getShadowRoot(shadowNode);
2254
+ if (_isDocumentFragment(innerSr)) {
2255
+ _sanitizeAttachedShadowRoots(innerSr);
2256
+ _sanitizeShadowDOM2(innerSr);
2257
+ }
2258
+ }
2259
+ }
2260
+ /* Execute a hook if present */
2261
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2262
+ };
2263
+ /**
2264
+ * _sanitizeAttachedShadowRoots
2265
+ *
2266
+ * Walks `root` and feeds every attached shadow root we encounter into
2267
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
2268
+ * does not descend into shadow trees, so nodes inside an attached
2269
+ * shadow root would otherwise be skipped entirely.
2270
+ *
2271
+ * Two real input paths put attached shadow roots in front of us:
2272
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
2273
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
2274
+ * shadow root because it was created with `clonable: true`.
2275
+ *
2276
+ * This pass runs once, up front, so the main iteration loop (and the
2277
+ * existing _sanitizeShadowDOM template-content recursion) stay
2278
+ * untouched — string-input paths are not affected.
2279
+ *
2280
+ * @param root the subtree root to walk for attached shadow roots
2281
+ */
2282
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
2283
+ /* Iterative (explicit stack) rather than per-child recursion. DOM APIs
2284
+ impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
2285
+ built straight into the DOM — the IN_PLACE surface) deeper than the JS
2286
+ call-stack budget would otherwise overflow native recursion here and
2287
+ throw at the IN_PLACE entry pre-pass, before a single node is
2288
+ sanitized, leaving the caller's live tree untouched (fail-open). See
2289
+ campaign-3 F4. A heap stack keeps depth off the call stack.
2290
+ Each work item is either a node to descend into, or a deferred
2291
+ `_sanitizeShadowDOM` for an already-walked shadow root. The deferred
2292
+ form preserves the original post-order discipline: a shadow root's
2293
+ nested shadow roots are discovered before the outer shadow is
2294
+ sanitized (which may remove hosts). Pushes are in reverse of the
2295
+ desired processing order (LIFO): template content, then children, then
2296
+ the shadow-sanitize, then the shadow walk — so the order matches the
2297
+ previous recursion exactly. */
2298
+ const stack = [{
2299
+ node: root,
2300
+ shadow: null
2301
+ }];
2302
+ while (stack.length > 0) {
2303
+ const item = stack.pop();
2304
+ /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
2305
+ if (item.shadow) {
2306
+ _sanitizeShadowDOM2(item.shadow);
2307
+ continue;
2308
+ }
2309
+ const node = item.node;
2310
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2311
+ const isElement = nodeType === NODE_TYPE.element;
2312
+ /* (pushed last → processed first) Children, snapshotted in reverse so
2313
+ the first child is processed first. Snapshotting matters because a
2314
+ hook may detach siblings mid-walk. */
2315
+ const childNodes = getChildNodes(node);
2316
+ if (childNodes) {
2317
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2318
+ stack.push({
2319
+ node: childNodes[i],
2320
+ shadow: null
2321
+ });
2322
+ }
2323
+ }
2324
+ /* (pushed before children → processed after them, matching the old
2325
+ "template content last" order) When the node is a <template>,
2326
+ descend into its content. */
2327
+ if (isElement) {
2328
+ const rootName = getNodeName ? getNodeName(node) : null;
2329
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
2330
+ const content = node.content;
2331
+ if (_isDocumentFragment(content)) {
2332
+ stack.push({
2333
+ node: content,
2334
+ shadow: null
2335
+ });
2336
+ }
2337
+ }
2338
+ }
2339
+ /* Shadow root (processed first): walk its subtree, then sanitise it.
2340
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
2341
+ rather than `instanceof DocumentFragment`, which is realm-bound and
2342
+ silently skipped foreign-realm shadow roots (e.g.
2343
+ iframe.contentDocument attachShadow). */
2344
+ if (isElement) {
2345
+ const sr = getShadowRoot(node);
2346
+ if (_isDocumentFragment(sr)) {
2347
+ /* Push the deferred sanitise first so it pops after the shadow
2348
+ walk we push next, i.e. nested shadow roots are discovered
2349
+ before this one is sanitised. */
2350
+ stack.push({
2351
+ node: null,
2352
+ shadow: sr
2353
+ }, {
2354
+ node: sr,
2355
+ shadow: null
2356
+ });
2357
+ }
2358
+ }
2359
+ }
2360
+ };
2361
+ // eslint-disable-next-line complexity
2362
+ DOMPurify.sanitize = function (dirty) {
2363
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2364
+ let body = null;
2365
+ let importedNode = null;
2366
+ let currentNode = null;
2367
+ let returnNode = null;
2368
+ /* Make sure we have a string to sanitize.
2369
+ DO NOT return early, as this will return the wrong type if
2370
+ the user has requested a DOM object rather than a string */
2371
+ IS_EMPTY_INPUT = !dirty;
2372
+ if (IS_EMPTY_INPUT) {
2373
+ dirty = '<!-->';
2374
+ }
2375
+ /* Stringify, in case dirty is an object */
2376
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
2377
+ dirty = stringifyValue(dirty);
2378
+ if (typeof dirty !== 'string') {
2379
+ throw typeErrorCreate('dirty is not a string, aborting');
2380
+ }
2381
+ }
2382
+ /* Return dirty HTML if DOMPurify cannot run */
2383
+ if (!DOMPurify.isSupported) {
2384
+ return dirty;
2385
+ }
2386
+ /* Assign config vars */
2387
+ if (SET_CONFIG) {
2388
+ /* Persistent setConfig() path: _parseConfig is skipped, so the sets are
2389
+ * not re-derived per call. Restore them from the pristine bindings
2390
+ * captured at setConfig() time so a previous call's hook clone (mutated
2391
+ * below) does not carry over. */
2392
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
2393
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
2394
+ } else {
2395
+ _parseConfig(cfg);
2396
+ }
2397
+ /* Clone the hook-mutable allowlists before the walk whenever an
2398
+ * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
2399
+ * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
2400
+ * a hook that widens them would otherwise mutate the shared set
2401
+ * permanently: across later calls and across every element. Cloning per
2402
+ * walk keeps documented in-call widening working while scoping it to the
2403
+ * call. A single guard for both config paths - the per-call path rebinds
2404
+ * the sets in _parseConfig each call, the persistent path restores them
2405
+ * from the captured bindings just above - so the two cannot diverge. */
2406
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
2407
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
2408
+ }
2409
+ if (hooks.uponSanitizeAttribute.length > 0) {
2410
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
2411
+ }
2412
+ /* Clean up removed elements */
2413
+ DOMPurify.removed = [];
2414
+ /* Resolve IN_PLACE for this call without mutating persistent config.
2415
+ Writing the IN_PLACE closure variable here leaks under setConfig(),
2416
+ where _parseConfig is skipped on later calls: a single string call would
2417
+ disable in-place mode for every subsequent node call, returning a
2418
+ sanitized copy while leaving the caller's node — which in-place callers
2419
+ keep using and whose return value they ignore — unsanitized. REPORT-2. */
2420
+ const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
2421
+ if (inPlace) {
2422
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
2423
+ Read nodeName through the cached prototype getter — a clobbering
2424
+ child named "nodeName" on the form root would otherwise shadow
2425
+ the property and let this check skip the root-allowlist
2426
+ validation entirely. */
2427
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2428
+ if (typeof nn === 'string') {
2429
+ const tagName = transformCaseFunc(nn);
2430
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2431
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
2432
+ }
2433
+ }
2434
+ /* Pre-flight the root through _isClobbered. The iterator-driven
2435
+ removal path can not detach a parent-less root: _forceRemove
2436
+ falls through to Element.prototype.remove(), which per spec
2437
+ is a no-op on a node with no parent. A clobbered root would
2438
+ then survive the main loop with its attributes uninspected,
2439
+ because _sanitizeAttributes early-returns on _isClobbered. The
2440
+ result would be an attacker-controlled form, complete with any
2441
+ event-handler attributes the caller passed in, handed back to
2442
+ the application unsanitized. Refuse to sanitize such a root
2443
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
2444
+ if (_isClobbered(dirty)) {
2445
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
2446
+ }
2447
+ /* Sanitize attached shadow roots before the main iterator runs.
2448
+ The iterator does not descend into shadow trees. Same fail-closed
2449
+ barrier as the main walk (campaign-3 F2): a custom-element reaction
2450
+ inside a shadow root could abort this pre-pass before the walk runs,
2451
+ which would otherwise leave the entire live tree unsanitized. */
2452
+ try {
2453
+ _sanitizeAttachedShadowRoots(dirty);
2454
+ } catch (error) {
2455
+ _neutralizeRoot(dirty);
2456
+ throw error;
2457
+ }
2458
+ } else if (_isNode(dirty)) {
2459
+ /* If dirty is a DOM element, append to an empty document to avoid
2460
+ elements being stripped by the parser */
2461
+ body = _initDocument('<!---->');
2462
+ importedNode = body.ownerDocument.importNode(dirty, true);
2463
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
2464
+ /* Node is already a body, use as is */
2465
+ body = importedNode;
2466
+ } else if (importedNode.nodeName === 'HTML') {
2467
+ body = importedNode;
2468
+ } else {
2469
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
2470
+ body.appendChild(importedNode);
2471
+ }
2472
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
2473
+ them before the main iterator runs, since the iterator does not
2474
+ descend into shadow trees. The walk routes every read through a
2475
+ cached prototype getter so clobbering descendants on a form root
2476
+ cannot hide a shadow host from this pass. */
2477
+ _sanitizeAttachedShadowRoots(importedNode);
2478
+ } else {
2479
+ /* Exit directly if we have nothing to do */
2480
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
2481
+ // eslint-disable-next-line unicorn/prefer-includes
2482
+ dirty.indexOf('<') === -1) {
2483
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
2484
+ }
2485
+ /* Initialize the document to work on */
2486
+ body = _initDocument(dirty);
2487
+ /* Check we have a DOM node from the data */
2488
+ if (!body) {
2489
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
2490
+ }
2491
+ }
2492
+ /* Remove first element node (ours) if FORCE_BODY is set */
2493
+ if (body && FORCE_BODY) {
2494
+ _forceRemove(body.firstChild);
2495
+ }
2496
+ /* Get node iterator */
2497
+ const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
2498
+ /* Now start iterating over the created document.
2499
+ The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
2500
+ engine/custom-element mutation can detach a node mid-walk so
2501
+ `_forceRemove`'s parentless guard throws, aborting the loop. Without the
2502
+ barrier the caller's in-place tree would be left half-sanitized with the
2503
+ unvisited tail still armed. On any throw we fail closed — strip the
2504
+ in-place root bare — then rethrow so the existing throw contract is
2505
+ preserved. (String/DOM-copy paths never return the partial body, so the
2506
+ propagating throw is already fail-closed there.) */
2507
+ try {
2508
+ while (currentNode = nodeIterator.nextNode()) {
2509
+ /* Sanitize tags and elements */
2510
+ _sanitizeElements(currentNode);
2511
+ /* Check attributes next */
2512
+ _sanitizeAttributes(currentNode);
2513
+ /* Shadow DOM detected, sanitize it.
2514
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
2515
+ instead of instanceof, so foreign-realm <template>.content is
2516
+ walked correctly. */
2517
+ if (_isDocumentFragment(currentNode.content)) {
2518
+ _sanitizeShadowDOM2(currentNode.content);
2519
+ }
2520
+ }
2521
+ } catch (error) {
2522
+ if (inPlace) {
2523
+ _neutralizeRoot(dirty);
2524
+ }
2525
+ throw error;
2526
+ }
2527
+ /* If we sanitized `dirty` in-place, return it. */
2528
+ if (inPlace) {
2529
+ /* Fail-closed completion of the audit-5 F1 fix: every node removed from
2530
+ the caller's live tree is detached but may still hold a queued
2531
+ resource-event handler that fires in page scope after we return. The
2532
+ move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
2533
+ non-allow-listed attributes off every other removed subtree (clobber,
2534
+ mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
2535
+ cancelled before any event can fire. Runs synchronously, pre-return. */
2536
+ arrayForEach(DOMPurify.removed, entry => {
2537
+ if (entry.element) {
2538
+ _neutralizeSubtree(entry.element);
2539
+ }
2540
+ });
2541
+ if (SAFE_FOR_TEMPLATES) {
2542
+ _scrubTemplateExpressions2(dirty);
2543
+ }
2544
+ return dirty;
2545
+ }
2546
+ /* Return sanitized string or DOM */
2547
+ if (RETURN_DOM) {
2548
+ if (SAFE_FOR_TEMPLATES) {
2549
+ _scrubTemplateExpressions2(body);
2550
+ }
2551
+ if (RETURN_DOM_FRAGMENT) {
2552
+ returnNode = createDocumentFragment.call(body.ownerDocument);
2553
+ while (body.firstChild) {
2554
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
2555
+ returnNode.appendChild(body.firstChild);
2556
+ }
2557
+ } else {
2558
+ returnNode = body;
2559
+ }
2560
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
2561
+ /*
2562
+ AdoptNode() is not used because internal state is not reset
2563
+ (e.g. the past names map of a HTMLFormElement), this is safe
2564
+ in theory but we would rather not risk another attack vector.
2565
+ The state that is cloned by importNode() is explicitly defined
2566
+ by the specs.
2567
+ */
2568
+ returnNode = importNode.call(originalDocument, returnNode, true);
2569
+ }
2570
+ return returnNode;
2571
+ }
2572
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2573
+ /* Serialize doctype if allowed */
2574
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
2575
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
2576
+ }
2577
+ /* Sanitize final string template-safe */
2578
+ if (SAFE_FOR_TEMPLATES) {
2579
+ serializedHTML = _stripTemplateExpressions(serializedHTML);
2580
+ }
2581
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
2582
+ };
2583
+ DOMPurify.setConfig = function () {
2584
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2585
+ _parseConfig(cfg);
2586
+ SET_CONFIG = true;
2587
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
2588
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
2589
+ };
2590
+ DOMPurify.clearConfig = function () {
2591
+ CONFIG = null;
2592
+ SET_CONFIG = false;
2593
+ SET_CONFIG_ALLOWED_TAGS = null;
2594
+ SET_CONFIG_ALLOWED_ATTR = null;
2595
+ // Drop any caller-supplied Trusted Types policy so it cannot poison later
2596
+ // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
2597
+ // never recreated — Trusted Types throws on duplicate names) is restored by
2598
+ // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
2599
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
2600
+ emptyHTML = '';
2601
+ };
2602
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
2603
+ /* Initialize shared config vars if necessary. */
2604
+ if (!CONFIG) {
2605
+ _parseConfig({});
2606
+ }
2607
+ const lcTag = transformCaseFunc(tag);
2608
+ const lcName = transformCaseFunc(attr);
2609
+ return _isValidAttribute(lcTag, lcName, value);
2610
+ };
2611
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
2612
+ if (typeof hookFunction !== 'function') {
2613
+ return;
2614
+ }
2615
+ /* Reject unknown entry points. Without this, a non-hook key (e.g.
2616
+ * '__proto__') indexes off the prototype chain rather than a real
2617
+ * hook array, and arrayPush then writes to Object.prototype. Guard
2618
+ * with an own-property check against the known hook names. */
2619
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
2620
+ return;
2621
+ }
2622
+ arrayPush(hooks[entryPoint], hookFunction);
2623
+ };
2624
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
2625
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
2626
+ return undefined;
2627
+ }
2628
+ if (hookFunction !== undefined) {
2629
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2630
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
2631
+ }
2632
+ return arrayPop(hooks[entryPoint]);
2633
+ };
2634
+ DOMPurify.removeHooks = function (entryPoint) {
2635
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
2636
+ return;
2637
+ }
2638
+ hooks[entryPoint] = [];
2639
+ };
2640
+ DOMPurify.removeAllHooks = function () {
2641
+ hooks = _createHooksMap();
2642
+ };
2643
+ return DOMPurify;
2644
+ }
2645
+ createDOMPurify();
2646
+
2647
+ const modeDefinitions = [
2648
+ {
2649
+ id: "search",
2650
+ normalize(searchTerm, caseSensitiveSearch) {
2651
+ return caseSensitiveSearch ? searchTerm : searchTerm.toLowerCase();
2652
+ },
2653
+ test(text, normalizedSearchTerm, caseSensitiveSearch, inverseSearch) {
2654
+ const testText = caseSensitiveSearch ? text : text.toLowerCase();
2655
+ const matches = testText.includes(normalizedSearchTerm);
2656
+ return inverseSearch ? !matches : matches;
2657
+ }
2658
+ },
2659
+ {
2660
+ id: "wildcard",
2661
+ normalize(searchTerm, caseSensitiveSearch) {
2662
+ if (searchTerm.length > 0) {
2663
+ const escapedSearchTerm = searchTerm.replace(
2664
+ /[-[\]{}()+.,\\^$|#\s]/g,
2665
+ "\\$&"
2666
+ );
2667
+ const wildcardSearchTerm = escapedSearchTerm.replace(/\*/g, ".*").replace(/\?/g, ".?");
2668
+ searchTerm = `^${wildcardSearchTerm}$`;
2669
+ } else {
2670
+ return { test: () => false };
2671
+ }
2672
+ try {
2673
+ const flags = caseSensitiveSearch ? "" : "i";
2674
+ return new RegExp(searchTerm, flags);
2675
+ } catch (_error) {
2676
+ return /$^/;
2677
+ }
2678
+ },
2679
+ test(text, normalizedSearchTerm, caseSensitiveSearch, inverseSearch) {
2680
+ const matches = normalizedSearchTerm.test(text);
2681
+ return inverseSearch ? !matches : matches;
2682
+ }
2683
+ },
2684
+ {
2685
+ id: "regex",
2686
+ normalize(searchTerm, caseSensitiveSearch) {
2687
+ try {
2688
+ const flags = caseSensitiveSearch ? "" : "i";
2689
+ return new RegExp(`^(${searchTerm})$`, flags);
2690
+ } catch (_error) {
2691
+ return /$^/;
2692
+ }
2693
+ },
2694
+ test(text, normalizedSearchTerm, caseSensitiveSearch, inverseSearch) {
2695
+ const matches = normalizedSearchTerm.test(text);
2696
+ return inverseSearch ? !matches : matches;
2697
+ }
2698
+ },
2699
+ {
2700
+ id: "type",
2701
+ normalize(selectedTypes) {
2702
+ return { test: (type) => selectedTypes.includes(type) };
2703
+ },
2704
+ test(type, normalizedSearchTerm) {
2705
+ if (typeof type === "undefined") {
2706
+ return false;
2707
+ }
2708
+ return normalizedSearchTerm.test(type);
2709
+ }
2710
+ }
2711
+ ];
2712
+ Object.assign({}, ...modeDefinitions.map((obj) => ({ [obj.id]: obj })));
2713
+
400
2714
  const isMac = () => navigator?.userAgent?.toLowerCase()?.includes("mac");
2715
+ const yearsPart = "(\\d+)\\s*y(?:ears?)?";
2716
+ const monthsPart = "(\\d+)\\s*m(?:o(?:nths?)?)?";
2717
+ const weeksPart = "(\\d+)\\s*w(?:eeks?)?";
2718
+ const daysPart = "(\\d+)\\s*d(?:ays?)?";
2719
+ const hoursPart = "(\\d+)\\s*h(?:ours?)?";
2720
+ const minutesPart = "(\\d+)\\s*m(?:in(?:s|utes?)?)?";
2721
+ const secondsPart = "(\\d+)(?:[,.](\\d{1,3}))?\\s*s(?:ec(?:s|onds?)?)?";
2722
+ const humanReadablePeriodRegex = new RegExp(
2723
+ `^(?:${yearsPart})?\\s*(?:${monthsPart})?\\s*(?:${weeksPart})?\\s*(?:${daysPart})?\\s*$`,
2724
+ "i"
2725
+ );
2726
+ const humanReadableDurationRegex = new RegExp(
2727
+ `^(?:${hoursPart})?\\s*(?:${minutesPart})?\\s*(?:${secondsPart})?$`,
2728
+ "i"
2729
+ );
2730
+ new RegExp(
2731
+ `^\\s*-\\s*\\(\\s*${humanReadablePeriodRegex.source.replace(/[$^]/g, "")}\\s*\\)\\s*$`,
2732
+ "i"
2733
+ );
2734
+ new RegExp(
2735
+ `^\\s*-\\s*\\(\\s*${humanReadableDurationRegex.source.replace(/[$^]/g, "")}\\s*\\)\\s*$`,
2736
+ "i"
2737
+ );
401
2738
 
402
2739
  function sleep(ms) {
403
2740
  return new Promise((resolve) => setTimeout(resolve, ms));
404
2741
  }
405
-
406
2742
  const getMetaOrCtrlKey = () => {
407
2743
  return isMac() ? "metaKey" : "ctrlKey";
408
2744
  };
@@ -666,7 +3002,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
666
3002
  })
667
3003
  }, [
668
3004
  createVNode(unref(KdsCheckbox), {
669
- title: "Selection",
3005
+ tooltip: "Selection",
670
3006
  disabled: "",
671
3007
  class: "select-checkbox"
672
3008
  })
@@ -690,7 +3026,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
690
3026
  }
691
3027
  });
692
3028
 
693
- const EmptyRow = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-732e42c3"]]);
3029
+ const EmptyRow = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-f722e2bf"]]);
694
3030
 
695
3031
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
696
3032
  __name: "PlaceholderRow",
@@ -1581,7 +3917,7 @@ const createEditingCellKeydownHandler = ({
1581
3917
 
1582
3918
  const _hoisted_1$c = { class: "page-navigation" };
1583
3919
  const _hoisted_2$8 = { class: "navigation-buttons" };
1584
- const _hoisted_3$5 = { class: "page-count" };
3920
+ const _hoisted_3$4 = { class: "page-count" };
1585
3921
  const _hoisted_4$2 = { class: "navigation-buttons" };
1586
3922
  const _sfc_main$h = /* @__PURE__ */ defineComponent({
1587
3923
  __name: "PageNavigation",
@@ -1618,7 +3954,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
1618
3954
  onClick: _cache[1] || (_cache[1] = ($event) => onPageChange(__props.currentPage - 1))
1619
3955
  }, null, 8, ["disabled"])
1620
3956
  ]),
1621
- createElementVNode("span", _hoisted_3$5, toDisplayString(__props.currentPage) + " of " + toDisplayString(__props.totalPages), 1),
3957
+ createElementVNode("span", _hoisted_3$4, toDisplayString(__props.currentPage) + " of " + toDisplayString(__props.totalPages), 1),
1622
3958
  createElementVNode("div", _hoisted_4$2, [
1623
3959
  createVNode(unref(KdsButton), {
1624
3960
  variant: "transparent",
@@ -1652,7 +3988,7 @@ const _hoisted_2$7 = {
1652
3988
  key: 1,
1653
3989
  class: "row-range-container"
1654
3990
  };
1655
- const _hoisted_3$4 = { class: "subtle" };
3991
+ const _hoisted_3$3 = { class: "subtle" };
1656
3992
  const _hoisted_4$1 = {
1657
3993
  key: 0,
1658
3994
  class: "muted"
@@ -1681,7 +4017,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
1681
4017
  );
1682
4018
  return (_ctx, _cache) => {
1683
4019
  return __props.showTableSize && __props.currentItems === 0 ? (openBlock(), createElementBlock("span", _hoisted_1$b, "No data")) : (openBlock(), createElementBlock("div", _hoisted_2$7, [
1684
- createElementVNode("span", _hoisted_3$4, toDisplayString(__props.rowLabel) + ":", 1),
4020
+ createElementVNode("span", _hoisted_3$3, toDisplayString(__props.rowLabel) + ":", 1),
1685
4021
  hasMultiplePages.value && __props.currentItems ? (openBlock(), createElementBlock("span", _hoisted_4$1, toDisplayString(pageRangeStart.value) + "–" + toDisplayString(pageRangeEnd.value), 1)) : createCommentVNode("", true),
1686
4022
  createElementVNode("span", _hoisted_5, toDisplayString(rowCountText.value), 1)
1687
4023
  ]));
@@ -2044,20 +4380,20 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2044
4380
  }
2045
4381
  });
2046
4382
 
2047
- const FilterControlBody = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-bd4cc5ec"]]);
4383
+ const FilterControlBody = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-e5d5e963"]]);
2048
4384
 
2049
4385
  const _sfc_main$d = { };
2050
4386
 
2051
4387
  const _hoisted_1$8 = { class: "popover" };
2052
4388
  const _hoisted_2$4 = { class: "header" };
2053
- const _hoisted_3$3 = { class: "body" };
4389
+ const _hoisted_3$2 = { class: "body" };
2054
4390
 
2055
4391
  function _sfc_render$3(_ctx, _cache) {
2056
4392
  return (openBlock(), createElementBlock("div", _hoisted_1$8, [
2057
4393
  createElementVNode("span", _hoisted_2$4, [
2058
4394
  renderSlot(_ctx.$slots, "header", {}, undefined, true)
2059
4395
  ]),
2060
- createElementVNode("div", _hoisted_3$3, [
4396
+ createElementVNode("div", _hoisted_3$2, [
2061
4397
  renderSlot(_ctx.$slots, "body", {}, undefined, true)
2062
4398
  ])
2063
4399
  ]))
@@ -2154,7 +4490,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
2154
4490
  "aria-label": "Filter",
2155
4491
  "popover-type": "auto",
2156
4492
  role: "dialog",
2157
- class: "filter-popover"
4493
+ "stretch-inline": "",
4494
+ "max-inline-size": "var(--kds-dimension-component-width-32x)"
2158
4495
  }, {
2159
4496
  default: withCtx(() => [
2160
4497
  createVNode(PopoverContainer, null, {
@@ -2184,8 +4521,6 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
2184
4521
  }
2185
4522
  });
2186
4523
 
2187
- const FilterControl = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-3cd94230"]]);
2188
-
2189
4524
  const _hoisted_1$7 = { class: "body" };
2190
4525
  const NONE_COLUMN_VALUE = "None";
2191
4526
  const _sfc_main$b = /* @__PURE__ */ defineComponent({
@@ -2266,7 +4601,8 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2266
4601
  "popover-type": "auto",
2267
4602
  role: "dialog",
2268
4603
  class: "sort-popover",
2269
- "max-inline-size": "100vw",
4604
+ "stretch-inline": "",
4605
+ "max-inline-size": "var(--kds-dimension-component-width-20x)",
2270
4606
  "onUpdate:modelValue": unref(onPopoverToggle)
2271
4607
  }, {
2272
4608
  default: withCtx(() => [
@@ -2306,14 +4642,14 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2306
4642
  }
2307
4643
  });
2308
4644
 
2309
- const SortControl = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-ad5ee20c"]]);
4645
+ const SortControl = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-0885d523"]]);
2310
4646
 
2311
4647
  const _hoisted_1$6 = { class: "left" };
2312
4648
  const _hoisted_2$3 = {
2313
4649
  key: 0,
2314
4650
  class: "dimension"
2315
4651
  };
2316
- const _hoisted_3$2 = { class: "right" };
4652
+ const _hoisted_3$1 = { class: "right" };
2317
4653
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
2318
4654
  __name: "TableActionBar",
2319
4655
  props: {
@@ -2356,7 +4692,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2356
4692
  return rowText;
2357
4693
  }
2358
4694
  const columnText = formatCount(
2359
- "Columns",
4695
+ "Cols",
2360
4696
  totalNumColumns,
2361
4697
  __props.tableSizes?.currentNumColumns
2362
4698
  );
@@ -2383,7 +4719,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2383
4719
  "sort-control-options": __props.sortControlOptions,
2384
4720
  onColumnSort: _cache[0] || (_cache[0] = (columnId, colDir) => emit("onColumnSort", columnId, colDir))
2385
4721
  }, null, 8, ["col-sort-values", "sort-control-options"])) : createCommentVNode("", true),
2386
- __props.actionConfig.enableFilters ? (openBlock(), createBlock(FilterControl, {
4722
+ __props.actionConfig.enableFilters ? (openBlock(), createBlock(_sfc_main$c, {
2387
4723
  key: 2,
2388
4724
  ref_key: "filterControlRef",
2389
4725
  ref: filterControlRef,
@@ -2392,7 +4728,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2392
4728
  onColumnFilter: _cache[1] || (_cache[1] = (colInd, value) => emit("columnFilter", colInd, value))
2393
4729
  }, null, 8, ["columns", "col-filter-values"])) : createCommentVNode("", true)
2394
4730
  ]),
2395
- createElementVNode("div", _hoisted_3$2, [
4731
+ createElementVNode("div", _hoisted_3$1, [
2396
4732
  __props.actionConfig.enableSearch ? (openBlock(), createBlock(unref(KdsSearchInput), {
2397
4733
  key: 0,
2398
4734
  ariaLabel: "Search table",
@@ -2422,7 +4758,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2422
4758
  }
2423
4759
  });
2424
4760
 
2425
- const TableActionBar = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-96b1acf9"]]);
4761
+ const TableActionBar = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-9181ec3b"]]);
2426
4762
 
2427
4763
  const useHeaderMenuItems = ({
2428
4764
  enableSorting,
@@ -2647,8 +4983,8 @@ const useAutoScrollOnRightEdge = ({
2647
4983
  };
2648
4984
 
2649
4985
  const _hoisted_1$5 = ["tabindex"];
2650
- const _hoisted_2$2 = ["title"];
2651
- const _hoisted_3$1 = {
4986
+ const _hoisted_2$2 = { class: "header-text-container" };
4987
+ const _hoisted_3 = {
2652
4988
  key: 0,
2653
4989
  class: "sub-header-text-container"
2654
4990
  };
@@ -2850,17 +5186,16 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
2850
5186
  ref: mainHeader,
2851
5187
  class: "main-header"
2852
5188
  }, [
2853
- createElementVNode("div", {
2854
- class: "header-text-container",
2855
- title: __props.column.header
2856
- }, [
5189
+ withDirectives((openBlock(), createElementBlock("div", _hoisted_2$2, [
2857
5190
  createElementVNode("span", {
2858
5191
  ref_key: "headerText",
2859
5192
  ref: headerText
2860
5193
  }, toDisplayString(__props.column.header), 513)
2861
- ], 8, _hoisted_2$2)
5194
+ ])), [
5195
+ [unref(vKdsTooltip), __props.column.header, "truncated"]
5196
+ ])
2862
5197
  ], 512),
2863
- __props.column.subHeader ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
5198
+ __props.column.subHeader ? (openBlock(), createElementBlock("div", _hoisted_3, [
2864
5199
  renderSlot(_ctx.$slots, "subHeader", {
2865
5200
  subHeader: __props.column.subHeader
2866
5201
  }, () => [
@@ -2921,7 +5256,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
2921
5256
  }
2922
5257
  });
2923
5258
 
2924
- const HeaderCell = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-f64d6cbe"]]);
5259
+ const HeaderCell = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-04d0c31b"]]);
2925
5260
 
2926
5261
  const _sfc_main$8 = {
2927
5262
  components: {
@@ -3188,7 +5523,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3188
5523
  createVNode(_component_KdsCheckbox, {
3189
5524
  ref: "selection-checkbox",
3190
5525
  class: "select-checkbox",
3191
- title: "Select all rows",
5526
+ tooltip: "Select all rows",
3192
5527
  "model-value": $props.isSelected,
3193
5528
  disabled: $props.tableConfig.disableSelection,
3194
5529
  "onUpdate:modelValue": $options.onSelect
@@ -3260,7 +5595,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3260
5595
  }, null, 6)) : createCommentVNode("", true)
3261
5596
  ]);
3262
5597
  }
3263
- const Header = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$2], ["__scopeId", "data-v-14546b00"]]);
5598
+ const Header = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$2], ["__scopeId", "data-v-302dfb0e"]]);
3264
5599
 
3265
5600
  const _hoisted_1$3 = { class: "sticky-container" };
3266
5601
  const buttonRef = "button";
@@ -3319,12 +5654,11 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3319
5654
 
3320
5655
  const CellExpandButton = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-f204ddf3"]]);
3321
5656
 
3322
- const _hoisted_1$2 = ["title"];
3323
- const _hoisted_2$1 = {
5657
+ const _hoisted_1$2 = {
3324
5658
  ref: "cell-content",
3325
5659
  class: "cell-content"
3326
5660
  };
3327
- const _hoisted_3 = {
5661
+ const _hoisted_2$1 = {
3328
5662
  key: 3,
3329
5663
  class: "cell-text"
3330
5664
  };
@@ -3339,7 +5673,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3339
5673
  noPaddingTopBottom: { type: Boolean },
3340
5674
  noPaddingLeftRight: { type: Boolean },
3341
5675
  text: {},
3342
- title: {},
5676
+ tooltip: {},
3343
5677
  color: {},
3344
5678
  selectOnMove: { type: Boolean },
3345
5679
  colSizeCssVar: {},
@@ -3460,7 +5794,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3460
5794
  watch(() => props.isToBeExpanded, changeExpandedCellViewIfNecessary);
3461
5795
  onMounted(changeExpandedCellViewIfNecessary);
3462
5796
  return (_ctx, _cache) => {
3463
- return openBlock(), createElementBlock("td", {
5797
+ return withDirectives((openBlock(), createElementBlock("td", {
3464
5798
  class: normalizeClass([
3465
5799
  "data-cell",
3466
5800
  {
@@ -3477,7 +5811,6 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3477
5811
  ...paddingTopBottom.value,
3478
5812
  ...dataCellColorStyle.value
3479
5813
  }),
3480
- title: __props.title === null || __props.isSlotted && !__props.isMissing ? void 0 : __props.title,
3481
5814
  onDblclick: _cache[0] || (_cache[0] = (event) => __props.enableExpand && expandAndSelect(event)),
3482
5815
  onPointerenter: _cache[1] || (_cache[1] = ($event) => isHovered.value = true),
3483
5816
  onPointerleave: _cache[2] || (_cache[2] = ($event) => isHovered.value = false),
@@ -3486,7 +5819,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3486
5819
  onPointerdown: onPointerDown,
3487
5820
  onInput: _cache[4] || (_cache[4] = (val) => emit("input", { value: val, cell: _ctx.$el }))
3488
5821
  }, [
3489
- createElementVNode("div", _hoisted_2$1, [
5822
+ createElementVNode("div", _hoisted_1$2, [
3490
5823
  __props.isEditing ? renderSlot(_ctx.$slots, "editable-cell", {
3491
5824
  key: 0,
3492
5825
  cellElement: _ctx.$el
@@ -3496,7 +5829,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3496
5829
  })) : __props.isSlotted ? renderSlot(_ctx.$slots, "default", {
3497
5830
  key: 2,
3498
5831
  width: __props.size - props.defaultLeftRightPadding * 2 - (showCellExpandButton.value ? unref(EXPAND_BUTTON_WIDTH) : 0)
3499
- }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.text), 1)),
5832
+ }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_2$1, toDisplayString(__props.text), 1)),
3500
5833
  showCellExpandButton.value ? (openBlock(), createBlock(CellExpandButton, {
3501
5834
  key: 4,
3502
5835
  toggled: isExpanded.value,
@@ -3504,12 +5837,17 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3504
5837
  onClick: onExpandButtonClick
3505
5838
  }, null, 8, ["toggled"])) : createCommentVNode("", true)
3506
5839
  ], 512)
3507
- ], 46, _hoisted_1$2);
5840
+ ], 38)), [
5841
+ [
5842
+ unref(vKdsTooltip),
5843
+ props.tooltip === null || __props.isSlotted && !__props.isMissing ? void 0 : props.tooltip
5844
+ ]
5845
+ ]);
3508
5846
  };
3509
5847
  }
3510
5848
  });
3511
5849
 
3512
- const CellRenderer = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-8ecc59ac"]]);
5850
+ const CellRenderer = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-2b17463f"]]);
3513
5851
 
3514
5852
  const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3515
5853
  __name: "Cell",
@@ -3536,7 +5874,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3536
5874
  const unpackedValue = computed(
3537
5875
  () => unpackObjectRepresentation(props.cellData)
3538
5876
  );
3539
- const title = computed(() => {
5877
+ const tooltip = computed(() => {
3540
5878
  const { cellData } = props;
3541
5879
  if (isMissingValue(cellData)) {
3542
5880
  return getMissingValueMessage(cellData);
@@ -3561,7 +5899,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3561
5899
  "is-missing": isMissing.value,
3562
5900
  "is-slotted": __props.column.hasSlotContent ?? false,
3563
5901
  text: unpackedValue.value,
3564
- title: title.value,
5902
+ tooltip: tooltip.value,
3565
5903
  color: color.value,
3566
5904
  "select-on-move": __props.selectOnMove,
3567
5905
  "default-top-bottom-padding": __props.defaultTopBottomPadding,
@@ -3588,7 +5926,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3588
5926
  ])
3589
5927
  };
3590
5928
  })
3591
- ]), 1032, ["is-missing", "is-slotted", "text", "title", "color", "select-on-move", "default-top-bottom-padding", "default-left-right-padding", "no-padding-left-right", "no-padding-top-bottom", "col-size-css-var", "size", "enable-expand", "is-selected", "is-in-cell-selection", "is-to-be-expanded", "is-editing"]);
5929
+ ]), 1032, ["is-missing", "is-slotted", "text", "tooltip", "color", "select-on-move", "default-top-bottom-padding", "default-left-right-padding", "no-padding-left-right", "no-padding-top-bottom", "col-size-css-var", "size", "enable-expand", "is-selected", "is-in-cell-selection", "is-to-be-expanded", "is-editing"]);
3592
5930
  };
3593
5931
  }
3594
5932
  });
@@ -3814,7 +6152,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3814
6152
  createVNode(unref(KdsCheckbox), {
3815
6153
  ref_key: "selectionCheckbox",
3816
6154
  ref: selectionCheckbox,
3817
- title: "Select row",
6155
+ tooltip: "Select row",
3818
6156
  class: "select-checkbox",
3819
6157
  "model-value": __props.isSelected,
3820
6158
  disabled: __props.tableConfig.disableSelection,
@@ -3903,7 +6241,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3903
6241
  }
3904
6242
  });
3905
6243
 
3906
- const Row = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-8b00de21"]]);
6244
+ const Row = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-1e8298b4"]]);
3907
6245
 
3908
6246
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3909
6247
  __name: "CellSelectionOverlay",
@@ -5178,7 +7516,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
5178
7516
  columns: $props.columns,
5179
7517
  "col-filter-values": $props.colFilterValues,
5180
7518
  "col-sort-values": $props.colSortValues,
5181
- "is-selected": $props.tableState.totalSelected > 0,
7519
+ "is-selected": Boolean($props.tableState.totalSelected),
5182
7520
  "get-drag-handle-height": getDragHandleHeight,
5183
7521
  class: normalizeClass([
5184
7522
  "table-header",
@@ -5248,7 +7586,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
5248
7586
  ], 544)
5249
7587
  ]);
5250
7588
  }
5251
- const TableUI = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-51f46838"]]);
7589
+ const TableUI = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-5dec2b59"]]);
5252
7590
 
5253
7591
  const useTableReady = ({ onReady }) => {
5254
7592
  const autoSizesInitialized = ref(false);