bkui-vue 2.0.2-beta.7 → 2.0.2-beta.70
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.
- package/License.txt +1 -2
- package/dist/cli.css +1 -0
- package/dist/index.cjs.js +165 -138
- package/dist/index.esm.js +24235 -18488
- package/dist/index.umd.js +165 -138
- package/dist/locale/en.esm.js.map +1 -1
- package/dist/locale/en.umd.js.map +1 -1
- package/dist/locale/ja-jp.esm.js +2 -0
- package/dist/locale/ja-jp.esm.js.map +1 -0
- package/dist/locale/ja-jp.umd.js +2 -0
- package/dist/locale/ja-jp.umd.js.map +1 -0
- package/dist/locale/zh-cn.esm.js.map +1 -1
- package/dist/locale/zh-cn.umd.js.map +1 -1
- package/dist/style.variable.css +1 -1
- package/lib/affix/affix.variable.css +2 -1
- package/lib/affix/index.js +2 -2
- package/lib/alert/alert.variable.css +2 -1
- package/lib/alert/index.js +16 -5
- package/lib/animate-number/index.js +2 -2
- package/lib/backtop/backtop.variable.css +2 -1
- package/lib/backtop/index.js +2 -2
- package/lib/badge/badge.variable.css +2 -1
- package/lib/badge/index.js +2 -2
- package/lib/breadcrumb/breadcrumb.variable.css +2 -1
- package/lib/breadcrumb/index.js +3 -3
- package/lib/button/button.d.ts +1 -1
- package/lib/button/button.variable.css +2 -1
- package/lib/button/index.js +3 -3
- package/lib/card/card.variable.css +2 -1
- package/lib/card/index.js +2 -2
- package/lib/cascader/cascader.css +26 -24
- package/lib/cascader/cascader.d.ts +311 -0
- package/lib/cascader/cascader.less +78 -76
- package/lib/cascader/cascader.variable.css +28 -25
- package/lib/cascader/index.d.ts +610 -0
- package/lib/cascader/index.js +107 -49
- package/lib/checkbox/checkbox.variable.css +2 -1
- package/lib/checkbox/index.js +5 -5
- package/lib/code-diff/code-diff.variable.css +2 -1
- package/lib/code-diff/index.js +2 -2
- package/lib/collapse/collapse.variable.css +2 -1
- package/lib/collapse/index.js +3 -3
- package/lib/collapse-transition/collapse-transition.variable.css +2 -1
- package/lib/collapse-transition/index.js +2 -2
- package/lib/color-picker/color-picker.variable.css +2 -1
- package/lib/color-picker/index.js +62 -55
- package/lib/components.js +1 -1
- package/lib/config-provider/config-provider.variable.css +2 -1
- package/lib/config-provider/index.d.ts +1 -1
- package/lib/config-provider/index.js +6 -6
- package/lib/container/container.variable.css +2 -1
- package/lib/container/index.js +5 -5
- package/lib/date-picker/date-picker.d.ts +2 -1
- package/lib/date-picker/date-picker.variable.css +2 -1
- package/lib/date-picker/index.d.ts +6 -2
- package/lib/date-picker/index.js +77 -76
- package/lib/date-picker/panel/date-range.d.ts +2 -1
- package/lib/date-picker/panel/time.d.ts +1 -1
- package/lib/date-picker/utils.d.ts +5 -17
- package/lib/dialog/dialog.css +20 -1
- package/lib/dialog/dialog.variable.css +22 -2
- package/lib/dialog/index.js +13 -36
- package/lib/directives/index.js +6 -9
- package/lib/dist.index.js +1 -1
- package/lib/divider/divider.variable.css +2 -1
- package/lib/divider/index.js +3 -3
- package/lib/dropdown/dropdown.d.ts +1 -0
- package/lib/dropdown/dropdown.variable.css +2 -1
- package/lib/dropdown/index.d.ts +3 -0
- package/lib/dropdown/index.js +15 -10
- package/lib/exception/exception.variable.css +2 -1
- package/lib/exception/index.js +2 -2
- package/lib/fixed-navbar/fixed-navbar.variable.css +2 -1
- package/lib/fixed-navbar/index.js +2 -2
- package/lib/form/form-item.d.ts +19 -0
- package/lib/form/form.css +16 -4
- package/lib/form/form.less +24 -6
- package/lib/form/form.variable.css +18 -5
- package/lib/form/index.d.ts +13 -0
- package/lib/form/index.js +41 -50
- package/lib/hooks.js +1 -1
- package/lib/icon/angle-double-down-line.js +1 -1
- package/lib/icon/angle-double-left-line.js +1 -1
- package/lib/icon/angle-double-left.js +1 -1
- package/lib/icon/angle-double-right-line.js +1 -1
- package/lib/icon/angle-double-right.js +1 -1
- package/lib/icon/angle-double-up-line.js +1 -1
- package/lib/icon/angle-down-fill.js +1 -1
- package/lib/icon/angle-down-line.js +1 -1
- package/lib/icon/angle-down.js +1 -1
- package/lib/icon/angle-left.js +1 -1
- package/lib/icon/angle-right.js +1 -1
- package/lib/icon/angle-up-fill.js +1 -1
- package/lib/icon/angle-up.js +1 -1
- package/lib/icon/archive-fill.js +1 -1
- package/lib/icon/arrows-left.js +1 -1
- package/lib/icon/arrows-right.js +1 -1
- package/lib/icon/assistant.js +1 -1
- package/lib/icon/audio-fill.js +1 -1
- package/lib/icon/bk.js +1 -1
- package/lib/icon/circle.js +1 -1
- package/lib/icon/close-line.js +1 -1
- package/lib/icon/close.js +1 -1
- package/lib/icon/code.js +1 -1
- package/lib/icon/cog-shape.js +1 -1
- package/lib/icon/collapse-left.js +1 -1
- package/lib/icon/copy-shape.js +1 -1
- package/lib/icon/copy.js +1 -1
- package/lib/icon/data-shape.js +1 -1
- package/lib/icon/del.js +1 -1
- package/lib/icon/doc-fill.js +1 -1
- package/lib/icon/done.js +1 -1
- package/lib/icon/down-shape.js +1 -1
- package/lib/icon/down-small.js +1 -1
- package/lib/icon/edit-line.js +1 -1
- package/lib/icon/ellipsis.js +1 -1
- package/lib/icon/enlarge-line.js +1 -1
- package/lib/icon/error.js +1 -1
- package/lib/icon/excel-fill.js +1 -1
- package/lib/icon/exclamation-circle-shape.js +1 -1
- package/lib/icon/eye.js +1 -1
- package/lib/icon/filliscreen-line.js +1 -1
- package/lib/icon/fix-line.js +1 -1
- package/lib/icon/fix-shape.js +1 -1
- package/lib/icon/folder-open.js +1 -1
- package/lib/icon/folder-shape-open.js +1 -1
- package/lib/icon/folder-shape.js +1 -1
- package/lib/icon/folder.js +1 -1
- package/lib/icon/funnel.js +1 -1
- package/lib/icon/grag-fill.js +1 -1
- package/lib/icon/help-document-fill.js +1 -1
- package/lib/icon/help-fill.js +1 -1
- package/lib/icon/help.js +1 -1
- package/lib/icon/image-fill.js +1 -1
- package/lib/icon/img-error.js +1 -1
- package/lib/icon/img-placehoulder.js +1 -1
- package/lib/icon/index.js +1 -1
- package/lib/icon/info-line.js +1 -1
- package/lib/icon/info.js +1 -1
- package/lib/icon/left-shape.js +1 -1
- package/lib/icon/left-turn-line.js +1 -1
- package/lib/icon/loading.js +1 -1
- package/lib/icon/narrow-line.js +1 -1
- package/lib/icon/original.js +1 -1
- package/lib/icon/pdf-fill.js +1 -1
- package/lib/icon/play-shape.js +1 -1
- package/lib/icon/plus.js +1 -1
- package/lib/icon/ppt-fill.js +1 -1
- package/lib/icon/qq.js +1 -1
- package/lib/icon/right-shape.js +1 -1
- package/lib/icon/right-turn-line.js +1 -1
- package/lib/icon/search.js +1 -1
- package/lib/icon/share.js +1 -1
- package/lib/icon/spinner.js +1 -1
- package/lib/icon/success.js +1 -1
- package/lib/icon/switcher-loading.js +1 -1
- package/lib/icon/text-all.js +1 -1
- package/lib/icon/text-file.js +1 -1
- package/lib/icon/text-fill.js +1 -1
- package/lib/icon/transfer.js +1 -1
- package/lib/icon/tree-application-shape.js +1 -1
- package/lib/icon/unfull-screen.js +1 -1
- package/lib/icon/unvisible.js +1 -1
- package/lib/icon/up-shape.js +1 -1
- package/lib/icon/upload.js +1 -1
- package/lib/icon/video-fill.js +1 -1
- package/lib/icon/warn.js +1 -1
- package/lib/icon/weixin-pro.js +1 -1
- package/lib/icon/weixin.js +1 -1
- package/lib/image/image-viewer.variable.css +2 -1
- package/lib/image/image.variable.css +2 -1
- package/lib/image/index.js +9 -12
- package/lib/index.js +1 -1
- package/lib/info-box/index.js +22 -7
- package/lib/info-box/info-box.css +20 -1
- package/lib/info-box/info-box.d.ts +1 -0
- package/lib/info-box/info-box.less +28 -2
- package/lib/info-box/info-box.variable.css +23 -3
- package/lib/input/index.d.ts +39 -20
- package/lib/input/index.js +44 -27
- package/lib/input/input.css +6 -0
- package/lib/input/input.d.ts +30 -16
- package/lib/input/input.less +7 -0
- package/lib/input/input.variable.css +8 -1
- package/lib/link/index.js +2 -2
- package/lib/link/link.variable.css +2 -1
- package/lib/loading/index.js +3 -3
- package/lib/loading/loading.variable.css +2 -1
- package/lib/locale/index.d.ts +1 -0
- package/lib/locale/index.js +172 -4
- package/lib/locale/lang/ja-jp.d.ts +3 -0
- package/lib/menu/index.js +12 -9
- package/lib/menu/menu.css +5 -4
- package/lib/menu/menu.less +1 -0
- package/lib/menu/menu.variable.css +7 -5
- package/lib/menu/submenu.variable.css +2 -1
- package/lib/message/index.js +4 -4
- package/lib/message/message.variable.css +2 -1
- package/lib/modal/index.js +14 -6
- package/lib/modal/modal.css +20 -1
- package/lib/modal/modal.variable.css +22 -2
- package/lib/navigation/index.js +3 -3
- package/lib/navigation/navigation.css +29 -29
- package/lib/navigation/navigation.less +29 -29
- package/lib/navigation/navigation.variable.css +31 -30
- package/lib/notify/index.js +3 -3
- package/lib/notify/notify.variable.css +2 -1
- package/lib/overflow-title/index.js +3 -3
- package/lib/pagination/index.js +22 -14
- package/lib/pagination/pagination.css +1 -0
- package/lib/pagination/pagination.less +1 -0
- package/lib/pagination/pagination.variable.css +3 -1
- package/lib/pop-confirm/index.d.ts +584 -0
- package/lib/pop-confirm/index.js +10 -6
- package/lib/pop-confirm/pop-confirm.d.ts +292 -0
- package/lib/pop-confirm/pop-confirm.variable.css +2 -1
- package/lib/pop-confirm/props.d.ts +146 -0
- package/lib/popover/index.js +18 -21
- package/lib/popover/popover.variable.css +2 -1
- package/lib/popover2/index.js +2 -2
- package/lib/preset.js +1 -1
- package/lib/process/index.js +2 -2
- package/lib/process/process.d.ts +1 -1
- package/lib/process/process.variable.css +2 -1
- package/lib/progress/index.js +4 -4
- package/lib/progress/progress.variable.css +2 -1
- package/lib/radio/index.js +5 -5
- package/lib/radio/radio.variable.css +2 -1
- package/lib/rate/index.js +3 -3
- package/lib/rate/rate.variable.css +2 -1
- package/lib/resize-layout/index.js +2 -2
- package/lib/resize-layout/resize-layout.css +1 -0
- package/lib/resize-layout/resize-layout.less +1 -0
- package/lib/resize-layout/resize-layout.variable.css +3 -1
- package/lib/scrollbar/css/scrollbar.variable.css +2 -1
- package/lib/scrollbar/index.js +6 -6
- package/lib/search-select/index.d.ts +39 -11
- package/lib/search-select/index.js +86 -37
- package/lib/search-select/input.d.ts +5 -1
- package/lib/search-select/search-select.d.ts +13 -4
- package/lib/search-select/search-select.variable.css +2 -1
- package/lib/search-select/selected.d.ts +10 -2
- package/lib/search-select/utils.d.ts +1 -0
- package/lib/select/index.d.ts +22 -3
- package/lib/select/index.js +34 -28
- package/lib/select/select.d.ts +11 -1
- package/lib/select/select.variable.css +2 -1
- package/lib/shared/index.d.ts +1 -1
- package/lib/shared/index.js +10 -10
- package/lib/shared/z-index-manager.d.ts +1 -1
- package/lib/sideslider/index.js +5 -3
- package/lib/sideslider/sideslider.variable.css +2 -1
- package/lib/slider/index.d.ts +1 -1
- package/lib/slider/index.js +5 -4
- package/lib/slider/slider-button.d.ts +1 -1
- package/lib/slider/slider.d.ts +1 -1
- package/lib/slider/slider.variable.css +2 -1
- package/lib/steps/index.js +2 -2
- package/lib/steps/steps.d.ts +1 -1
- package/lib/steps/steps.variable.css +2 -1
- package/lib/styles/mixins/animate.variable.css +2 -1
- package/lib/styles/mixins/popper.variable.css +2 -1
- package/lib/styles/mixins/scroll.variable.css +2 -1
- package/lib/styles/reset.variable.css +2 -1
- package/lib/styles/themes/themes.less +4 -1
- package/lib/swiper/index.js +2 -2
- package/lib/swiper/swiper.variable.css +2 -1
- package/lib/switcher/index.js +2 -2
- package/lib/switcher/switcher.variable.css +2 -1
- package/lib/tab/index.d.ts +12 -0
- package/lib/tab/index.js +20 -17
- package/lib/tab/props.d.ts +3 -0
- package/lib/tab/tab.d.ts +6 -0
- package/lib/tab/tab.variable.css +2 -1
- package/lib/table/index.js +33 -36
- package/lib/table/plugins/head-filter.variable.css +2 -1
- package/lib/table/plugins/head-sort.variable.css +2 -1
- package/lib/table/plugins/settings.variable.css +2 -1
- package/lib/table/table.css +1 -0
- package/lib/table/table.variable.css +3 -1
- package/lib/table-column/index.js +1 -1
- package/lib/tag/index.js +2 -2
- package/lib/tag/tag.variable.css +2 -1
- package/lib/tag-input/index.d.ts +9 -0
- package/lib/tag-input/index.js +1569 -42
- package/lib/tag-input/tag-input.css +16 -0
- package/lib/tag-input/tag-input.d.ts +17 -2
- package/lib/tag-input/tag-input.less +16 -0
- package/lib/tag-input/tag-input.variable.css +18 -1
- package/lib/tag-input/tag-render.d.ts +24 -2
- package/lib/time-picker/index.js +1 -1
- package/lib/time-picker/time-picker.variable.css +2 -1
- package/lib/timeline/index.js +1353 -4
- package/lib/timeline/timeline.d.ts +1 -1
- package/lib/timeline/timeline.variable.css +2 -1
- package/lib/transfer/index.d.ts +1 -24
- package/lib/transfer/index.js +21 -11
- package/lib/transfer/props.d.ts +0 -5
- package/lib/transfer/transfer.css +26 -8
- package/lib/transfer/transfer.d.ts +1 -12
- package/lib/transfer/transfer.less +18 -8
- package/lib/transfer/transfer.variable.css +28 -9
- package/lib/tree/constant.d.ts +2 -0
- package/lib/tree/index.d.ts +48 -11
- package/lib/tree/index.js +17650 -106
- package/lib/tree/props.d.ts +30 -3
- package/lib/tree/tree.css +46 -0
- package/lib/tree/tree.d.ts +22 -5
- package/lib/tree/tree.less +57 -2
- package/lib/tree/tree.variable.css +48 -1
- package/lib/tree/use-array-move.d.ts +6 -0
- package/lib/tree/use-node-action.d.ts +2 -2
- package/lib/tree/use-node-attribute.d.ts +3 -0
- package/lib/upload/index.js +8 -8
- package/lib/upload/upload.variable.css +2 -1
- package/lib/virtual-render/index.js +7 -7
- package/lib/virtual-render/virtual-render.variable.css +2 -1
- package/lib/volar.components.d.ts +2 -1
- package/package.json +13 -2
- package/dist/style.css +0 -1
package/lib/tag-input/index.js
CHANGED
|
@@ -789,7 +789,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
789
789
|
* Tencent is pleased to support the open source community by making
|
|
790
790
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
791
791
|
*
|
|
792
|
-
* Copyright (C)
|
|
792
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
793
793
|
*
|
|
794
794
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
795
795
|
*
|
|
@@ -1017,7 +1017,7 @@ function clickoutside_arrayLikeToArray(arr, len) { if (len == null || len > arr.
|
|
|
1017
1017
|
* Tencent is pleased to support the open source community by making
|
|
1018
1018
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1019
1019
|
*
|
|
1020
|
-
* Copyright (C)
|
|
1020
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1021
1021
|
*
|
|
1022
1022
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1023
1023
|
*
|
|
@@ -1145,7 +1145,7 @@ const popover_namespaceObject = popover_x({ ["$bkPopover"]: () => __WEBPACK_EXTE
|
|
|
1145
1145
|
* Tencent is pleased to support the open source community by making
|
|
1146
1146
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1147
1147
|
*
|
|
1148
|
-
* Copyright (C)
|
|
1148
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1149
1149
|
*
|
|
1150
1150
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1151
1151
|
*
|
|
@@ -1257,7 +1257,7 @@ var normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(normalize_wheel
|
|
|
1257
1257
|
* Tencent is pleased to support the open source community by making
|
|
1258
1258
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1259
1259
|
*
|
|
1260
|
-
* Copyright (C)
|
|
1260
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1261
1261
|
*
|
|
1262
1262
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1263
1263
|
*
|
|
@@ -1308,7 +1308,7 @@ function tooltips_objectSpread(e) { for (var r = 1; r < arguments.length; r++) {
|
|
|
1308
1308
|
* Tencent is pleased to support the open source community by making
|
|
1309
1309
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1310
1310
|
*
|
|
1311
|
-
* Copyright (C)
|
|
1311
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1312
1312
|
*
|
|
1313
1313
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1314
1314
|
*
|
|
@@ -1363,9 +1363,6 @@ var tooltips = {
|
|
|
1363
1363
|
hide(el);
|
|
1364
1364
|
}, 100);
|
|
1365
1365
|
});
|
|
1366
|
-
el.addEventListener('click', function () {
|
|
1367
|
-
hide(el);
|
|
1368
|
-
});
|
|
1369
1366
|
popper.addEventListener('mouseleave', function () {
|
|
1370
1367
|
clearTimeout(delayTimeout);
|
|
1371
1368
|
hideTimeout = setTimeout(function () {
|
|
@@ -1379,7 +1376,7 @@ var tooltips = {
|
|
|
1379
1376
|
show(el);
|
|
1380
1377
|
clearTimeout(delayTimeout);
|
|
1381
1378
|
}, opts.delay);
|
|
1382
|
-
} else if (popper.hasAttribute('data-show')) {
|
|
1379
|
+
} else if (!el.contains(event.target) && popper.hasAttribute('data-show')) {
|
|
1383
1380
|
hide(el);
|
|
1384
1381
|
}
|
|
1385
1382
|
});
|
|
@@ -1603,7 +1600,7 @@ const external_overflow_title_namespaceObject = external_overflow_title_x({ });
|
|
|
1603
1600
|
* Tencent is pleased to support the open source community by making
|
|
1604
1601
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1605
1602
|
*
|
|
1606
|
-
* Copyright (C)
|
|
1603
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1607
1604
|
*
|
|
1608
1605
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1609
1606
|
*
|
|
@@ -1655,13 +1652,1361 @@ const debounce_namespaceObject = debounce_x({ ["default"]: () => __WEBPACK_EXTER
|
|
|
1655
1652
|
var trim_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
1656
1653
|
var trim_y = x => () => x
|
|
1657
1654
|
const trim_namespaceObject = trim_x({ ["default"]: () => __WEBPACK_EXTERNAL_MODULE_lodash_trim_5cdad98c__["default"] });
|
|
1655
|
+
;// CONCATENATED MODULE: ../../node_modules/dompurify/dist/purify.es.mjs
|
|
1656
|
+
/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */
|
|
1657
|
+
|
|
1658
|
+
const {
|
|
1659
|
+
entries,
|
|
1660
|
+
setPrototypeOf,
|
|
1661
|
+
isFrozen,
|
|
1662
|
+
getPrototypeOf,
|
|
1663
|
+
getOwnPropertyDescriptor
|
|
1664
|
+
} = Object;
|
|
1665
|
+
let {
|
|
1666
|
+
freeze,
|
|
1667
|
+
seal,
|
|
1668
|
+
create
|
|
1669
|
+
} = Object; // eslint-disable-line import/no-mutable-exports
|
|
1670
|
+
let {
|
|
1671
|
+
apply,
|
|
1672
|
+
construct
|
|
1673
|
+
} = typeof Reflect !== 'undefined' && Reflect;
|
|
1674
|
+
if (!freeze) {
|
|
1675
|
+
freeze = function freeze(x) {
|
|
1676
|
+
return x;
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
if (!seal) {
|
|
1680
|
+
seal = function seal(x) {
|
|
1681
|
+
return x;
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
if (!apply) {
|
|
1685
|
+
apply = function apply(fun, thisValue, args) {
|
|
1686
|
+
return fun.apply(thisValue, args);
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
if (!construct) {
|
|
1690
|
+
construct = function construct(Func, args) {
|
|
1691
|
+
return new Func(...args);
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
const arrayForEach = unapply(Array.prototype.forEach);
|
|
1695
|
+
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
1696
|
+
const arrayPop = unapply(Array.prototype.pop);
|
|
1697
|
+
const arrayPush = unapply(Array.prototype.push);
|
|
1698
|
+
const arraySplice = unapply(Array.prototype.splice);
|
|
1699
|
+
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
1700
|
+
const stringToString = unapply(String.prototype.toString);
|
|
1701
|
+
const stringMatch = unapply(String.prototype.match);
|
|
1702
|
+
const stringReplace = unapply(String.prototype.replace);
|
|
1703
|
+
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
1704
|
+
const stringTrim = unapply(String.prototype.trim);
|
|
1705
|
+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
1706
|
+
const regExpTest = unapply(RegExp.prototype.test);
|
|
1707
|
+
const typeErrorCreate = unconstruct(TypeError);
|
|
1708
|
+
/**
|
|
1709
|
+
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
1710
|
+
*
|
|
1711
|
+
* @param func - The function to be wrapped and called.
|
|
1712
|
+
* @returns A new function that calls the given function with a specified thisArg and arguments.
|
|
1713
|
+
*/
|
|
1714
|
+
function unapply(func) {
|
|
1715
|
+
return function (thisArg) {
|
|
1716
|
+
if (thisArg instanceof RegExp) {
|
|
1717
|
+
thisArg.lastIndex = 0;
|
|
1718
|
+
}
|
|
1719
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1720
|
+
args[_key - 1] = arguments[_key];
|
|
1721
|
+
}
|
|
1722
|
+
return apply(func, thisArg, args);
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
|
1727
|
+
*
|
|
1728
|
+
* @param func - The constructor function to be wrapped and called.
|
|
1729
|
+
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
|
|
1730
|
+
*/
|
|
1731
|
+
function unconstruct(func) {
|
|
1732
|
+
return function () {
|
|
1733
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1734
|
+
args[_key2] = arguments[_key2];
|
|
1735
|
+
}
|
|
1736
|
+
return construct(func, args);
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Add properties to a lookup table
|
|
1741
|
+
*
|
|
1742
|
+
* @param set - The set to which elements will be added.
|
|
1743
|
+
* @param array - The array containing elements to be added to the set.
|
|
1744
|
+
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
|
1745
|
+
* @returns The modified set with added elements.
|
|
1746
|
+
*/
|
|
1747
|
+
function addToSet(set, array) {
|
|
1748
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
1749
|
+
if (setPrototypeOf) {
|
|
1750
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
1751
|
+
// independent of any properties defined on Object.prototype.
|
|
1752
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
1753
|
+
setPrototypeOf(set, null);
|
|
1754
|
+
}
|
|
1755
|
+
let l = array.length;
|
|
1756
|
+
while (l--) {
|
|
1757
|
+
let element = array[l];
|
|
1758
|
+
if (typeof element === 'string') {
|
|
1759
|
+
const lcElement = transformCaseFunc(element);
|
|
1760
|
+
if (lcElement !== element) {
|
|
1761
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
1762
|
+
if (!isFrozen(array)) {
|
|
1763
|
+
array[l] = lcElement;
|
|
1764
|
+
}
|
|
1765
|
+
element = lcElement;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
set[element] = true;
|
|
1769
|
+
}
|
|
1770
|
+
return set;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Clean up an array to harden against CSPP
|
|
1774
|
+
*
|
|
1775
|
+
* @param array - The array to be cleaned.
|
|
1776
|
+
* @returns The cleaned version of the array
|
|
1777
|
+
*/
|
|
1778
|
+
function cleanArray(array) {
|
|
1779
|
+
for (let index = 0; index < array.length; index++) {
|
|
1780
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
1781
|
+
if (!isPropertyExist) {
|
|
1782
|
+
array[index] = null;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
return array;
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Shallow clone an object
|
|
1789
|
+
*
|
|
1790
|
+
* @param object - The object to be cloned.
|
|
1791
|
+
* @returns A new object that copies the original.
|
|
1792
|
+
*/
|
|
1793
|
+
function clone(object) {
|
|
1794
|
+
const newObject = create(null);
|
|
1795
|
+
for (const [property, value] of entries(object)) {
|
|
1796
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
1797
|
+
if (isPropertyExist) {
|
|
1798
|
+
if (Array.isArray(value)) {
|
|
1799
|
+
newObject[property] = cleanArray(value);
|
|
1800
|
+
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
1801
|
+
newObject[property] = clone(value);
|
|
1802
|
+
} else {
|
|
1803
|
+
newObject[property] = value;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
return newObject;
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
1811
|
+
*
|
|
1812
|
+
* @param object - The object to look up the getter function in its prototype chain.
|
|
1813
|
+
* @param prop - The property name for which to find the getter function.
|
|
1814
|
+
* @returns The getter function found in the prototype chain or a fallback function.
|
|
1815
|
+
*/
|
|
1816
|
+
function lookupGetter(object, prop) {
|
|
1817
|
+
while (object !== null) {
|
|
1818
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
1819
|
+
if (desc) {
|
|
1820
|
+
if (desc.get) {
|
|
1821
|
+
return unapply(desc.get);
|
|
1822
|
+
}
|
|
1823
|
+
if (typeof desc.value === 'function') {
|
|
1824
|
+
return unapply(desc.value);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
object = getPrototypeOf(object);
|
|
1828
|
+
}
|
|
1829
|
+
function fallbackValue() {
|
|
1830
|
+
return null;
|
|
1831
|
+
}
|
|
1832
|
+
return fallbackValue;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
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', 'section', 'select', 'shadow', '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']);
|
|
1836
|
+
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
1837
|
+
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']);
|
|
1838
|
+
// List of SVG elements that are disallowed by default.
|
|
1839
|
+
// We still need to know them so that we can do namespace
|
|
1840
|
+
// checks properly in case one wants to add them to
|
|
1841
|
+
// allow-list.
|
|
1842
|
+
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']);
|
|
1843
|
+
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']);
|
|
1844
|
+
// Similarly to SVG, we want to know all MathML elements,
|
|
1845
|
+
// even those that we disallow by default.
|
|
1846
|
+
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
1847
|
+
const purify_es_text = freeze(['#text']);
|
|
1848
|
+
|
|
1849
|
+
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', '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', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
|
|
1850
|
+
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', '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']);
|
|
1851
|
+
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', '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']);
|
|
1852
|
+
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
1853
|
+
|
|
1854
|
+
// eslint-disable-next-line unicorn/better-regex
|
|
1855
|
+
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
1856
|
+
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
1857
|
+
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
|
1858
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
|
1859
|
+
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
1860
|
+
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
|
|
1861
|
+
);
|
|
1862
|
+
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
1863
|
+
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
1864
|
+
);
|
|
1865
|
+
const DOCTYPE_NAME = seal(/^html$/i);
|
|
1866
|
+
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
1867
|
+
|
|
1868
|
+
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
1869
|
+
__proto__: null,
|
|
1870
|
+
ARIA_ATTR: ARIA_ATTR,
|
|
1871
|
+
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
1872
|
+
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
|
1873
|
+
DATA_ATTR: DATA_ATTR,
|
|
1874
|
+
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
1875
|
+
ERB_EXPR: ERB_EXPR,
|
|
1876
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
1877
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
1878
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
1879
|
+
TMPLIT_EXPR: TMPLIT_EXPR
|
|
1880
|
+
});
|
|
1881
|
+
|
|
1882
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
1883
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
1884
|
+
const NODE_TYPE = {
|
|
1885
|
+
element: 1,
|
|
1886
|
+
attribute: 2,
|
|
1887
|
+
text: 3,
|
|
1888
|
+
cdataSection: 4,
|
|
1889
|
+
entityReference: 5,
|
|
1890
|
+
// Deprecated
|
|
1891
|
+
entityNode: 6,
|
|
1892
|
+
// Deprecated
|
|
1893
|
+
progressingInstruction: 7,
|
|
1894
|
+
comment: 8,
|
|
1895
|
+
document: 9,
|
|
1896
|
+
documentType: 10,
|
|
1897
|
+
documentFragment: 11,
|
|
1898
|
+
notation: 12 // Deprecated
|
|
1899
|
+
};
|
|
1900
|
+
const getGlobal = function getGlobal() {
|
|
1901
|
+
return typeof window === 'undefined' ? null : window;
|
|
1902
|
+
};
|
|
1903
|
+
/**
|
|
1904
|
+
* Creates a no-op policy for internal use only.
|
|
1905
|
+
* Don't export this function outside this module!
|
|
1906
|
+
* @param trustedTypes The policy factory.
|
|
1907
|
+
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
|
1908
|
+
* @return The policy created (or null, if Trusted Types
|
|
1909
|
+
* are not supported or creating the policy failed).
|
|
1910
|
+
*/
|
|
1911
|
+
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
1912
|
+
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
1913
|
+
return null;
|
|
1914
|
+
}
|
|
1915
|
+
// Allow the callers to control the unique policy name
|
|
1916
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
1917
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
1918
|
+
let suffix = null;
|
|
1919
|
+
const ATTR_NAME = 'data-tt-policy-suffix';
|
|
1920
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
|
1921
|
+
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
1922
|
+
}
|
|
1923
|
+
const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
1924
|
+
try {
|
|
1925
|
+
return trustedTypes.createPolicy(policyName, {
|
|
1926
|
+
createHTML(html) {
|
|
1927
|
+
return html;
|
|
1928
|
+
},
|
|
1929
|
+
createScriptURL(scriptUrl) {
|
|
1930
|
+
return scriptUrl;
|
|
1931
|
+
}
|
|
1932
|
+
});
|
|
1933
|
+
} catch (_) {
|
|
1934
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
1935
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
1936
|
+
// if TT are enforced.
|
|
1937
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
1938
|
+
return null;
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1941
|
+
const _createHooksMap = function _createHooksMap() {
|
|
1942
|
+
return {
|
|
1943
|
+
afterSanitizeAttributes: [],
|
|
1944
|
+
afterSanitizeElements: [],
|
|
1945
|
+
afterSanitizeShadowDOM: [],
|
|
1946
|
+
beforeSanitizeAttributes: [],
|
|
1947
|
+
beforeSanitizeElements: [],
|
|
1948
|
+
beforeSanitizeShadowDOM: [],
|
|
1949
|
+
uponSanitizeAttribute: [],
|
|
1950
|
+
uponSanitizeElement: [],
|
|
1951
|
+
uponSanitizeShadowNode: []
|
|
1952
|
+
};
|
|
1953
|
+
};
|
|
1954
|
+
function createDOMPurify() {
|
|
1955
|
+
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
1956
|
+
const DOMPurify = root => createDOMPurify(root);
|
|
1957
|
+
DOMPurify.version = '3.2.6';
|
|
1958
|
+
DOMPurify.removed = [];
|
|
1959
|
+
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
1960
|
+
// Not running in a browser, provide a factory function
|
|
1961
|
+
// so that you can pass your own Window
|
|
1962
|
+
DOMPurify.isSupported = false;
|
|
1963
|
+
return DOMPurify;
|
|
1964
|
+
}
|
|
1965
|
+
let {
|
|
1966
|
+
document
|
|
1967
|
+
} = window;
|
|
1968
|
+
const originalDocument = document;
|
|
1969
|
+
const currentScript = originalDocument.currentScript;
|
|
1970
|
+
const {
|
|
1971
|
+
DocumentFragment,
|
|
1972
|
+
HTMLTemplateElement,
|
|
1973
|
+
Node,
|
|
1974
|
+
Element,
|
|
1975
|
+
NodeFilter,
|
|
1976
|
+
NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
|
|
1977
|
+
HTMLFormElement,
|
|
1978
|
+
DOMParser,
|
|
1979
|
+
trustedTypes
|
|
1980
|
+
} = window;
|
|
1981
|
+
const ElementPrototype = Element.prototype;
|
|
1982
|
+
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
1983
|
+
const remove = lookupGetter(ElementPrototype, 'remove');
|
|
1984
|
+
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
1985
|
+
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
1986
|
+
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
1987
|
+
// As per issue #47, the web-components registry is inherited by a
|
|
1988
|
+
// new document created via createHTMLDocument. As per the spec
|
|
1989
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
1990
|
+
// a new empty registry is used when creating a template contents owner
|
|
1991
|
+
// document, so we use that as our parent document to ensure nothing
|
|
1992
|
+
// is inherited.
|
|
1993
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
1994
|
+
const template = document.createElement('template');
|
|
1995
|
+
if (template.content && template.content.ownerDocument) {
|
|
1996
|
+
document = template.content.ownerDocument;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
let trustedTypesPolicy;
|
|
2000
|
+
let emptyHTML = '';
|
|
2001
|
+
const {
|
|
2002
|
+
implementation,
|
|
2003
|
+
createNodeIterator,
|
|
2004
|
+
createDocumentFragment,
|
|
2005
|
+
getElementsByTagName
|
|
2006
|
+
} = document;
|
|
2007
|
+
const {
|
|
2008
|
+
importNode
|
|
2009
|
+
} = originalDocument;
|
|
2010
|
+
let hooks = _createHooksMap();
|
|
2011
|
+
/**
|
|
2012
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
2013
|
+
*/
|
|
2014
|
+
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
|
2015
|
+
const {
|
|
2016
|
+
MUSTACHE_EXPR,
|
|
2017
|
+
ERB_EXPR,
|
|
2018
|
+
TMPLIT_EXPR,
|
|
2019
|
+
DATA_ATTR,
|
|
2020
|
+
ARIA_ATTR,
|
|
2021
|
+
IS_SCRIPT_OR_DATA,
|
|
2022
|
+
ATTR_WHITESPACE,
|
|
2023
|
+
CUSTOM_ELEMENT
|
|
2024
|
+
} = EXPRESSIONS;
|
|
2025
|
+
let {
|
|
2026
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
2027
|
+
} = EXPRESSIONS;
|
|
2028
|
+
/**
|
|
2029
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
2030
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
2031
|
+
*/
|
|
2032
|
+
/* allowed element names */
|
|
2033
|
+
let ALLOWED_TAGS = null;
|
|
2034
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...purify_es_text]);
|
|
2035
|
+
/* Allowed attribute names */
|
|
2036
|
+
let ALLOWED_ATTR = null;
|
|
2037
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
2038
|
+
/*
|
|
2039
|
+
* Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
|
|
2040
|
+
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
2041
|
+
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
2042
|
+
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
2043
|
+
*/
|
|
2044
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
2045
|
+
tagNameCheck: {
|
|
2046
|
+
writable: true,
|
|
2047
|
+
configurable: false,
|
|
2048
|
+
enumerable: true,
|
|
2049
|
+
value: null
|
|
2050
|
+
},
|
|
2051
|
+
attributeNameCheck: {
|
|
2052
|
+
writable: true,
|
|
2053
|
+
configurable: false,
|
|
2054
|
+
enumerable: true,
|
|
2055
|
+
value: null
|
|
2056
|
+
},
|
|
2057
|
+
allowCustomizedBuiltInElements: {
|
|
2058
|
+
writable: true,
|
|
2059
|
+
configurable: false,
|
|
2060
|
+
enumerable: true,
|
|
2061
|
+
value: false
|
|
2062
|
+
}
|
|
2063
|
+
}));
|
|
2064
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
2065
|
+
let FORBID_TAGS = null;
|
|
2066
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
2067
|
+
let FORBID_ATTR = null;
|
|
2068
|
+
/* Decide if ARIA attributes are okay */
|
|
2069
|
+
let ALLOW_ARIA_ATTR = true;
|
|
2070
|
+
/* Decide if custom data attributes are okay */
|
|
2071
|
+
let ALLOW_DATA_ATTR = true;
|
|
2072
|
+
/* Decide if unknown protocols are okay */
|
|
2073
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
2074
|
+
/* Decide if self-closing tags in attributes are allowed.
|
|
2075
|
+
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
|
2076
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
2077
|
+
/* Output should be safe for common template engines.
|
|
2078
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
2079
|
+
*/
|
|
2080
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
2081
|
+
/* Output should be safe even for XML used within HTML and alike.
|
|
2082
|
+
* This means, DOMPurify removes comments when containing risky content.
|
|
2083
|
+
*/
|
|
2084
|
+
let SAFE_FOR_XML = true;
|
|
2085
|
+
/* Decide if document with <html>... should be returned */
|
|
2086
|
+
let WHOLE_DOCUMENT = false;
|
|
2087
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
2088
|
+
let SET_CONFIG = false;
|
|
2089
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
2090
|
+
* document.body. By default, browsers might move them to document.head */
|
|
2091
|
+
let FORCE_BODY = false;
|
|
2092
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
2093
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
2094
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
2095
|
+
*/
|
|
2096
|
+
let RETURN_DOM = false;
|
|
2097
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
2098
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
2099
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
2100
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
2101
|
+
* case Trusted Types are not supported */
|
|
2102
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
2103
|
+
/* Output should be free from DOM clobbering attacks?
|
|
2104
|
+
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
2105
|
+
*/
|
|
2106
|
+
let SANITIZE_DOM = true;
|
|
2107
|
+
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
2108
|
+
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
2109
|
+
*
|
|
2110
|
+
* HTML/DOM spec rules that enable DOM Clobbering:
|
|
2111
|
+
* - Named Access on Window (§7.3.3)
|
|
2112
|
+
* - DOM Tree Accessors (§3.1.5)
|
|
2113
|
+
* - Form Element Parent-Child Relations (§4.10.3)
|
|
2114
|
+
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
|
|
2115
|
+
* - HTMLCollection (§4.2.10.2)
|
|
2116
|
+
*
|
|
2117
|
+
* Namespace isolation is implemented by prefixing `id` and `name` attributes
|
|
2118
|
+
* with a constant string, i.e., `user-content-`
|
|
2119
|
+
*/
|
|
2120
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
2121
|
+
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
2122
|
+
/* Keep element content when removing element? */
|
|
2123
|
+
let KEEP_CONTENT = true;
|
|
2124
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
2125
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
2126
|
+
let IN_PLACE = false;
|
|
2127
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
2128
|
+
let USE_PROFILES = {};
|
|
2129
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
2130
|
+
let FORBID_CONTENTS = null;
|
|
2131
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
2132
|
+
/* Tags that are safe for data: URIs */
|
|
2133
|
+
let DATA_URI_TAGS = null;
|
|
2134
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
2135
|
+
/* Attributes safe for values like "javascript:" */
|
|
2136
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
2137
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
2138
|
+
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
2139
|
+
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
2140
|
+
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
2141
|
+
/* Document namespace */
|
|
2142
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
2143
|
+
let IS_EMPTY_INPUT = false;
|
|
2144
|
+
/* Allowed XHTML+XML namespaces */
|
|
2145
|
+
let ALLOWED_NAMESPACES = null;
|
|
2146
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
2147
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
2148
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
|
|
2149
|
+
// Certain elements are allowed in both SVG and HTML
|
|
2150
|
+
// namespace. We need to specify them explicitly
|
|
2151
|
+
// so that they don't get erroneously deleted from
|
|
2152
|
+
// HTML namespace.
|
|
2153
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
2154
|
+
/* Parsing of strict XHTML documents */
|
|
2155
|
+
let PARSER_MEDIA_TYPE = null;
|
|
2156
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
2157
|
+
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
2158
|
+
let transformCaseFunc = null;
|
|
2159
|
+
/* Keep a reference to config to pass to hooks */
|
|
2160
|
+
let CONFIG = null;
|
|
2161
|
+
/* Ideally, do not touch anything below this line */
|
|
2162
|
+
/* ______________________________________________ */
|
|
2163
|
+
const formElement = document.createElement('form');
|
|
2164
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
2165
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
2166
|
+
};
|
|
2167
|
+
/**
|
|
2168
|
+
* _parseConfig
|
|
2169
|
+
*
|
|
2170
|
+
* @param cfg optional config literal
|
|
2171
|
+
*/
|
|
2172
|
+
// eslint-disable-next-line complexity
|
|
2173
|
+
const _parseConfig = function _parseConfig() {
|
|
2174
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2175
|
+
if (CONFIG && CONFIG === cfg) {
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
/* Shield configuration object from tampering */
|
|
2179
|
+
if (!cfg || typeof cfg !== 'object') {
|
|
2180
|
+
cfg = {};
|
|
2181
|
+
}
|
|
2182
|
+
/* Shield configuration object from prototype pollution */
|
|
2183
|
+
cfg = clone(cfg);
|
|
2184
|
+
PARSER_MEDIA_TYPE =
|
|
2185
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
2186
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
2187
|
+
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
2188
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
2189
|
+
/* Set configuration parameters */
|
|
2190
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
2191
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
2192
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
2193
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
2194
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
2195
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
2196
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
|
|
2197
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
|
|
2198
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
|
|
2199
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
2200
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
2201
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
2202
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
|
|
2203
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
2204
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
|
|
2205
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
2206
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
2207
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
2208
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
2209
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
2210
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
2211
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
2212
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
2213
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
2214
|
+
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
2215
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
2216
|
+
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
|
2217
|
+
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
|
2218
|
+
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
2219
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
2220
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
2221
|
+
}
|
|
2222
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
2223
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
2224
|
+
}
|
|
2225
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
|
|
2226
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
2227
|
+
}
|
|
2228
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
2229
|
+
ALLOW_DATA_ATTR = false;
|
|
2230
|
+
}
|
|
2231
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
2232
|
+
RETURN_DOM = true;
|
|
2233
|
+
}
|
|
2234
|
+
/* Parse profile info */
|
|
2235
|
+
if (USE_PROFILES) {
|
|
2236
|
+
ALLOWED_TAGS = addToSet({}, purify_es_text);
|
|
2237
|
+
ALLOWED_ATTR = [];
|
|
2238
|
+
if (USE_PROFILES.html === true) {
|
|
2239
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
2240
|
+
addToSet(ALLOWED_ATTR, html);
|
|
2241
|
+
}
|
|
2242
|
+
if (USE_PROFILES.svg === true) {
|
|
2243
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
2244
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
2245
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2246
|
+
}
|
|
2247
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
2248
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
2249
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
2250
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2251
|
+
}
|
|
2252
|
+
if (USE_PROFILES.mathMl === true) {
|
|
2253
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
2254
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
2255
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
/* Merge configuration parameters */
|
|
2259
|
+
if (cfg.ADD_TAGS) {
|
|
2260
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
2261
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
2262
|
+
}
|
|
2263
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
2264
|
+
}
|
|
2265
|
+
if (cfg.ADD_ATTR) {
|
|
2266
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
2267
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2268
|
+
}
|
|
2269
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
2270
|
+
}
|
|
2271
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
2272
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
2273
|
+
}
|
|
2274
|
+
if (cfg.FORBID_CONTENTS) {
|
|
2275
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
2276
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
2277
|
+
}
|
|
2278
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
2279
|
+
}
|
|
2280
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
2281
|
+
if (KEEP_CONTENT) {
|
|
2282
|
+
ALLOWED_TAGS['#text'] = true;
|
|
2283
|
+
}
|
|
2284
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
2285
|
+
if (WHOLE_DOCUMENT) {
|
|
2286
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
2287
|
+
}
|
|
2288
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
2289
|
+
if (ALLOWED_TAGS.table) {
|
|
2290
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
2291
|
+
delete FORBID_TAGS.tbody;
|
|
2292
|
+
}
|
|
2293
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
2294
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
|
|
2295
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
2296
|
+
}
|
|
2297
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
2298
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
2299
|
+
}
|
|
2300
|
+
// Overwrite existing TrustedTypes policy.
|
|
2301
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
2302
|
+
// Sign local variables required by `sanitize`.
|
|
2303
|
+
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
2304
|
+
} else {
|
|
2305
|
+
// Uninitialized policy, attempt to initialize the internal dompurify policy.
|
|
2306
|
+
if (trustedTypesPolicy === undefined) {
|
|
2307
|
+
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
2308
|
+
}
|
|
2309
|
+
// If creating the internal policy succeeded sign internal variables.
|
|
2310
|
+
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
|
2311
|
+
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
// Prevent further manipulation of configuration.
|
|
2315
|
+
// Not available in IE8, Safari 5, etc.
|
|
2316
|
+
if (freeze) {
|
|
2317
|
+
freeze(cfg);
|
|
2318
|
+
}
|
|
2319
|
+
CONFIG = cfg;
|
|
2320
|
+
};
|
|
2321
|
+
/* Keep track of all possible SVG and MathML tags
|
|
2322
|
+
* so that we can perform the namespace checks
|
|
2323
|
+
* correctly. */
|
|
2324
|
+
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
2325
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
2326
|
+
/**
|
|
2327
|
+
* @param element a DOM element whose namespace is being checked
|
|
2328
|
+
* @returns Return false if the element has a
|
|
2329
|
+
* namespace that a spec-compliant parser would never
|
|
2330
|
+
* return. Return true otherwise.
|
|
2331
|
+
*/
|
|
2332
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
2333
|
+
let parent = getParentNode(element);
|
|
2334
|
+
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
2335
|
+
// can be null. We just simulate parent in this case.
|
|
2336
|
+
if (!parent || !parent.tagName) {
|
|
2337
|
+
parent = {
|
|
2338
|
+
namespaceURI: NAMESPACE,
|
|
2339
|
+
tagName: 'template'
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
2343
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
2344
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
2345
|
+
return false;
|
|
2346
|
+
}
|
|
2347
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
2348
|
+
// The only way to switch from HTML namespace to SVG
|
|
2349
|
+
// is via <svg>. If it happens via any other tag, then
|
|
2350
|
+
// it should be killed.
|
|
2351
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
2352
|
+
return tagName === 'svg';
|
|
2353
|
+
}
|
|
2354
|
+
// The only way to switch from MathML to SVG is via`
|
|
2355
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
2356
|
+
// text integration points.
|
|
2357
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
2358
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
2359
|
+
}
|
|
2360
|
+
// We only allow elements that are defined in SVG
|
|
2361
|
+
// spec. All others are disallowed in SVG namespace.
|
|
2362
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
2363
|
+
}
|
|
2364
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
2365
|
+
// The only way to switch from HTML namespace to MathML
|
|
2366
|
+
// is via <math>. If it happens via any other tag, then
|
|
2367
|
+
// it should be killed.
|
|
2368
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
2369
|
+
return tagName === 'math';
|
|
2370
|
+
}
|
|
2371
|
+
// The only way to switch from SVG to MathML is via
|
|
2372
|
+
// <math> and HTML integration points
|
|
2373
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
2374
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
2375
|
+
}
|
|
2376
|
+
// We only allow elements that are defined in MathML
|
|
2377
|
+
// spec. All others are disallowed in MathML namespace.
|
|
2378
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
2379
|
+
}
|
|
2380
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
2381
|
+
// The only way to switch from SVG to HTML is via
|
|
2382
|
+
// HTML integration points, and from MathML to HTML
|
|
2383
|
+
// is via MathML text integration points
|
|
2384
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
2385
|
+
return false;
|
|
2386
|
+
}
|
|
2387
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
2388
|
+
return false;
|
|
2389
|
+
}
|
|
2390
|
+
// We disallow tags that are specific for MathML
|
|
2391
|
+
// or SVG and should never appear in HTML namespace
|
|
2392
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
2393
|
+
}
|
|
2394
|
+
// For XHTML and XML documents that support custom namespaces
|
|
2395
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
2396
|
+
return true;
|
|
2397
|
+
}
|
|
2398
|
+
// The code should never reach this place (this means
|
|
2399
|
+
// that the element somehow got namespace that is not
|
|
2400
|
+
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
|
2401
|
+
// Return false just in case.
|
|
2402
|
+
return false;
|
|
2403
|
+
};
|
|
2404
|
+
/**
|
|
2405
|
+
* _forceRemove
|
|
2406
|
+
*
|
|
2407
|
+
* @param node a DOM node
|
|
2408
|
+
*/
|
|
2409
|
+
const _forceRemove = function _forceRemove(node) {
|
|
2410
|
+
arrayPush(DOMPurify.removed, {
|
|
2411
|
+
element: node
|
|
2412
|
+
});
|
|
2413
|
+
try {
|
|
2414
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
2415
|
+
getParentNode(node).removeChild(node);
|
|
2416
|
+
} catch (_) {
|
|
2417
|
+
remove(node);
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
/**
|
|
2421
|
+
* _removeAttribute
|
|
2422
|
+
*
|
|
2423
|
+
* @param name an Attribute name
|
|
2424
|
+
* @param element a DOM node
|
|
2425
|
+
*/
|
|
2426
|
+
const _removeAttribute = function _removeAttribute(name, element) {
|
|
2427
|
+
try {
|
|
2428
|
+
arrayPush(DOMPurify.removed, {
|
|
2429
|
+
attribute: element.getAttributeNode(name),
|
|
2430
|
+
from: element
|
|
2431
|
+
});
|
|
2432
|
+
} catch (_) {
|
|
2433
|
+
arrayPush(DOMPurify.removed, {
|
|
2434
|
+
attribute: null,
|
|
2435
|
+
from: element
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
element.removeAttribute(name);
|
|
2439
|
+
// We void attribute values for unremovable "is" attributes
|
|
2440
|
+
if (name === 'is') {
|
|
2441
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
2442
|
+
try {
|
|
2443
|
+
_forceRemove(element);
|
|
2444
|
+
} catch (_) {}
|
|
2445
|
+
} else {
|
|
2446
|
+
try {
|
|
2447
|
+
element.setAttribute(name, '');
|
|
2448
|
+
} catch (_) {}
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
/**
|
|
2453
|
+
* _initDocument
|
|
2454
|
+
*
|
|
2455
|
+
* @param dirty - a string of dirty markup
|
|
2456
|
+
* @return a DOM, filled with the dirty markup
|
|
2457
|
+
*/
|
|
2458
|
+
const _initDocument = function _initDocument(dirty) {
|
|
2459
|
+
/* Create a HTML document */
|
|
2460
|
+
let doc = null;
|
|
2461
|
+
let leadingWhitespace = null;
|
|
2462
|
+
if (FORCE_BODY) {
|
|
2463
|
+
dirty = '<remove></remove>' + dirty;
|
|
2464
|
+
} else {
|
|
2465
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
2466
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
2467
|
+
leadingWhitespace = matches && matches[0];
|
|
2468
|
+
}
|
|
2469
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
|
|
2470
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
2471
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
2472
|
+
}
|
|
2473
|
+
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
2474
|
+
/*
|
|
2475
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
2476
|
+
* DOMParser not work for svg when has multiple root element.
|
|
2477
|
+
*/
|
|
2478
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
2479
|
+
try {
|
|
2480
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
2481
|
+
} catch (_) {}
|
|
2482
|
+
}
|
|
2483
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
2484
|
+
if (!doc || !doc.documentElement) {
|
|
2485
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
2486
|
+
try {
|
|
2487
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
2488
|
+
} catch (_) {
|
|
2489
|
+
// Syntax error if dirtyPayload is invalid xml
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
const body = doc.body || doc.documentElement;
|
|
2493
|
+
if (dirty && leadingWhitespace) {
|
|
2494
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
2495
|
+
}
|
|
2496
|
+
/* Work on whole document or just its body */
|
|
2497
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
2498
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
2499
|
+
}
|
|
2500
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
2501
|
+
};
|
|
2502
|
+
/**
|
|
2503
|
+
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
|
2504
|
+
*
|
|
2505
|
+
* @param root The root element or node to start traversing on.
|
|
2506
|
+
* @return The created NodeIterator
|
|
2507
|
+
*/
|
|
2508
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
2509
|
+
return createNodeIterator.call(root.ownerDocument || root, root,
|
|
2510
|
+
// eslint-disable-next-line no-bitwise
|
|
2511
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
2512
|
+
};
|
|
2513
|
+
/**
|
|
2514
|
+
* _isClobbered
|
|
2515
|
+
*
|
|
2516
|
+
* @param element element to check for clobbering attacks
|
|
2517
|
+
* @return true if clobbered, false if safe
|
|
2518
|
+
*/
|
|
2519
|
+
const _isClobbered = function _isClobbered(element) {
|
|
2520
|
+
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
|
|
2521
|
+
};
|
|
2522
|
+
/**
|
|
2523
|
+
* Checks whether the given object is a DOM node.
|
|
2524
|
+
*
|
|
2525
|
+
* @param value object to check whether it's a DOM node
|
|
2526
|
+
* @return true is object is a DOM node
|
|
2527
|
+
*/
|
|
2528
|
+
const _isNode = function _isNode(value) {
|
|
2529
|
+
return typeof Node === 'function' && value instanceof Node;
|
|
2530
|
+
};
|
|
2531
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
2532
|
+
arrayForEach(hooks, hook => {
|
|
2533
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* _sanitizeElements
|
|
2538
|
+
*
|
|
2539
|
+
* @protect nodeName
|
|
2540
|
+
* @protect textContent
|
|
2541
|
+
* @protect removeChild
|
|
2542
|
+
* @param currentNode to check for permission to exist
|
|
2543
|
+
* @return true if node was killed, false if left alive
|
|
2544
|
+
*/
|
|
2545
|
+
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
2546
|
+
let content = null;
|
|
2547
|
+
/* Execute a hook if present */
|
|
2548
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
2549
|
+
/* Check if element is clobbered or can clobber */
|
|
2550
|
+
if (_isClobbered(currentNode)) {
|
|
2551
|
+
_forceRemove(currentNode);
|
|
2552
|
+
return true;
|
|
2553
|
+
}
|
|
2554
|
+
/* Now let's check the element's type and name */
|
|
2555
|
+
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
2556
|
+
/* Execute a hook if present */
|
|
2557
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
2558
|
+
tagName,
|
|
2559
|
+
allowedTags: ALLOWED_TAGS
|
|
2560
|
+
});
|
|
2561
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
2562
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
|
|
2563
|
+
_forceRemove(currentNode);
|
|
2564
|
+
return true;
|
|
2565
|
+
}
|
|
2566
|
+
/* Remove any occurrence of processing instructions */
|
|
2567
|
+
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
2568
|
+
_forceRemove(currentNode);
|
|
2569
|
+
return true;
|
|
2570
|
+
}
|
|
2571
|
+
/* Remove any kind of possibly harmful comments */
|
|
2572
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
2573
|
+
_forceRemove(currentNode);
|
|
2574
|
+
return true;
|
|
2575
|
+
}
|
|
2576
|
+
/* Remove element if anything forbids its presence */
|
|
2577
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2578
|
+
/* Check if we have a custom element to handle */
|
|
2579
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
2580
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
2581
|
+
return false;
|
|
2582
|
+
}
|
|
2583
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
2584
|
+
return false;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
/* Keep content except for bad-listed elements */
|
|
2588
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
2589
|
+
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
2590
|
+
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
2591
|
+
if (childNodes && parentNode) {
|
|
2592
|
+
const childCount = childNodes.length;
|
|
2593
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
2594
|
+
const childClone = cloneNode(childNodes[i], true);
|
|
2595
|
+
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
2596
|
+
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
_forceRemove(currentNode);
|
|
2601
|
+
return true;
|
|
2602
|
+
}
|
|
2603
|
+
/* Check whether element has a valid namespace */
|
|
2604
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
2605
|
+
_forceRemove(currentNode);
|
|
2606
|
+
return true;
|
|
2607
|
+
}
|
|
2608
|
+
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
2609
|
+
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
2610
|
+
_forceRemove(currentNode);
|
|
2611
|
+
return true;
|
|
2612
|
+
}
|
|
2613
|
+
/* Sanitize element content to be template-safe */
|
|
2614
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
2615
|
+
/* Get the element's text content */
|
|
2616
|
+
content = currentNode.textContent;
|
|
2617
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
2618
|
+
content = stringReplace(content, expr, ' ');
|
|
2619
|
+
});
|
|
2620
|
+
if (currentNode.textContent !== content) {
|
|
2621
|
+
arrayPush(DOMPurify.removed, {
|
|
2622
|
+
element: currentNode.cloneNode()
|
|
2623
|
+
});
|
|
2624
|
+
currentNode.textContent = content;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
/* Execute a hook if present */
|
|
2628
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
2629
|
+
return false;
|
|
2630
|
+
};
|
|
2631
|
+
/**
|
|
2632
|
+
* _isValidAttribute
|
|
2633
|
+
*
|
|
2634
|
+
* @param lcTag Lowercase tag name of containing element.
|
|
2635
|
+
* @param lcName Lowercase attribute name.
|
|
2636
|
+
* @param value Attribute value.
|
|
2637
|
+
* @return Returns true if `value` is valid, otherwise false.
|
|
2638
|
+
*/
|
|
2639
|
+
// eslint-disable-next-line complexity
|
|
2640
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
2641
|
+
/* Make sure attribute cannot clobber */
|
|
2642
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
2643
|
+
return false;
|
|
2644
|
+
}
|
|
2645
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
2646
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
2647
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
2648
|
+
We don't need to check the value; it's always URI safe. */
|
|
2649
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
2650
|
+
if (
|
|
2651
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
2652
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2653
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
2654
|
+
_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)) ||
|
|
2655
|
+
// Alternative, second condition checks if it's an `is`-attribute, AND
|
|
2656
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2657
|
+
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 {
|
|
2658
|
+
return false;
|
|
2659
|
+
}
|
|
2660
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
2661
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; 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, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
|
|
2662
|
+
return false;
|
|
2663
|
+
} else ;
|
|
2664
|
+
return true;
|
|
2665
|
+
};
|
|
2666
|
+
/**
|
|
2667
|
+
* _isBasicCustomElement
|
|
2668
|
+
* checks if at least one dash is included in tagName, and it's not the first char
|
|
2669
|
+
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
2670
|
+
*
|
|
2671
|
+
* @param tagName name of the tag of the node to sanitize
|
|
2672
|
+
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
2673
|
+
*/
|
|
2674
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
2675
|
+
return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
2676
|
+
};
|
|
2677
|
+
/**
|
|
2678
|
+
* _sanitizeAttributes
|
|
2679
|
+
*
|
|
2680
|
+
* @protect attributes
|
|
2681
|
+
* @protect nodeName
|
|
2682
|
+
* @protect removeAttribute
|
|
2683
|
+
* @protect setAttribute
|
|
2684
|
+
*
|
|
2685
|
+
* @param currentNode to sanitize
|
|
2686
|
+
*/
|
|
2687
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
2688
|
+
/* Execute a hook if present */
|
|
2689
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
2690
|
+
const {
|
|
2691
|
+
attributes
|
|
2692
|
+
} = currentNode;
|
|
2693
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
2694
|
+
if (!attributes || _isClobbered(currentNode)) {
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
const hookEvent = {
|
|
2698
|
+
attrName: '',
|
|
2699
|
+
attrValue: '',
|
|
2700
|
+
keepAttr: true,
|
|
2701
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
2702
|
+
forceKeepAttr: undefined
|
|
2703
|
+
};
|
|
2704
|
+
let l = attributes.length;
|
|
2705
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
2706
|
+
while (l--) {
|
|
2707
|
+
const attr = attributes[l];
|
|
2708
|
+
const {
|
|
2709
|
+
name,
|
|
2710
|
+
namespaceURI,
|
|
2711
|
+
value: attrValue
|
|
2712
|
+
} = attr;
|
|
2713
|
+
const lcName = transformCaseFunc(name);
|
|
2714
|
+
const initValue = attrValue;
|
|
2715
|
+
let value = name === 'value' ? initValue : stringTrim(initValue);
|
|
2716
|
+
/* Execute a hook if present */
|
|
2717
|
+
hookEvent.attrName = lcName;
|
|
2718
|
+
hookEvent.attrValue = value;
|
|
2719
|
+
hookEvent.keepAttr = true;
|
|
2720
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
2721
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
2722
|
+
value = hookEvent.attrValue;
|
|
2723
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
2724
|
+
* Prefix id and name attributes with `user-content-`
|
|
2725
|
+
*/
|
|
2726
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
2727
|
+
// Remove the attribute with this value
|
|
2728
|
+
_removeAttribute(name, currentNode);
|
|
2729
|
+
// Prefix the value and later re-create the attribute with the sanitized value
|
|
2730
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
2731
|
+
}
|
|
2732
|
+
/* Work around a security issue with comments inside attributes */
|
|
2733
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
2734
|
+
_removeAttribute(name, currentNode);
|
|
2735
|
+
continue;
|
|
2736
|
+
}
|
|
2737
|
+
/* Did the hooks approve of the attribute? */
|
|
2738
|
+
if (hookEvent.forceKeepAttr) {
|
|
2739
|
+
continue;
|
|
2740
|
+
}
|
|
2741
|
+
/* Did the hooks approve of the attribute? */
|
|
2742
|
+
if (!hookEvent.keepAttr) {
|
|
2743
|
+
_removeAttribute(name, currentNode);
|
|
2744
|
+
continue;
|
|
2745
|
+
}
|
|
2746
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
2747
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
2748
|
+
_removeAttribute(name, currentNode);
|
|
2749
|
+
continue;
|
|
2750
|
+
}
|
|
2751
|
+
/* Sanitize attribute content to be template-safe */
|
|
2752
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
2753
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
2754
|
+
value = stringReplace(value, expr, ' ');
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
/* Is `value` valid for this attribute? */
|
|
2758
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
2759
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
2760
|
+
_removeAttribute(name, currentNode);
|
|
2761
|
+
continue;
|
|
2762
|
+
}
|
|
2763
|
+
/* Handle attributes that require Trusted Types */
|
|
2764
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
2765
|
+
if (namespaceURI) ; else {
|
|
2766
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
2767
|
+
case 'TrustedHTML':
|
|
2768
|
+
{
|
|
2769
|
+
value = trustedTypesPolicy.createHTML(value);
|
|
2770
|
+
break;
|
|
2771
|
+
}
|
|
2772
|
+
case 'TrustedScriptURL':
|
|
2773
|
+
{
|
|
2774
|
+
value = trustedTypesPolicy.createScriptURL(value);
|
|
2775
|
+
break;
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
2781
|
+
if (value !== initValue) {
|
|
2782
|
+
try {
|
|
2783
|
+
if (namespaceURI) {
|
|
2784
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
2785
|
+
} else {
|
|
2786
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
2787
|
+
currentNode.setAttribute(name, value);
|
|
2788
|
+
}
|
|
2789
|
+
if (_isClobbered(currentNode)) {
|
|
2790
|
+
_forceRemove(currentNode);
|
|
2791
|
+
} else {
|
|
2792
|
+
arrayPop(DOMPurify.removed);
|
|
2793
|
+
}
|
|
2794
|
+
} catch (_) {
|
|
2795
|
+
_removeAttribute(name, currentNode);
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
/* Execute a hook if present */
|
|
2800
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
2801
|
+
};
|
|
2802
|
+
/**
|
|
2803
|
+
* _sanitizeShadowDOM
|
|
2804
|
+
*
|
|
2805
|
+
* @param fragment to iterate over recursively
|
|
2806
|
+
*/
|
|
2807
|
+
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
2808
|
+
let shadowNode = null;
|
|
2809
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
2810
|
+
/* Execute a hook if present */
|
|
2811
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
2812
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
2813
|
+
/* Execute a hook if present */
|
|
2814
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
2815
|
+
/* Sanitize tags and elements */
|
|
2816
|
+
_sanitizeElements(shadowNode);
|
|
2817
|
+
/* Check attributes next */
|
|
2818
|
+
_sanitizeAttributes(shadowNode);
|
|
2819
|
+
/* Deep shadow DOM detected */
|
|
2820
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
2821
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
/* Execute a hook if present */
|
|
2825
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
2826
|
+
};
|
|
2827
|
+
// eslint-disable-next-line complexity
|
|
2828
|
+
DOMPurify.sanitize = function (dirty) {
|
|
2829
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2830
|
+
let body = null;
|
|
2831
|
+
let importedNode = null;
|
|
2832
|
+
let currentNode = null;
|
|
2833
|
+
let returnNode = null;
|
|
2834
|
+
/* Make sure we have a string to sanitize.
|
|
2835
|
+
DO NOT return early, as this will return the wrong type if
|
|
2836
|
+
the user has requested a DOM object rather than a string */
|
|
2837
|
+
IS_EMPTY_INPUT = !dirty;
|
|
2838
|
+
if (IS_EMPTY_INPUT) {
|
|
2839
|
+
dirty = '<!-->';
|
|
2840
|
+
}
|
|
2841
|
+
/* Stringify, in case dirty is an object */
|
|
2842
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
2843
|
+
if (typeof dirty.toString === 'function') {
|
|
2844
|
+
dirty = dirty.toString();
|
|
2845
|
+
if (typeof dirty !== 'string') {
|
|
2846
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
2847
|
+
}
|
|
2848
|
+
} else {
|
|
2849
|
+
throw typeErrorCreate('toString is not a function');
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
/* Return dirty HTML if DOMPurify cannot run */
|
|
2853
|
+
if (!DOMPurify.isSupported) {
|
|
2854
|
+
return dirty;
|
|
2855
|
+
}
|
|
2856
|
+
/* Assign config vars */
|
|
2857
|
+
if (!SET_CONFIG) {
|
|
2858
|
+
_parseConfig(cfg);
|
|
2859
|
+
}
|
|
2860
|
+
/* Clean up removed elements */
|
|
2861
|
+
DOMPurify.removed = [];
|
|
2862
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
2863
|
+
if (typeof dirty === 'string') {
|
|
2864
|
+
IN_PLACE = false;
|
|
2865
|
+
}
|
|
2866
|
+
if (IN_PLACE) {
|
|
2867
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
|
2868
|
+
if (dirty.nodeName) {
|
|
2869
|
+
const tagName = transformCaseFunc(dirty.nodeName);
|
|
2870
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2871
|
+
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
} else if (dirty instanceof Node) {
|
|
2875
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
2876
|
+
elements being stripped by the parser */
|
|
2877
|
+
body = _initDocument('<!---->');
|
|
2878
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
2879
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
|
|
2880
|
+
/* Node is already a body, use as is */
|
|
2881
|
+
body = importedNode;
|
|
2882
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
2883
|
+
body = importedNode;
|
|
2884
|
+
} else {
|
|
2885
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
2886
|
+
body.appendChild(importedNode);
|
|
2887
|
+
}
|
|
2888
|
+
} else {
|
|
2889
|
+
/* Exit directly if we have nothing to do */
|
|
2890
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
2891
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
2892
|
+
dirty.indexOf('<') === -1) {
|
|
2893
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
2894
|
+
}
|
|
2895
|
+
/* Initialize the document to work on */
|
|
2896
|
+
body = _initDocument(dirty);
|
|
2897
|
+
/* Check we have a DOM node from the data */
|
|
2898
|
+
if (!body) {
|
|
2899
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
2903
|
+
if (body && FORCE_BODY) {
|
|
2904
|
+
_forceRemove(body.firstChild);
|
|
2905
|
+
}
|
|
2906
|
+
/* Get node iterator */
|
|
2907
|
+
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
2908
|
+
/* Now start iterating over the created document */
|
|
2909
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
2910
|
+
/* Sanitize tags and elements */
|
|
2911
|
+
_sanitizeElements(currentNode);
|
|
2912
|
+
/* Check attributes next */
|
|
2913
|
+
_sanitizeAttributes(currentNode);
|
|
2914
|
+
/* Shadow DOM detected, sanitize it */
|
|
2915
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
2916
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
2920
|
+
if (IN_PLACE) {
|
|
2921
|
+
return dirty;
|
|
2922
|
+
}
|
|
2923
|
+
/* Return sanitized string or DOM */
|
|
2924
|
+
if (RETURN_DOM) {
|
|
2925
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
2926
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
2927
|
+
while (body.firstChild) {
|
|
2928
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
2929
|
+
returnNode.appendChild(body.firstChild);
|
|
2930
|
+
}
|
|
2931
|
+
} else {
|
|
2932
|
+
returnNode = body;
|
|
2933
|
+
}
|
|
2934
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
2935
|
+
/*
|
|
2936
|
+
AdoptNode() is not used because internal state is not reset
|
|
2937
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
2938
|
+
in theory but we would rather not risk another attack vector.
|
|
2939
|
+
The state that is cloned by importNode() is explicitly defined
|
|
2940
|
+
by the specs.
|
|
2941
|
+
*/
|
|
2942
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
2943
|
+
}
|
|
2944
|
+
return returnNode;
|
|
2945
|
+
}
|
|
2946
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
2947
|
+
/* Serialize doctype if allowed */
|
|
2948
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
2949
|
+
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
2950
|
+
}
|
|
2951
|
+
/* Sanitize final string template-safe */
|
|
2952
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
2953
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
2954
|
+
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
2958
|
+
};
|
|
2959
|
+
DOMPurify.setConfig = function () {
|
|
2960
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2961
|
+
_parseConfig(cfg);
|
|
2962
|
+
SET_CONFIG = true;
|
|
2963
|
+
};
|
|
2964
|
+
DOMPurify.clearConfig = function () {
|
|
2965
|
+
CONFIG = null;
|
|
2966
|
+
SET_CONFIG = false;
|
|
2967
|
+
};
|
|
2968
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
2969
|
+
/* Initialize shared config vars if necessary. */
|
|
2970
|
+
if (!CONFIG) {
|
|
2971
|
+
_parseConfig({});
|
|
2972
|
+
}
|
|
2973
|
+
const lcTag = transformCaseFunc(tag);
|
|
2974
|
+
const lcName = transformCaseFunc(attr);
|
|
2975
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
2976
|
+
};
|
|
2977
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
2978
|
+
if (typeof hookFunction !== 'function') {
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
2982
|
+
};
|
|
2983
|
+
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
2984
|
+
if (hookFunction !== undefined) {
|
|
2985
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
2986
|
+
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
2987
|
+
}
|
|
2988
|
+
return arrayPop(hooks[entryPoint]);
|
|
2989
|
+
};
|
|
2990
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
2991
|
+
hooks[entryPoint] = [];
|
|
2992
|
+
};
|
|
2993
|
+
DOMPurify.removeAllHooks = function () {
|
|
2994
|
+
hooks = _createHooksMap();
|
|
2995
|
+
};
|
|
2996
|
+
return DOMPurify;
|
|
2997
|
+
}
|
|
2998
|
+
var purify = createDOMPurify();
|
|
2999
|
+
|
|
3000
|
+
|
|
3001
|
+
//# sourceMappingURL=purify.es.mjs.map
|
|
3002
|
+
|
|
1658
3003
|
;// CONCATENATED MODULE: ../../packages/tag-input/src/list-tag-render.tsx
|
|
1659
3004
|
|
|
1660
3005
|
/*
|
|
1661
3006
|
* Tencent is pleased to support the open source community by making
|
|
1662
3007
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1663
3008
|
*
|
|
1664
|
-
* Copyright (C)
|
|
3009
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1665
3010
|
*
|
|
1666
3011
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1667
3012
|
*
|
|
@@ -1685,6 +3030,7 @@ const trim_namespaceObject = trim_x({ ["default"]: () => __WEBPACK_EXTERNAL_MODU
|
|
|
1685
3030
|
|
|
1686
3031
|
|
|
1687
3032
|
|
|
3033
|
+
|
|
1688
3034
|
/* harmony default export */ const list_tag_render = ((0,external_vue_namespaceObject.defineComponent)({
|
|
1689
3035
|
name: 'ListTagRender',
|
|
1690
3036
|
props: {
|
|
@@ -1704,9 +3050,9 @@ const trim_namespaceObject = trim_x({ ["default"]: () => __WEBPACK_EXTERNAL_MODU
|
|
|
1704
3050
|
var highlightKeyword = function highlightKeyword(value) {
|
|
1705
3051
|
if (_this.searchKeyword && !_this.disabled) {
|
|
1706
3052
|
var keywordReg = new RegExp("(".concat(_this.searchKeyword, ")"), 'i');
|
|
1707
|
-
return value.replace(keywordReg, '<strong class="highlight-text">$1</strong>');
|
|
3053
|
+
return purify.sanitize(value.replace(keywordReg, '<strong class="highlight-text">$1</strong>'));
|
|
1708
3054
|
}
|
|
1709
|
-
return value;
|
|
3055
|
+
return purify.sanitize(value);
|
|
1710
3056
|
};
|
|
1711
3057
|
if (this.tpl) {
|
|
1712
3058
|
return this.tpl(this.node, highlightKeyword, external_vue_namespaceObject.h, this);
|
|
@@ -1717,7 +3063,7 @@ const trim_namespaceObject = trim_x({ ["default"]: () => __WEBPACK_EXTERNAL_MODU
|
|
|
1717
3063
|
}, [(0,external_vue_namespaceObject.createVNode)("span", {
|
|
1718
3064
|
"class": "text",
|
|
1719
3065
|
"innerHTML": highlightKeyword(displayText)
|
|
1720
|
-
},
|
|
3066
|
+
}, null)]);
|
|
1721
3067
|
}
|
|
1722
3068
|
}));
|
|
1723
3069
|
;// CONCATENATED MODULE: external "vue-types"
|
|
@@ -1729,7 +3075,7 @@ const external_vue_types_namespaceObject = external_vue_types_x({ ["toType"]: ()
|
|
|
1729
3075
|
* Tencent is pleased to support the open source community by making
|
|
1730
3076
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1731
3077
|
*
|
|
1732
|
-
* Copyright (C)
|
|
3078
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1733
3079
|
*
|
|
1734
3080
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1735
3081
|
*
|
|
@@ -1834,7 +3180,7 @@ function tag_render_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
1834
3180
|
* Tencent is pleased to support the open source community by making
|
|
1835
3181
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1836
3182
|
*
|
|
1837
|
-
* Copyright (C)
|
|
3183
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1838
3184
|
*
|
|
1839
3185
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1840
3186
|
*
|
|
@@ -1880,9 +3226,15 @@ function tag_render_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
1880
3226
|
"default": function _default() {
|
|
1881
3227
|
return {};
|
|
1882
3228
|
}
|
|
3229
|
+
},
|
|
3230
|
+
allowCreate: {
|
|
3231
|
+
type: Boolean,
|
|
3232
|
+
"default": false
|
|
1883
3233
|
}
|
|
1884
3234
|
},
|
|
1885
|
-
|
|
3235
|
+
emits: ['dblclick', 'change'],
|
|
3236
|
+
setup: function setup(props, _ref) {
|
|
3237
|
+
var emit = _ref.emit;
|
|
1886
3238
|
var tagRef = (0,external_vue_namespaceObject.ref)();
|
|
1887
3239
|
var isOverflow = (0,external_vue_namespaceObject.ref)(false);
|
|
1888
3240
|
var overflowTips = (0,external_vue_namespaceObject.computed)(function () {
|
|
@@ -1894,12 +3246,82 @@ function tag_render_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
1894
3246
|
disabled: !(0,has_namespaceObject["default"])(props.node, props.tooltipKey) || !isOverflow.value
|
|
1895
3247
|
}, props.tagOverflowTips);
|
|
1896
3248
|
});
|
|
3249
|
+
var editRef = (0,external_vue_namespaceObject.ref)();
|
|
3250
|
+
var showEdit = (0,external_vue_namespaceObject.ref)(false);
|
|
3251
|
+
var clickTimer = (0,external_vue_namespaceObject.ref)(null);
|
|
3252
|
+
var handleClick = function handleClick() {
|
|
3253
|
+
if (clickTimer.value) {
|
|
3254
|
+
clearTimeout(clickTimer.value);
|
|
3255
|
+
}
|
|
3256
|
+
clickTimer.value = window.setTimeout(function () {
|
|
3257
|
+
// timer 为 null 说明是双击
|
|
3258
|
+
if (clickTimer.value === null) {
|
|
3259
|
+
return;
|
|
3260
|
+
}
|
|
3261
|
+
clickTimer.value = null;
|
|
3262
|
+
}, 200);
|
|
3263
|
+
};
|
|
3264
|
+
var handleDblclick = function handleDblclick(e) {
|
|
3265
|
+
e.preventDefault();
|
|
3266
|
+
e.stopPropagation();
|
|
3267
|
+
// 阻止单击事件执行
|
|
3268
|
+
if (clickTimer.value) {
|
|
3269
|
+
clearTimeout(clickTimer.value);
|
|
3270
|
+
clickTimer.value = null;
|
|
3271
|
+
}
|
|
3272
|
+
showEdit.value = true;
|
|
3273
|
+
emit('dblclick', true);
|
|
3274
|
+
setTimeout(function () {
|
|
3275
|
+
var _editRef$value;
|
|
3276
|
+
(_editRef$value = editRef.value) === null || _editRef$value === void 0 || _editRef$value.focus();
|
|
3277
|
+
}, 0);
|
|
3278
|
+
};
|
|
3279
|
+
var handleEditBlur = function handleEditBlur() {
|
|
3280
|
+
showEdit.value = false;
|
|
3281
|
+
emit('dblclick', false);
|
|
3282
|
+
};
|
|
3283
|
+
var handleEditFocus = function handleEditFocus() {
|
|
3284
|
+
showEdit.value = true;
|
|
3285
|
+
};
|
|
3286
|
+
var handleEditChange = function handleEditChange(e) {
|
|
3287
|
+
var val = e.target.value;
|
|
3288
|
+
emit('change', val);
|
|
3289
|
+
};
|
|
3290
|
+
var handleEditKeyDown = function handleEditKeyDown(e) {
|
|
3291
|
+
if ((e.code === 'Enter' || e.key === 'Enter' || e.keyCode === 13) && !e.isComposing) {
|
|
3292
|
+
var val = e.target.value;
|
|
3293
|
+
emit('change', val);
|
|
3294
|
+
setTimeout(function () {
|
|
3295
|
+
handleEditBlur();
|
|
3296
|
+
}, 100);
|
|
3297
|
+
}
|
|
3298
|
+
};
|
|
3299
|
+
var handleEditInput = function handleEditInput(e) {
|
|
3300
|
+
// console.error('handleEditInputhandleEditInputhandleEditInput', (e.target as HTMLInputElement).value, props.node);
|
|
3301
|
+
// emit('input', e.target.value);
|
|
3302
|
+
var val = e.target.value;
|
|
3303
|
+
editValue.value = val;
|
|
3304
|
+
};
|
|
3305
|
+
var editValue = (0,external_vue_namespaceObject.ref)(props.node[props.displayKey]);
|
|
3306
|
+
(0,external_vue_namespaceObject.watch)(props.node[props.displayKey], function (val) {
|
|
3307
|
+
editValue.value = val;
|
|
3308
|
+
});
|
|
1897
3309
|
(0,external_vue_namespaceObject.onMounted)(function () {
|
|
1898
3310
|
isOverflow.value = (0,shared_namespaceObject.checkOverflow)(tagRef.value);
|
|
1899
3311
|
});
|
|
1900
3312
|
return {
|
|
1901
3313
|
overflowTips: overflowTips,
|
|
1902
|
-
tagRef: tagRef
|
|
3314
|
+
tagRef: tagRef,
|
|
3315
|
+
editRef: editRef,
|
|
3316
|
+
handleClick: handleClick,
|
|
3317
|
+
handleDblclick: handleDblclick,
|
|
3318
|
+
showEdit: showEdit,
|
|
3319
|
+
handleEditBlur: handleEditBlur,
|
|
3320
|
+
handleEditFocus: handleEditFocus,
|
|
3321
|
+
handleEditChange: handleEditChange,
|
|
3322
|
+
handleEditKeyDown: handleEditKeyDown,
|
|
3323
|
+
handleEditInput: handleEditInput,
|
|
3324
|
+
editValue: editValue
|
|
1903
3325
|
};
|
|
1904
3326
|
},
|
|
1905
3327
|
render: function render() {
|
|
@@ -1909,9 +3331,21 @@ function tag_render_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
1909
3331
|
return (0,external_vue_namespaceObject.withDirectives)((0,external_vue_namespaceObject.createVNode)("div", {
|
|
1910
3332
|
"ref": "tagRef",
|
|
1911
3333
|
"class": "tag"
|
|
1912
|
-
}, [(0,external_vue_namespaceObject.createVNode)("
|
|
1913
|
-
"
|
|
1914
|
-
|
|
3334
|
+
}, [this.showEdit ? (0,external_vue_namespaceObject.createVNode)("input", {
|
|
3335
|
+
"ref": "editRef",
|
|
3336
|
+
"class": "dblclick-edit-input",
|
|
3337
|
+
"type": "text",
|
|
3338
|
+
"value": this.editValue,
|
|
3339
|
+
"onBlur": this.handleEditBlur,
|
|
3340
|
+
"onChange": this.handleEditChange,
|
|
3341
|
+
"onFocus": this.handleEditFocus,
|
|
3342
|
+
"onInput": this.handleEditInput,
|
|
3343
|
+
"onKeydown": this.handleEditKeyDown
|
|
3344
|
+
}, null) : null, (0,external_vue_namespaceObject.createVNode)("span", {
|
|
3345
|
+
"class": "text",
|
|
3346
|
+
"onClick": this.allowCreate ? this.handleClick : undefined,
|
|
3347
|
+
"onDblclick": this.allowCreate ? this.handleDblclick : undefined
|
|
3348
|
+
}, [this.editValue])]), [[(0,external_vue_namespaceObject.resolveDirective)("bk-tooltips"), this.overflowTips]]);
|
|
1915
3349
|
}
|
|
1916
3350
|
}));
|
|
1917
3351
|
;// CONCATENATED MODULE: ../../packages/tag-input/src/tag-input.tsx
|
|
@@ -1926,7 +3360,7 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
1926
3360
|
* Tencent is pleased to support the open source community by making
|
|
1927
3361
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
1928
3362
|
*
|
|
1929
|
-
* Copyright (C)
|
|
3363
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
1930
3364
|
*
|
|
1931
3365
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
1932
3366
|
*
|
|
@@ -2005,6 +3439,7 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2005
3439
|
var selectorListRef = (0,external_vue_namespaceObject.ref)(null);
|
|
2006
3440
|
var inputValueRef = (0,external_vue_namespaceObject.ref)();
|
|
2007
3441
|
var timer = (0,external_vue_namespaceObject.ref)(null);
|
|
3442
|
+
var isShowDblclickEdit = (0,external_vue_namespaceObject.ref)(false);
|
|
2008
3443
|
// 是否展示tag close
|
|
2009
3444
|
var showTagClose = (0,external_vue_namespaceObject.computed)(function () {
|
|
2010
3445
|
return !props.disabled && props.hasDeleteIcon;
|
|
@@ -2182,6 +3617,9 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2182
3617
|
state.isEdit = true;
|
|
2183
3618
|
setTimeout(function () {
|
|
2184
3619
|
var _tagInputRef$value;
|
|
3620
|
+
if (isShowDblclickEdit.value) {
|
|
3621
|
+
return;
|
|
3622
|
+
}
|
|
2185
3623
|
(_tagInputRef$value = tagInputRef.value) === null || _tagInputRef$value === void 0 || _tagInputRef$value.focus();
|
|
2186
3624
|
if (props.trigger === 'focus' && listState.localList.length !== 0) {
|
|
2187
3625
|
filterData();
|
|
@@ -2193,6 +3631,67 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2193
3631
|
}
|
|
2194
3632
|
}, 200);
|
|
2195
3633
|
};
|
|
3634
|
+
var handleTagDblclick = function handleTagDblclick(isDblclick) {
|
|
3635
|
+
isShowDblclickEdit.value = isDblclick;
|
|
3636
|
+
setTimeout(function () {
|
|
3637
|
+
state.isEdit = false;
|
|
3638
|
+
popoverProps.isShow = false;
|
|
3639
|
+
}, 10);
|
|
3640
|
+
};
|
|
3641
|
+
var handleTagDblclickChange = function handleTagDblclickChange(item, index, value) {
|
|
3642
|
+
setTimeout(function () {
|
|
3643
|
+
state.isEdit = false;
|
|
3644
|
+
popoverProps.isShow = false;
|
|
3645
|
+
}, 10);
|
|
3646
|
+
if (listState.selectedTagList.length >= props.maxData && props.maxData !== -1) {
|
|
3647
|
+
return;
|
|
3648
|
+
}
|
|
3649
|
+
var separator = props.separator,
|
|
3650
|
+
saveKey = props.saveKey,
|
|
3651
|
+
displayKey = props.displayKey,
|
|
3652
|
+
createTagValidator = props.createTagValidator,
|
|
3653
|
+
clearTextSpace = props.clearTextSpace;
|
|
3654
|
+
var validateTag = function validateTag(value) {
|
|
3655
|
+
if (typeof createTagValidator === 'function') {
|
|
3656
|
+
return createTagValidator(value);
|
|
3657
|
+
}
|
|
3658
|
+
return true;
|
|
3659
|
+
};
|
|
3660
|
+
var newValue;
|
|
3661
|
+
if (separator) {
|
|
3662
|
+
var tags = value.split(separator);
|
|
3663
|
+
tags = tags.filter(function (tag) {
|
|
3664
|
+
return (tag === null || tag === void 0 ? void 0 : tag.trim()) && !tagList.value.includes(tag) && validateTag(tag);
|
|
3665
|
+
});
|
|
3666
|
+
var localTags = tags.map(function (tag) {
|
|
3667
|
+
return saveKeyMap.value[tag] || _defineProperty(_defineProperty({}, saveKey, tag), displayKey, tag);
|
|
3668
|
+
});
|
|
3669
|
+
if (tags.length) {
|
|
3670
|
+
var _listState$selectedTa;
|
|
3671
|
+
(_listState$selectedTa = listState.selectedTagList).splice.apply(_listState$selectedTa, [index, 1].concat(_toConsumableArray(localTags)));
|
|
3672
|
+
}
|
|
3673
|
+
} else {
|
|
3674
|
+
var isObject = _typeof(value) === 'object';
|
|
3675
|
+
newValue = isObject ? value[saveKey] : value.trim();
|
|
3676
|
+
if (clearTextSpace) {
|
|
3677
|
+
newValue = newValue.replace(/\s+/g, '');
|
|
3678
|
+
}
|
|
3679
|
+
if (newValue !== undefined && !tagList.value.includes(newValue) && validateTag(newValue)) {
|
|
3680
|
+
var localItem = saveKeyMap.value[newValue] || (isObject ? value : _defineProperty(_defineProperty({}, saveKey, newValue), displayKey, newValue));
|
|
3681
|
+
listState.selectedTagList.splice(index, 1, localItem);
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
var isExistInit = saveKeyMap.value[item[props.saveKey]];
|
|
3685
|
+
// 将删除的项加入加列表
|
|
3686
|
+
if ((props.allowCreate && isExistInit || !props.allowCreate) && !isSingleSelect.value) {
|
|
3687
|
+
listState.localList.push(item);
|
|
3688
|
+
}
|
|
3689
|
+
// console.error('listState.selectedTagListlistState.selectedTagList', listState.selectedTagList);
|
|
3690
|
+
// console.error('listState.localListlistState.localList', listState.localList);
|
|
3691
|
+
// console.error('tagList.valuetagList.value', tagList.value);
|
|
3692
|
+
emit('update:modelValue', tagList.value);
|
|
3693
|
+
emit('change', tagList.value);
|
|
3694
|
+
};
|
|
2196
3695
|
/**
|
|
2197
3696
|
* 初始化列表数据
|
|
2198
3697
|
*/
|
|
@@ -2302,8 +3801,8 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2302
3801
|
// 聚焦的时候会存在空节点,导致backspace需要点击多次才能删除tag
|
|
2303
3802
|
var index = childNodes.filter(function (item) {
|
|
2304
3803
|
return item.className !== '';
|
|
2305
|
-
}).findIndex(function (
|
|
2306
|
-
var id =
|
|
3804
|
+
}).findIndex(function (_ref6) {
|
|
3805
|
+
var id = _ref6.id;
|
|
2307
3806
|
return id === 'tagInputItem';
|
|
2308
3807
|
});
|
|
2309
3808
|
return index >= 0 ? index : 0;
|
|
@@ -2320,25 +3819,42 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2320
3819
|
}
|
|
2321
3820
|
referenceNode.parentNode.insertBefore(newNode, swap);
|
|
2322
3821
|
};
|
|
3822
|
+
// 计算输入框的实际宽度,包括输入拼音时的正确宽度
|
|
3823
|
+
var updateInputWidth = function updateInputWidth(value) {
|
|
3824
|
+
var charLen = getCharLength(value);
|
|
3825
|
+
if (!charLen) {
|
|
3826
|
+
tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px");
|
|
3827
|
+
return;
|
|
3828
|
+
}
|
|
3829
|
+
var span = document.createElement('span');
|
|
3830
|
+
span.style.visibility = 'hidden';
|
|
3831
|
+
span.style.position = 'absolute';
|
|
3832
|
+
span.style.whiteSpace = 'pre';
|
|
3833
|
+
span.style.font = window.getComputedStyle(tagInputRef.value).font;
|
|
3834
|
+
span.textContent = value;
|
|
3835
|
+
document.body.appendChild(span);
|
|
3836
|
+
var width = span.offsetWidth;
|
|
3837
|
+
document.body.removeChild(span);
|
|
3838
|
+
tagInputRef.value.style.width = "".concat(Math.max(width + 10, INPUT_MIN_WIDTH), "px");
|
|
3839
|
+
};
|
|
3840
|
+
var handleCompositionEnd = function handleCompositionEnd() {
|
|
3841
|
+
updateInputWidth(curInputValue.value);
|
|
3842
|
+
};
|
|
2323
3843
|
var handleInput = function handleInput(e) {
|
|
2324
3844
|
var maxData = props.maxData,
|
|
2325
3845
|
trigger = props.trigger,
|
|
2326
3846
|
allowCreate = props.allowCreate;
|
|
2327
3847
|
if (maxData === -1 || maxData > tagList.value.length) {
|
|
2328
|
-
var
|
|
2329
|
-
value =
|
|
2330
|
-
|
|
2331
|
-
if (charLen) {
|
|
3848
|
+
var _ref7 = e !== null && e !== void 0 && e.target ? e.target : curInputValue,
|
|
3849
|
+
value = _ref7.value;
|
|
3850
|
+
if (value) {
|
|
2332
3851
|
filterData(value);
|
|
2333
|
-
(
|
|
2334
|
-
// getBoundingClientRect获取宽度在中文输入法输入的时候会存在为0的情况,导致不显示输入的内容,按回车以后光标在最前面,所以需要提供默认值
|
|
2335
|
-
var tagInputWidth = inputValueRef.value.getBoundingClientRect().width || charLen * INPUT_MIN_WIDTH;
|
|
2336
|
-
tagInputRef.value.style.width = "".concat(tagInputWidth, "px");
|
|
2337
|
-
});
|
|
3852
|
+
updateInputWidth(value);
|
|
2338
3853
|
} else {
|
|
2339
3854
|
if (trigger === 'focus') {
|
|
2340
3855
|
filterData();
|
|
2341
3856
|
}
|
|
3857
|
+
tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px");
|
|
2342
3858
|
}
|
|
2343
3859
|
} else {
|
|
2344
3860
|
handleBlur();
|
|
@@ -2630,8 +4146,8 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2630
4146
|
return tags.includes(tag[saveKey]);
|
|
2631
4147
|
});
|
|
2632
4148
|
if (tags.length) {
|
|
2633
|
-
var _listState$
|
|
2634
|
-
(_listState$
|
|
4149
|
+
var _listState$selectedTa2;
|
|
4150
|
+
(_listState$selectedTa2 = listState.selectedTagList).splice.apply(_listState$selectedTa2, [index, 0].concat(_toConsumableArray(localTags)));
|
|
2635
4151
|
swapElementPositions(tagInputItemRef.value, nodes[index]);
|
|
2636
4152
|
tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px");
|
|
2637
4153
|
listState.localList = listState.localList.filter(function (val) {
|
|
@@ -2690,8 +4206,8 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2690
4206
|
return saveKeyMap.value[tag] || _defineProperty(_defineProperty({}, saveKey, tag), displayKey, tag);
|
|
2691
4207
|
});
|
|
2692
4208
|
if (tags.length) {
|
|
2693
|
-
var _listState$
|
|
2694
|
-
(_listState$
|
|
4209
|
+
var _listState$selectedTa3;
|
|
4210
|
+
(_listState$selectedTa3 = listState.selectedTagList).splice.apply(_listState$selectedTa3, [targetIndex, 0].concat(_toConsumableArray(localTags)));
|
|
2695
4211
|
moveCount = localTags.length;
|
|
2696
4212
|
isSelected = true;
|
|
2697
4213
|
}
|
|
@@ -2788,6 +4304,7 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2788
4304
|
focusInputTrigger: focusInputTrigger,
|
|
2789
4305
|
activeClass: activeClass,
|
|
2790
4306
|
handleInput: handleInput,
|
|
4307
|
+
handleCompositionEnd: handleCompositionEnd,
|
|
2791
4308
|
handleFocus: handleFocus,
|
|
2792
4309
|
handleBlur: handleBlur,
|
|
2793
4310
|
handleTagSelected: handleTagSelected,
|
|
@@ -2796,7 +4313,9 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2796
4313
|
tagFocus: tagFocus,
|
|
2797
4314
|
handleKeydown: handleKeydown,
|
|
2798
4315
|
handlePaste: handlePaste,
|
|
2799
|
-
resolveClassName: resolveClassName
|
|
4316
|
+
resolveClassName: resolveClassName,
|
|
4317
|
+
handleTagDblclick: handleTagDblclick,
|
|
4318
|
+
handleTagDblclickChange: handleTagDblclickChange
|
|
2800
4319
|
});
|
|
2801
4320
|
},
|
|
2802
4321
|
render: function render() {
|
|
@@ -2814,9 +4333,9 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2814
4333
|
}, [(0,external_vue_namespaceObject.createVNode)(popover_namespaceObject["default"], (0,external_vue_namespaceObject.mergeProps)({
|
|
2815
4334
|
"arrow": false,
|
|
2816
4335
|
"placement": "bottom-start",
|
|
4336
|
+
"referenceCls": this.resolveClassName('tag-input-popover-reference'),
|
|
2817
4337
|
"theme": "light ".concat(this.resolveClassName('tag-input-popover-content')),
|
|
2818
|
-
"trigger": "manual"
|
|
2819
|
-
"referenceCls": this.resolveClassName('tag-input-popover-reference')
|
|
4338
|
+
"trigger": "manual"
|
|
2820
4339
|
}, this.popoverProps), {
|
|
2821
4340
|
"default": function _default() {
|
|
2822
4341
|
var _this$$slots$suffix, _this$$slots, _this$$slots$suffix2;
|
|
@@ -2837,11 +4356,18 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2837
4356
|
"class": "tag-item",
|
|
2838
4357
|
"onClick": _this.tagFocus
|
|
2839
4358
|
}, [(0,external_vue_namespaceObject.createVNode)(tag_render, {
|
|
4359
|
+
"allowCreate": _this.allowCreate,
|
|
2840
4360
|
"displayKey": _this.displayKey,
|
|
2841
4361
|
"node": item,
|
|
2842
4362
|
"tagOverflowTips": _this.tagOverflowTips,
|
|
2843
4363
|
"tooltipKey": _this.tooltipKey || _this.displayKey,
|
|
2844
|
-
"tpl": _this.tagTpl
|
|
4364
|
+
"tpl": _this.tagTpl,
|
|
4365
|
+
"onChange": _this.allowCreate ? function (val) {
|
|
4366
|
+
return _this.handleTagDblclickChange(item, index, val);
|
|
4367
|
+
} : undefined,
|
|
4368
|
+
"onDblclick": _this.allowCreate ? function (isDblclick) {
|
|
4369
|
+
return _this.handleTagDblclick(isDblclick);
|
|
4370
|
+
} : undefined
|
|
2845
4371
|
}, null), _this.showTagClose && (0,external_vue_namespaceObject.createVNode)(icon_namespaceObject.Error, {
|
|
2846
4372
|
"class": "remove-tag",
|
|
2847
4373
|
"onClick": _this.handleTagRemove.bind(_this, item, index)
|
|
@@ -2860,6 +4386,7 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2860
4386
|
"spellcheck": "false",
|
|
2861
4387
|
"type": "text",
|
|
2862
4388
|
"onBlur": _this.handleBlur,
|
|
4389
|
+
"onCompositionend": _this.handleCompositionEnd,
|
|
2863
4390
|
"onFocus": _this.handleFocus,
|
|
2864
4391
|
"onInput": _this.handleInput,
|
|
2865
4392
|
"onKeydown": _this.handleKeydown,
|
|
@@ -2939,7 +4466,7 @@ function tag_input_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
2939
4466
|
* Tencent is pleased to support the open source community by making
|
|
2940
4467
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
|
2941
4468
|
*
|
|
2942
|
-
* Copyright (C)
|
|
4469
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
2943
4470
|
*
|
|
2944
4471
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
|
|
2945
4472
|
*
|