Browse Source

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

sk 5 years ago
parent
commit
88358a1830
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/bootstrap-table.js

+ 2 - 1
src/bootstrap-table.js

@@ -1583,8 +1583,9 @@ class BootstrapTable {
         if (isHTML) {
         if (isHTML) {
           // value can contains a HTML tags
           // value can contains a HTML tags
           const textContent = new DOMParser().parseFromString(value.toString(), 'text/html').documentElement.textContent
           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 {
         } else {
           // but usually not
           // but usually not
           defValue = value.toString().replace(regExp, marker)
           defValue = value.toString().replace(regExp, marker)