@whitesev/pops 1.9.7 → 2.0.1

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/dist/index.amd.js CHANGED
@@ -312,6 +312,32 @@ define((function () { 'use strict';
312
312
  }
313
313
  const popsUtils = new PopsUtils();
314
314
 
315
+ const PopsSafeUtils = {
316
+ /**
317
+ * 获取安全的html
318
+ */
319
+ getSafeHTML(text) {
320
+ // @ts-ignore
321
+ if (globalThis.trustedTypes) {
322
+ // @ts-ignore
323
+ const policy = globalThis.trustedTypes.createPolicy("safe-innerHTML", {
324
+ createHTML: (html) => html,
325
+ });
326
+ return policy.createHTML(text);
327
+ }
328
+ else {
329
+ return text;
330
+ }
331
+ },
332
+ /**
333
+ * 设置安全的html
334
+ */
335
+ setSafeHTML($el, text) {
336
+ // 创建 TrustedHTML 策略(需 CSP 允许)
337
+ $el.innerHTML = this.getSafeHTML(text);
338
+ },
339
+ };
340
+
315
341
  class PopsDOMUtilsEvent {
316
342
  on(element, eventType, selector, callback, option) {
317
343
  /**
@@ -1249,7 +1275,7 @@ define((function () { 'use strict';
1249
1275
  attributes) {
1250
1276
  let tempElement = PopsCore.document.createElement(tagName);
1251
1277
  if (typeof property === "string") {
1252
- tempElement.innerHTML = property;
1278
+ PopsSafeUtils.setSafeHTML(tempElement, property);
1253
1279
  return tempElement;
1254
1280
  }
1255
1281
  if (property == null) {
@@ -1260,6 +1286,11 @@ define((function () { 'use strict';
1260
1286
  }
1261
1287
  Object.keys(property).forEach((key) => {
1262
1288
  let value = property[key];
1289
+ if (key === "innerHTML") {
1290
+ PopsSafeUtils.setSafeHTML(tempElement, value);
1291
+ return;
1292
+ }
1293
+ // @ts-ignore
1263
1294
  tempElement[key] = value;
1264
1295
  });
1265
1296
  Object.keys(attributes).forEach((key) => {
@@ -1462,7 +1493,7 @@ define((function () { 'use strict';
1462
1493
  }
1463
1494
  function parseHTMLByCreateDom() {
1464
1495
  let tempDIV = PopsCore.document.createElement("div");
1465
- tempDIV.innerHTML = html;
1496
+ PopsSafeUtils.setSafeHTML(tempDIV, html);
1466
1497
  if (isComplete) {
1467
1498
  return tempDIV;
1468
1499
  }
@@ -1495,7 +1526,7 @@ define((function () { 'use strict';
1495
1526
  }
1496
1527
  function elementAppendChild(ele, text) {
1497
1528
  if (typeof content === "string") {
1498
- ele.insertAdjacentHTML("beforeend", text);
1529
+ ele.insertAdjacentHTML("beforeend", PopsSafeUtils.getSafeHTML(text));
1499
1530
  }
1500
1531
  else {
1501
1532
  ele.appendChild(text);
@@ -1630,7 +1661,7 @@ define((function () { 'use strict';
1630
1661
  return;
1631
1662
  }
1632
1663
  if (typeof content === "string") {
1633
- element.insertAdjacentHTML("beforebegin", content);
1664
+ element.insertAdjacentHTML("beforebegin", PopsSafeUtils.getSafeHTML(content));
1634
1665
  }
1635
1666
  else {
1636
1667
  element.parentElement.insertBefore(content, element);
@@ -1653,7 +1684,7 @@ define((function () { 'use strict';
1653
1684
  return;
1654
1685
  }
1655
1686
  if (typeof content === "string") {
1656
- element.insertAdjacentHTML("afterend", content);
1687
+ element.insertAdjacentHTML("afterend", PopsSafeUtils.getSafeHTML(content));
1657
1688
  }
1658
1689
  else {
1659
1690
  element.parentElement.insertBefore(content, element.nextSibling);
@@ -4858,26 +4889,29 @@ define((function () { 'use strict';
4858
4889
  fileNameElement.className = "pops-folder-list-table__body-td";
4859
4890
  fileTimeElement.className = "pops-folder-list-table__body-td";
4860
4891
  fileFormatSize.className = "pops-folder-list-table__body-td";
4861
- fileNameElement.innerHTML = `
4862
- <div class="pops-folder-list-file-name cursor-p">
4863
- <div>
4864
- <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4865
- <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4866
- ${fileName}
4867
- </a>
4868
- </div>
4869
- </div>
4870
- `;
4871
- fileTimeElement.innerHTML = `
4872
- <div class="pops-folder-list__time">
4873
- <span>${latestTime}</span>
4874
- </div>
4875
- `;
4876
- fileFormatSize.innerHTML = `
4877
- <div class="pops-folder-list-format-size">
4878
- <span>${fileSize}</span>
4879
- </div>
4880
- `;
4892
+ PopsSafeUtils.setSafeHTML(fileNameElement,
4893
+ /*html*/ `
4894
+ <div class="pops-folder-list-file-name cursor-p">
4895
+ <div>
4896
+ <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4897
+ <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4898
+ ${fileName}
4899
+ </a>
4900
+ </div>
4901
+ </div>
4902
+ `);
4903
+ PopsSafeUtils.setSafeHTML(fileTimeElement,
4904
+ /*html*/ `
4905
+ <div class="pops-folder-list__time">
4906
+ <span>${latestTime}</span>
4907
+ </div>
4908
+ `);
4909
+ PopsSafeUtils.setSafeHTML(fileFormatSize,
4910
+ /*html*/ `
4911
+ <div class="pops-folder-list-format-size">
4912
+ <span>${fileSize}</span>
4913
+ </div>
4914
+ `);
4881
4915
  /* 存储原来的值 */
4882
4916
  let __value__ = {
4883
4917
  fileName: origin_fileName,
@@ -4938,17 +4972,18 @@ define((function () { 'use strict';
4938
4972
  }
4939
4973
  folderELement.className = "pops-folder-list-table__body-row";
4940
4974
  fileNameElement.className = "pops-folder-list-table__body-td";
4941
- fileNameElement.innerHTML = `
4942
- <div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
4943
- <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4944
- <div>
4945
- <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4946
- ${fileName}
4947
- </a>
4948
- <span>${latestTime} ${fileSize}</span>
4949
- </div>
4950
- </div>
4951
- `;
4975
+ PopsSafeUtils.setSafeHTML(fileNameElement,
4976
+ /*html*/ `
4977
+ <div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
4978
+ <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
4979
+ <div>
4980
+ <a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
4981
+ ${fileName}
4982
+ </a>
4983
+ <span>${latestTime} ${fileSize}</span>
4984
+ </div>
4985
+ </div>
4986
+ `);
4952
4987
  /* 存储原来的值 */
4953
4988
  let __value__ = {
4954
4989
  fileName: origin_fileName,
@@ -4968,7 +5003,7 @@ define((function () { 'use strict';
4968
5003
  * 清空每行的元素
4969
5004
  */
4970
5005
  function clearFolerRow() {
4971
- folderListBodyElement.innerHTML = "";
5006
+ PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
4972
5007
  }
4973
5008
  function getArrowIconElement() {
4974
5009
  let iconArrowElement = popsDOMUtils.createElement("div", {
@@ -5967,8 +6002,8 @@ define((function () { 'use strict';
5967
6002
  * 清空container容器的元素
5968
6003
  */
5969
6004
  clearContainer() {
5970
- this.sectionContainerHeaderULElement.innerHTML = "";
5971
- this.sectionContainerULElement.innerHTML = "";
6005
+ PopsSafeUtils.setSafeHTML(this.sectionContainerHeaderULElement, "");
6006
+ PopsSafeUtils.setSafeHTML(this.sectionContainerULElement, "");
5972
6007
  this.$el.$content
5973
6008
  ?.querySelectorAll("section.pops-panel-deepMenu-container")
5974
6009
  .forEach((ele) => ele.remove());
@@ -6054,8 +6089,9 @@ define((function () { 'use strict';
6054
6089
  createAsideItem(asideConfig) {
6055
6090
  let liElement = document.createElement("li");
6056
6091
  liElement.id = asideConfig.id;
6092
+ // @ts-ignore
6057
6093
  liElement["__forms__"] = asideConfig.forms;
6058
- liElement.innerHTML = asideConfig.title;
6094
+ PopsSafeUtils.setSafeHTML(liElement, asideConfig.title);
6059
6095
  /* 处理className */
6060
6096
  this.setElementClassName(liElement, asideConfig.className);
6061
6097
  this.setElementAttributes(liElement, asideConfig.attributes);
@@ -6078,18 +6114,19 @@ define((function () { 'use strict';
6078
6114
  if (Boolean(formConfig.description)) {
6079
6115
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6080
6116
  }
6081
- liElement.innerHTML = /*html*/ `
6082
- <div class="pops-panel-item-left-text">
6083
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6084
- ${leftDescriptionText}
6085
- </div>
6086
- <div class="pops-panel-switch">
6087
- <input class="pops-panel-switch__input" type="checkbox">
6088
- <span class="pops-panel-switch__core">
6089
- <div class="pops-panel-switch__action">
6090
- </div>
6091
- </span>
6092
- </div>`;
6117
+ PopsSafeUtils.setSafeHTML(liElement,
6118
+ /*html*/ `
6119
+ <div class="pops-panel-item-left-text">
6120
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6121
+ ${leftDescriptionText}
6122
+ </div>
6123
+ <div class="pops-panel-switch">
6124
+ <input class="pops-panel-switch__input" type="checkbox">
6125
+ <span class="pops-panel-switch__core">
6126
+ <div class="pops-panel-switch__action">
6127
+ </div>
6128
+ </span>
6129
+ </div>`);
6093
6130
  const PopsPanelSwitch = {
6094
6131
  [Symbol.toStringTag]: "PopsPanelSwitch",
6095
6132
  $data: {
@@ -6179,14 +6216,16 @@ define((function () { 'use strict';
6179
6216
  if (Boolean(formConfig.description)) {
6180
6217
  leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6181
6218
  }
6182
- liElement.innerHTML = `
6183
- <div class="pops-panel-item-left-text">
6184
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6185
- ${leftDescriptionText}
6186
- </div>
6187
- <div class="pops-panel-slider">
6188
- <input type="range" min="${formConfig.min}" max="${formConfig.max}">
6189
- </div>`;
6219
+ PopsSafeUtils.setSafeHTML(liElement,
6220
+ /*html*/ `
6221
+ <div class="pops-panel-item-left-text">
6222
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6223
+ ${leftDescriptionText}
6224
+ </div>
6225
+ <div class="pops-panel-slider">
6226
+ <input type="range" min="${formConfig.min}" max="${formConfig.max}">
6227
+ </div>
6228
+ `);
6190
6229
  let rangeInputElement = liElement.querySelector(".pops-panel-slider input[type=range]");
6191
6230
  if (formConfig.step) {
6192
6231
  rangeInputElement.setAttribute("step", formConfig.step.toString());
@@ -6242,19 +6281,20 @@ define((function () { 'use strict';
6242
6281
  if (Boolean(formConfig.description)) {
6243
6282
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6244
6283
  }
6245
- liElement.innerHTML = /*html*/ `
6246
- <div class="pops-panel-item-left-text" style="flex: 1;">
6247
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6248
- ${leftDescriptionText}
6249
- </div>
6250
- <div class="pops-slider pops-slider-width">
6251
- <div class="pops-slider__runway">
6252
- <div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
6253
- <div class="pops-slider__button-wrapper" style="left: 0%">
6254
- <div class="pops-slider__button"></div>
6255
- </div>
6284
+ PopsSafeUtils.setSafeHTML(liElement,
6285
+ /*html*/ `
6286
+ <div class="pops-panel-item-left-text" style="flex: 1;">
6287
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6288
+ ${leftDescriptionText}
6256
6289
  </div>
6257
- </div>`;
6290
+ <div class="pops-slider pops-slider-width">
6291
+ <div class="pops-slider__runway">
6292
+ <div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
6293
+ <div class="pops-slider__button-wrapper" style="left: 0%">
6294
+ <div class="pops-slider__button"></div>
6295
+ </div>
6296
+ </div>
6297
+ </div>`);
6258
6298
  const PopsPanelSlider = {
6259
6299
  [Symbol.toStringTag]: "PopsPanelSlider",
6260
6300
  /**
@@ -6804,15 +6844,16 @@ define((function () { 'use strict';
6804
6844
  if (Boolean(formConfig.description)) {
6805
6845
  leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
6806
6846
  }
6807
- liElement.innerHTML = `
6808
- <div class="pops-panel-item-left-text">
6809
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6810
- ${leftDescriptionText}
6811
- </div>
6812
- <div class="pops-panel-input pops-user-select-none">
6813
- <input type="${inputType}" placeholder="${formConfig.placeholder}">
6814
- </div>
6815
- `;
6847
+ PopsSafeUtils.setSafeHTML(liElement,
6848
+ /*html*/ `
6849
+ <div class="pops-panel-item-left-text">
6850
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
6851
+ ${leftDescriptionText}
6852
+ </div>
6853
+ <div class="pops-panel-input pops-user-select-none">
6854
+ <input type="${inputType}" placeholder="${formConfig.placeholder}">
6855
+ </div>
6856
+ `);
6816
6857
  const PopsPanelInput = {
6817
6858
  [Symbol.toStringTag]: "PopsPanelInput",
6818
6859
  $ele: {
@@ -6855,11 +6896,12 @@ define((function () { 'use strict';
6855
6896
  initEle() {
6856
6897
  this.$ele.input.parentElement.insertBefore(this.$ele.inputSpanIcon, this.$ele.input.nextSibling);
6857
6898
  this.$ele.inputSpanIcon.className = "pops-panel-input__suffix";
6858
- this.$ele.inputSpanIcon.innerHTML = `
6859
- <span class="pops-panel-input__suffix-inner">
6860
- <i class="pops-panel-icon"></i>
6861
- </span>
6862
- `;
6899
+ PopsSafeUtils.setSafeHTML(this.$ele.inputSpanIcon,
6900
+ /*html*/ `
6901
+ <span class="pops-panel-input__suffix-inner">
6902
+ <i class="pops-panel-icon"></i>
6903
+ </span>
6904
+ `);
6863
6905
  this.$ele.inputSpanIconInner =
6864
6906
  this.$ele.inputSpanIcon.querySelector(".pops-panel-input__suffix-inner");
6865
6907
  this.$ele.icon =
@@ -6894,7 +6936,7 @@ define((function () { 'use strict';
6894
6936
  },
6895
6937
  /**
6896
6938
  * 设置input元素的type
6897
- * @param {string} [typeValue="text"] type值
6939
+ * @param [typeValue="text"] type值
6898
6940
  */
6899
6941
  setInputType(typeValue = "text") {
6900
6942
  this.$ele.input.setAttribute("type", typeValue);
@@ -6903,14 +6945,14 @@ define((function () { 'use strict';
6903
6945
  * 删除图标按钮
6904
6946
  */
6905
6947
  removeCircleIcon() {
6906
- this.$ele.icon.innerHTML = "";
6948
+ PopsSafeUtils.setSafeHTML(this.$ele.icon, "");
6907
6949
  },
6908
6950
  /**
6909
6951
  * 添加清空图标按钮
6910
- * @param {string} [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
6952
+ * @param [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
6911
6953
  */
6912
6954
  setCircleIcon(svgHTML = pops.config.iconSVG.circleClose) {
6913
- this.$ele.icon.innerHTML = svgHTML;
6955
+ PopsSafeUtils.setSafeHTML(this.$ele.icon, svgHTML);
6914
6956
  },
6915
6957
  /**
6916
6958
  * 添加图标按钮的点击事件
@@ -6999,16 +7041,17 @@ define((function () { 'use strict';
6999
7041
  if (Boolean(formConfig.description)) {
7000
7042
  leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7001
7043
  }
7002
- liElement.innerHTML = `
7003
- <div class="pops-panel-item-left-text">
7004
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7005
- ${leftDescriptionText}
7006
- </div>
7007
- <div class="pops-panel-textarea">
7008
- <textarea placeholder="${formConfig.placeholder ?? ""}">
7009
- </textarea>
7010
- </div>
7011
- `;
7044
+ PopsSafeUtils.setSafeHTML(liElement,
7045
+ /*html*/ `
7046
+ <div class="pops-panel-item-left-text">
7047
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7048
+ ${leftDescriptionText}
7049
+ </div>
7050
+ <div class="pops-panel-textarea">
7051
+ <textarea placeholder="${formConfig.placeholder ?? ""}">
7052
+ </textarea>
7053
+ </div>
7054
+ `);
7012
7055
  const PopsPanelTextArea = {
7013
7056
  [Symbol.toStringTag]: "PopsPanelTextArea",
7014
7057
  $ele: {
@@ -7073,15 +7116,16 @@ define((function () { 'use strict';
7073
7116
  if (Boolean(formConfig.description)) {
7074
7117
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7075
7118
  }
7076
- liElement.innerHTML = /*html*/ `
7077
- <div class="pops-panel-item-left-text">
7078
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7079
- ${leftDescriptionText}
7080
- </div>
7081
- <div class="pops-panel-select pops-user-select-none">
7082
- <select></select>
7083
- </div>
7084
- `;
7119
+ PopsSafeUtils.setSafeHTML(liElement,
7120
+ /*html*/ `
7121
+ <div class="pops-panel-item-left-text">
7122
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7123
+ ${leftDescriptionText}
7124
+ </div>
7125
+ <div class="pops-panel-select pops-user-select-none">
7126
+ <select></select>
7127
+ </div>
7128
+ `);
7085
7129
  const PopsPanelSelect = {
7086
7130
  [Symbol.toStringTag]: "PopsPanelSelect",
7087
7131
  $ele: {
@@ -7268,33 +7312,34 @@ define((function () { 'use strict';
7268
7312
  if (Boolean(formConfig.description)) {
7269
7313
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7270
7314
  }
7271
- liElement.innerHTML = /*html*/ `
7272
- <div class="pops-panel-item-left-text">
7273
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7274
- ${leftDescriptionText}
7275
- </div>
7276
- <div class="pops-panel-select-multiple">
7277
- <div class="el-select__wrapper">
7278
- <div class="el-select__selection">
7279
- <!-- 这个是用于手动输入的,这里暂不适配 -->
7280
- <div class="el-select__selected-item el-select__input-wrapper">
7281
-
7315
+ PopsSafeUtils.setSafeHTML(liElement,
7316
+ /*html*/ `
7317
+ <div class="pops-panel-item-left-text">
7318
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7319
+ ${leftDescriptionText}
7320
+ </div>
7321
+ <div class="pops-panel-select-multiple">
7322
+ <div class="el-select__wrapper">
7323
+ <div class="el-select__selection">
7324
+ <!-- 这个是用于手动输入的,这里暂不适配 -->
7325
+ <div class="el-select__selected-item el-select__input-wrapper">
7326
+
7327
+ </div>
7328
+ <!-- 这个是placeholder -->
7329
+ <div class="el-select__selected-item el-select__placeholder">
7330
+ </div>
7282
7331
  </div>
7283
- <!-- 这个是placeholder -->
7284
- <div class="el-select__selected-item el-select__placeholder">
7332
+ <!-- 下拉箭头 -->
7333
+ <div class="el-select__suffix">
7334
+ <i class="el-icon el-select__caret el-select__icon">
7335
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
7336
+ <path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>
7337
+ </svg>
7338
+ </i>
7285
7339
  </div>
7286
7340
  </div>
7287
- <!-- 下拉箭头 -->
7288
- <div class="el-select__suffix">
7289
- <i class="el-icon el-select__caret el-select__icon">
7290
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
7291
- <path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>
7292
- </svg>
7293
- </i>
7294
- </div>
7295
7341
  </div>
7296
- </div>
7297
- `;
7342
+ `);
7298
7343
  const PopsPanelSelectMultiple = {
7299
7344
  [Symbol.toStringTag]: "PopsPanelSelectMultiple",
7300
7345
  $el: {
@@ -7419,7 +7464,7 @@ define((function () { 'use strict';
7419
7464
  /** 关闭图标 */
7420
7465
  const $closeIcon = $selectedItem.querySelector(".el-icon.el-tag__close");
7421
7466
  if (data.isHTML) {
7422
- $tagText.innerHTML = data.text;
7467
+ PopsSafeUtils.setSafeHTML($tagText, data.text);
7423
7468
  }
7424
7469
  else {
7425
7470
  $tagText.innerText = data.text;
@@ -7826,18 +7871,19 @@ define((function () { 'use strict';
7826
7871
  if (Boolean(formConfig.description)) {
7827
7872
  leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
7828
7873
  }
7829
- liElement.innerHTML = /*html*/ `
7830
- <div class="pops-panel-item-left-text">
7831
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7832
- ${leftDescriptionText}
7833
- </div>
7834
- <div class="pops-panel-button">
7835
- <button class="pops-panel-button_inner">
7836
- <i class="pops-bottom-icon"></i>
7837
- <span class="pops-panel-button-text"></span>
7838
- </button>
7839
- </div>
7840
- `;
7874
+ PopsSafeUtils.setSafeHTML(liElement,
7875
+ /*html*/ `
7876
+ <div class="pops-panel-item-left-text">
7877
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7878
+ ${leftDescriptionText}
7879
+ </div>
7880
+ <div class="pops-panel-button">
7881
+ <button class="pops-panel-button_inner">
7882
+ <i class="pops-bottom-icon"></i>
7883
+ <span class="pops-panel-button-text"></span>
7884
+ </button>
7885
+ </div>
7886
+ `);
7841
7887
  const PopsPanelButton = {
7842
7888
  [Symbol.toStringTag]: "PopsPanelButton",
7843
7889
  $ele: {
@@ -7907,7 +7953,7 @@ define((function () { 'use strict';
7907
7953
  * 设置icon图标的svg
7908
7954
  */
7909
7955
  setIconSVG(svgHTML) {
7910
- this.$ele.icon.innerHTML = svgHTML;
7956
+ PopsSafeUtils.setSafeHTML(this.$ele.icon, svgHTML);
7911
7957
  },
7912
7958
  /**
7913
7959
  * 设置icon图标是否旋转
@@ -7946,7 +7992,7 @@ define((function () { 'use strict';
7946
7992
  * @param text
7947
7993
  */
7948
7994
  setButtonText(text) {
7949
- this.$ele.spanText.innerHTML = text;
7995
+ PopsSafeUtils.setSafeHTML(this.$ele.spanText, text);
7950
7996
  },
7951
7997
  setClickEvent() {
7952
7998
  popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
@@ -7992,16 +8038,17 @@ define((function () { 'use strict';
7992
8038
  if (formConfig.rightText) {
7993
8039
  rightText = /*html*/ `<p class="pops-panel-item-right-text">${formConfig.rightText}</p>`;
7994
8040
  }
7995
- $li.innerHTML = /*html*/ `
7996
- <div class="pops-panel-item-left-text">
7997
- <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
7998
- ${leftDescriptionText}
7999
- </div>
8000
- <div class="pops-panel-deepMenu">
8001
- ${rightText}
8002
- ${arrowRightIconHTML}
8003
- </div>
8004
- `;
8041
+ PopsSafeUtils.setSafeHTML($li,
8042
+ /*html*/ `
8043
+ <div class="pops-panel-item-left-text">
8044
+ <p class="pops-panel-item-left-main-text">${formConfig.text}</p>
8045
+ ${leftDescriptionText}
8046
+ </div>
8047
+ <div class="pops-panel-deepMenu">
8048
+ ${rightText}
8049
+ ${arrowRightIconHTML}
8050
+ </div>
8051
+ `);
8005
8052
  const PopsPanelDeepMenu = {
8006
8053
  [Symbol.toStringTag]: "PopsPanelDeepMenu",
8007
8054
  $ele: {
@@ -8031,19 +8078,19 @@ define((function () { 'use strict';
8031
8078
  let formHeaderDivElement = popsDOMUtils.createElement("div", {
8032
8079
  className: "pops-panel-forms-container-item-header-text",
8033
8080
  });
8034
- formHeaderDivElement.innerHTML = formConfig_forms["text"];
8081
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement, formConfig_forms["text"]);
8035
8082
  if (formConfig_forms.isFold) {
8036
8083
  /* 添加第一个 */
8037
8084
  /* 加进容器内 */
8038
- formHeaderDivElement.innerHTML = /*html*/ `
8085
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement,
8086
+ /*html*/ `
8039
8087
  <p>${formConfig_forms.text}</p>
8040
8088
  <i class="pops-panel-forms-fold-container-icon">
8041
8089
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
8042
8090
  <path d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
8043
8091
  </svg>
8044
8092
  </i>
8045
-
8046
- `;
8093
+ `);
8047
8094
  // 添加点击事件
8048
8095
  popsDOMUtils.on(formHeaderDivElement, "click", (event) => {
8049
8096
  if (formContainerListElement.hasAttribute("data-fold-enable")) {
@@ -8241,18 +8288,18 @@ define((function () { 'use strict';
8241
8288
  let formHeaderDivElement = popsDOMUtils.createElement("div", {
8242
8289
  className: "pops-panel-forms-container-item-header-text",
8243
8290
  });
8244
- formHeaderDivElement.innerHTML = formConfig_forms["text"];
8291
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement, formConfig_forms["text"]);
8245
8292
  if (formConfig_forms.isFold) {
8246
8293
  /* 加进容器内 */
8247
- formHeaderDivElement.innerHTML = /*html*/ `
8294
+ PopsSafeUtils.setSafeHTML(formHeaderDivElement,
8295
+ /*html*/ `
8248
8296
  <p>${formConfig_forms.text}</p>
8249
8297
  <i class="pops-panel-forms-fold-container-icon">
8250
8298
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
8251
8299
  <path d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
8252
8300
  </svg>
8253
8301
  </i>
8254
-
8255
- `;
8302
+ `);
8256
8303
  // 添加点击事件
8257
8304
  popsDOMUtils.on(formHeaderDivElement, "click", (event) => {
8258
8305
  if (formContainerListElement.hasAttribute("data-fold-enable")) {
@@ -8338,7 +8385,7 @@ define((function () { 'use strict';
8338
8385
  let containerHeaderTitleLIElement = document.createElement("li");
8339
8386
  containerHeaderTitleLIElement["__asideConfig__"] =
8340
8387
  asideConfig;
8341
- containerHeaderTitleLIElement.innerHTML = headerTitleText;
8388
+ PopsSafeUtils.setSafeHTML(containerHeaderTitleLIElement, headerTitleText);
8342
8389
  this.sectionContainerHeaderULElement.appendChild(containerHeaderTitleLIElement);
8343
8390
  }
8344
8391
  let __forms__ = asideLiElement["__forms__"];
@@ -8627,9 +8674,11 @@ define((function () { 'use strict';
8627
8674
  pops.config.cssText.rightClickMenu,
8628
8675
  ]);
8629
8676
  if (config.style != null) {
8630
- let cssNode = document.createElement("style");
8631
- cssNode.setAttribute("type", "text/css");
8632
- cssNode.innerHTML = config.style;
8677
+ let cssNode = popsDOMUtils.createElement("style", {
8678
+ innerHTML: config.style,
8679
+ }, {
8680
+ type: "text/css",
8681
+ });
8633
8682
  $shadowRoot.appendChild(cssNode);
8634
8683
  }
8635
8684
  const PopsContextMenu = {
@@ -8938,7 +8987,7 @@ define((function () { 'use strict';
8938
8987
  menuLiElement.appendChild(iconElement);
8939
8988
  }
8940
8989
  /* 插入文字 */
8941
- menuLiElement.insertAdjacentHTML("beforeend", `<span>${item.text}</span>`);
8990
+ menuLiElement.insertAdjacentHTML("beforeend", PopsSafeUtils.getSafeHTML(`<span>${item.text}</span>`));
8942
8991
  /* 如果存在子数据,显示 */
8943
8992
  if (item.item && Array.isArray(item.item)) {
8944
8993
  popsDOMUtils.addClassName(menuLiElement, `pops-${PopsType}-item`);
@@ -9111,8 +9160,11 @@ define((function () { 'use strict';
9111
9160
  ]);
9112
9161
  if (config.style != null) {
9113
9162
  let cssNode = document.createElement("style");
9114
- cssNode.setAttribute("type", "text/css");
9115
- cssNode.innerHTML = config.style;
9163
+ popsDOMUtils.createElement("style", {
9164
+ innerHTML: config.style,
9165
+ }, {
9166
+ type: "text/css",
9167
+ });
9116
9168
  $shadowRoot.appendChild(cssNode);
9117
9169
  }
9118
9170
  const SearchSuggestion = {
@@ -9489,7 +9541,7 @@ define((function () { 'use strict';
9489
9541
  * 清空所有的搜索结果
9490
9542
  */
9491
9543
  clearAllSearchItemLi() {
9492
- SearchSuggestion.$el.$hintULContainer.innerHTML = "";
9544
+ PopsSafeUtils.setSafeHTML(SearchSuggestion.$el.$hintULContainer, "");
9493
9545
  },
9494
9546
  /**
9495
9547
  * 更新搜索建议框的位置(top、left)
@@ -9571,7 +9623,8 @@ define((function () { 'use strict';
9571
9623
  * 动态更新CSS
9572
9624
  */
9573
9625
  updateDynamicCSS() {
9574
- this.$el.$dynamicCSS.innerHTML = this.getDynamicCSS();
9626
+ let cssText = this.getDynamicCSS();
9627
+ PopsSafeUtils.setSafeHTML(this.$el.$dynamicCSS, cssText);
9575
9628
  },
9576
9629
  /**
9577
9630
  * 更新页面显示的搜索结果
@@ -9761,7 +9814,7 @@ define((function () { 'use strict';
9761
9814
  if (text == null) {
9762
9815
  text = this.getContent();
9763
9816
  }
9764
- this.$el.$content.innerHTML = text;
9817
+ PopsSafeUtils.setSafeHTML(this.$el.$content, text);
9765
9818
  }
9766
9819
  /**
9767
9820
  * 获取z-index
@@ -10133,7 +10186,7 @@ define((function () { 'use strict';
10133
10186
  /** 配置 */
10134
10187
  config = {
10135
10188
  /** 版本号 */
10136
- version: "2025.1.1",
10189
+ version: "2025.3.2",
10137
10190
  cssText: {
10138
10191
  /** 主CSS */
10139
10192
  index: indexCSS,
@@ -10238,7 +10291,7 @@ define((function () { 'use strict';
10238
10291
  /* 处理获取当前所有的动画名 */
10239
10292
  this.config.isInit = true;
10240
10293
  let animationStyle = document.createElement("style");
10241
- animationStyle.innerHTML = this.config.cssText.anim;
10294
+ PopsSafeUtils.setSafeHTML(animationStyle, this.config.cssText.anim);
10242
10295
  popsDOMUtils.appendHead(animationStyle);
10243
10296
  this.config.animation = null;
10244
10297
  this.config.animation = PopsInstanceUtils.getKeyFrames(animationStyle.sheet);