diff options
| author | XhmikosR <[email protected]> | 2020-05-02 16:56:23 +0300 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2020-11-14 15:54:50 +0200 |
| commit | 6d7bc54d222709275b0eb73bd6b974509332247a (patch) | |
| tree | 311222b691df1d7d6b237cd6fc74bae721911cd2 /js | |
| parent | 2e758f64cf7da4a8612992a027704d9f10686b20 (diff) | |
| download | bootstrap-6d7bc54d222709275b0eb73bd6b974509332247a.tar.xz bootstrap-6d7bc54d222709275b0eb73bd6b974509332247a.zip | |
Switch to `Set#has()`
Diffstat (limited to 'js')
| -rw-r--r-- | js/src/dom/event-handler.js | 8 | ||||
| -rw-r--r-- | js/src/tooltip.js | 4 | ||||
| -rw-r--r-- | js/src/util/sanitizer.js | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index 64a061ae6..439a3f188 100644 --- a/js/src/dom/event-handler.js +++ b/js/src/dom/event-handler.js @@ -22,7 +22,7 @@ const customEvents = { mouseenter: 'mouseover', mouseleave: 'mouseout' } -const nativeEvents = [ +const nativeEvents = new Set([ 'click', 'dblclick', 'mouseup', @@ -69,7 +69,7 @@ const nativeEvents = [ 'error', 'abort', 'scroll' -] +]) /** * ------------------------------------------------------------------------ @@ -151,7 +151,7 @@ function normalizeParams(originalTypeEvent, handler, delegationFn) { typeEvent = custom } - const isNative = nativeEvents.includes(typeEvent) + const isNative = nativeEvents.has(typeEvent) if (!isNative) { typeEvent = originalTypeEvent @@ -273,7 +273,7 @@ const EventHandler = { const $ = getjQuery() const typeEvent = event.replace(stripNameRegex, '') const inNamespace = event !== typeEvent - const isNative = nativeEvents.includes(typeEvent) + const isNative = nativeEvents.has(typeEvent) let jQueryEvent let bubbles = true diff --git a/js/src/tooltip.js b/js/src/tooltip.js index e4616f1f1..7b115a69b 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -39,7 +39,7 @@ const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const CLASS_PREFIX = 'bs-tooltip' const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') -const DISALLOWED_ATTRIBUTES = ['sanitize', 'allowList', 'sanitizeFn'] +const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']) const DefaultType = { animation: 'boolean', @@ -679,7 +679,7 @@ class Tooltip { const dataAttributes = Manipulator.getDataAttributes(this.element) Object.keys(dataAttributes).forEach(dataAttr => { - if (DISALLOWED_ATTRIBUTES.includes(dataAttr)) { + if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { delete dataAttributes[dataAttr] } }) diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index 27c8dcfb6..68469285a 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -5,7 +5,7 @@ * -------------------------------------------------------------------------- */ -const uriAttrs = [ +const uriAttrs = new Set([ 'background', 'cite', 'href', @@ -14,7 +14,7 @@ const uriAttrs = [ 'poster', 'src', 'xlink:href' -] +]) const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i @@ -36,7 +36,7 @@ const allowedAttribute = (attr, allowedAttributeList) => { const attrName = attr.nodeName.toLowerCase() if (allowedAttributeList.includes(attrName)) { - if (uriAttrs.includes(attrName)) { + if (uriAttrs.has(attrName)) { return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) } |
