diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-05-02 16:43:13 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2020-11-14 16:54:50 +0300 |
commit | b9f7668cf65ab166660d5695affb72d2553f59a9 (patch) | |
tree | 3475949a50e33ebe7f751141ca10dad94f644f59 | |
parent | 470e99ed5f53f8a94df9e501fcc30423151be324 (diff) |
Switch to `String.includes()`
-rw-r--r-- | .eslintrc.json | 1 | ||||
-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 | ||||
-rw-r--r-- | site/.eslintrc.json | 1 |
5 files changed, 8 insertions, 10 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index 4c49fd0b1d..98e24c656a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -51,7 +51,6 @@ "unicorn/no-useless-undefined": "off", "unicorn/prefer-array-find": "off", "unicorn/prefer-dataset": "off", - "unicorn/prefer-includes": "off", "unicorn/prefer-node-append": "off", "unicorn/prefer-node-remove": "off", "unicorn/prefer-number-properties": "off", diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index bf9aa38dff..64a061ae69 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 2a55992cba..e4616f1f19 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 d3747bba9d..27c8dcfb6a 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 diff --git a/site/.eslintrc.json b/site/.eslintrc.json index f7b6b4a7f3..ec51527c14 100644 --- a/site/.eslintrc.json +++ b/site/.eslintrc.json @@ -36,7 +36,6 @@ "unicorn/no-for-loop": "off", "unicorn/no-null": "off", "unicorn/prefer-dataset": "off", - "unicorn/prefer-includes": "off", "unicorn/prefer-node-append": "off", "unicorn/prefer-query-selector": "off", "unicorn/prevent-abbreviations": "off" |