diff options
| author | XhmikosR <[email protected]> | 2020-05-02 16:43:13 +0300 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2020-11-14 15:54:50 +0200 |
| commit | b9f7668cf65ab166660d5695affb72d2553f59a9 (patch) | |
| tree | 3475949a50e33ebe7f751141ca10dad94f644f59 /js | |
| parent | 470e99ed5f53f8a94df9e501fcc30423151be324 (diff) | |
| download | bootstrap-b9f7668cf65ab166660d5695affb72d2553f59a9.tar.xz bootstrap-b9f7668cf65ab166660d5695affb72d2553f59a9.zip | |
Switch to `String.includes()`
Diffstat (limited to 'js')
| -rw-r--r-- | js/src/dom/event-handler.js | 8 | ||||
| -rw-r--r-- | js/src/tooltip.js | 2 | ||||
| -rw-r--r-- | js/src/util/sanitizer.js | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index bf9aa38df..64a061ae6 100644 --- a/js/src/dom/event-handler.js +++ b/js/src/dom/event-handler.js @@ -151,7 +151,7 @@ function normalizeParams(originalTypeEvent, handler, delegationFn) { typeEvent = custom } - const isNative = nativeEvents.indexOf(typeEvent) > -1 + const isNative = nativeEvents.includes(typeEvent) if (!isNative) { typeEvent = originalTypeEvent @@ -210,7 +210,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) { const storeElementEvent = events[typeEvent] || {} Object.keys(storeElementEvent).forEach(handlerKey => { - if (handlerKey.indexOf(namespace) > -1) { + if (handlerKey.includes(namespace)) { const event = storeElementEvent[handlerKey] removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector) @@ -257,7 +257,7 @@ const EventHandler = { Object.keys(storeElementEvent).forEach(keyHandlers => { const handlerKey = keyHandlers.replace(stripUidRegex, '') - if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) { + if (!inNamespace || originalTypeEvent.includes(handlerKey)) { const event = storeElementEvent[keyHandlers] removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector) @@ -273,7 +273,7 @@ const EventHandler = { const $ = getjQuery() const typeEvent = event.replace(stripNameRegex, '') const inNamespace = event !== typeEvent - const isNative = nativeEvents.indexOf(typeEvent) > -1 + const isNative = nativeEvents.includes(typeEvent) let jQueryEvent let bubbles = true diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2a55992cb..e4616f1f1 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -679,7 +679,7 @@ class Tooltip { const dataAttributes = Manipulator.getDataAttributes(this.element) Object.keys(dataAttributes).forEach(dataAttr => { - if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { + if (DISALLOWED_ATTRIBUTES.includes(dataAttr)) { delete dataAttributes[dataAttr] } }) diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index d3747bba9..27c8dcfb6 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -35,8 +35,8 @@ const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|vid const allowedAttribute = (attr, allowedAttributeList) => { const attrName = attr.nodeName.toLowerCase() - if (allowedAttributeList.indexOf(attrName) !== -1) { - if (uriAttrs.indexOf(attrName) !== -1) { + if (allowedAttributeList.includes(attrName)) { + if (uriAttrs.includes(attrName)) { return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) } @@ -107,7 +107,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { const el = elements[i] const elName = el.nodeName.toLowerCase() - if (allowlistKeys.indexOf(elName) === -1) { + if (!allowlistKeys.includes(elName)) { el.parentNode.removeChild(el) continue |
