Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2020-01-07 23:07:51 +0300
committerGitHub <noreply@github.com>2020-01-07 23:07:51 +0300
commit9c2b9ac74d4abb5ec8b7864054315de3409d5f3a (patch)
treebdd48def07c5ef9c88c01c15554e3acada526b59 /js
parenta7945d4501377cd42afd49c0e885b0e1923b36cc (diff)
Use regex.test() when we want to check for a Boolean. (#29969)
Diffstat (limited to 'js')
-rw-r--r--js/src/popover.js1
-rw-r--r--js/src/tooltip.js5
-rw-r--r--js/src/util/sanitizer.js6
3 files changed, 5 insertions, 7 deletions
diff --git a/js/src/popover.js b/js/src/popover.js
index a633af4ba0..d71a78236c 100644
--- a/js/src/popover.js
+++ b/js/src/popover.js
@@ -135,7 +135,6 @@ class Popover extends Tooltip {
_cleanTipClass() {
const tip = this.getTipElement()
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
-
if (tabClass !== null && tabClass.length > 0) {
tabClass.map(token => token.trim())
.forEach(tClass => tip.classList.remove(tClass))
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index b4f047b70e..1bc000d2cc 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -747,9 +747,8 @@ class Tooltip {
_cleanTipClass() {
const tip = this.getTipElement()
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
- if (tabClass !== null && tabClass.length) {
- tabClass
- .map(token => token.trim())
+ if (tabClass !== null && tabClass.length > 0) {
+ tabClass.map(token => token.trim())
.forEach(tClass => tip.classList.remove(tClass))
}
}
diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js
index a85bc5f91d..8f72d2005a 100644
--- a/js/src/util/sanitizer.js
+++ b/js/src/util/sanitizer.js
@@ -39,7 +39,7 @@ const allowedAttribute = (attr, allowedAttributeList) => {
if (allowedAttributeList.indexOf(attrName) !== -1) {
if (uriAttrs.indexOf(attrName) !== -1) {
- return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
+ return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue)
}
return true
@@ -48,8 +48,8 @@ const allowedAttribute = (attr, allowedAttributeList) => {
const regExp = allowedAttributeList.filter(attrRegex => attrRegex instanceof RegExp)
// Check if a regular expression validates the attribute.
- for (let i = 0, l = regExp.length; i < l; i++) {
- if (attrName.match(regExp[i])) {
+ for (let i = 0, len = regExp.length; i < len; i++) {
+ if (regExp[i].test(attrName)) {
return true
}
}