浏览代码

Fixed regex to replace text content in HTML tag (#5534)

sk 5 年之前
父节点
当前提交
88358a1830
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/bootstrap-table.js

+ 2 - 1
src/bootstrap-table.js

@@ -1583,8 +1583,9 @@ class BootstrapTable {
         if (isHTML) {
           // value can contains a HTML tags
           const textContent = new DOMParser().parseFromString(value.toString(), 'text/html').documentElement.textContent
+          const textReplaced = textContent.replace(regExp, marker)
 
-          defValue = value.toString().replace(textContent, textContent.replace(regExp, marker))
+          defValue = value.replace(new RegExp(`(>\\s*)(${textContent})(\\s*)`, 'gm'), `$1${textReplaced}$3`)
         } else {
           // but usually not
           defValue = value.toString().replace(regExp, marker)