mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
Switch to String.includes()
This commit is contained in:
parent
470e99ed5f
commit
b9f7668cf6
5 changed files with 8 additions and 10 deletions
|
@ -51,7 +51,6 @@
|
||||||
"unicorn/no-useless-undefined": "off",
|
"unicorn/no-useless-undefined": "off",
|
||||||
"unicorn/prefer-array-find": "off",
|
"unicorn/prefer-array-find": "off",
|
||||||
"unicorn/prefer-dataset": "off",
|
"unicorn/prefer-dataset": "off",
|
||||||
"unicorn/prefer-includes": "off",
|
|
||||||
"unicorn/prefer-node-append": "off",
|
"unicorn/prefer-node-append": "off",
|
||||||
"unicorn/prefer-node-remove": "off",
|
"unicorn/prefer-node-remove": "off",
|
||||||
"unicorn/prefer-number-properties": "off",
|
"unicorn/prefer-number-properties": "off",
|
||||||
|
|
|
@ -151,7 +151,7 @@ function normalizeParams(originalTypeEvent, handler, delegationFn) {
|
||||||
typeEvent = custom
|
typeEvent = custom
|
||||||
}
|
}
|
||||||
|
|
||||||
const isNative = nativeEvents.indexOf(typeEvent) > -1
|
const isNative = nativeEvents.includes(typeEvent)
|
||||||
|
|
||||||
if (!isNative) {
|
if (!isNative) {
|
||||||
typeEvent = originalTypeEvent
|
typeEvent = originalTypeEvent
|
||||||
|
@ -210,7 +210,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) {
|
||||||
const storeElementEvent = events[typeEvent] || {}
|
const storeElementEvent = events[typeEvent] || {}
|
||||||
|
|
||||||
Object.keys(storeElementEvent).forEach(handlerKey => {
|
Object.keys(storeElementEvent).forEach(handlerKey => {
|
||||||
if (handlerKey.indexOf(namespace) > -1) {
|
if (handlerKey.includes(namespace)) {
|
||||||
const event = storeElementEvent[handlerKey]
|
const event = storeElementEvent[handlerKey]
|
||||||
|
|
||||||
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
|
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
|
||||||
|
@ -257,7 +257,7 @@ const EventHandler = {
|
||||||
Object.keys(storeElementEvent).forEach(keyHandlers => {
|
Object.keys(storeElementEvent).forEach(keyHandlers => {
|
||||||
const handlerKey = keyHandlers.replace(stripUidRegex, '')
|
const handlerKey = keyHandlers.replace(stripUidRegex, '')
|
||||||
|
|
||||||
if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
|
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
|
||||||
const event = storeElementEvent[keyHandlers]
|
const event = storeElementEvent[keyHandlers]
|
||||||
|
|
||||||
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
|
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
|
||||||
|
@ -273,7 +273,7 @@ const EventHandler = {
|
||||||
const $ = getjQuery()
|
const $ = getjQuery()
|
||||||
const typeEvent = event.replace(stripNameRegex, '')
|
const typeEvent = event.replace(stripNameRegex, '')
|
||||||
const inNamespace = event !== typeEvent
|
const inNamespace = event !== typeEvent
|
||||||
const isNative = nativeEvents.indexOf(typeEvent) > -1
|
const isNative = nativeEvents.includes(typeEvent)
|
||||||
|
|
||||||
let jQueryEvent
|
let jQueryEvent
|
||||||
let bubbles = true
|
let bubbles = true
|
||||||
|
|
|
@ -679,7 +679,7 @@ class Tooltip {
|
||||||
const dataAttributes = Manipulator.getDataAttributes(this.element)
|
const dataAttributes = Manipulator.getDataAttributes(this.element)
|
||||||
|
|
||||||
Object.keys(dataAttributes).forEach(dataAttr => {
|
Object.keys(dataAttributes).forEach(dataAttr => {
|
||||||
if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
|
if (DISALLOWED_ATTRIBUTES.includes(dataAttr)) {
|
||||||
delete dataAttributes[dataAttr]
|
delete dataAttributes[dataAttr]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -35,8 +35,8 @@ const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|vid
|
||||||
const allowedAttribute = (attr, allowedAttributeList) => {
|
const allowedAttribute = (attr, allowedAttributeList) => {
|
||||||
const attrName = attr.nodeName.toLowerCase()
|
const attrName = attr.nodeName.toLowerCase()
|
||||||
|
|
||||||
if (allowedAttributeList.indexOf(attrName) !== -1) {
|
if (allowedAttributeList.includes(attrName)) {
|
||||||
if (uriAttrs.indexOf(attrName) !== -1) {
|
if (uriAttrs.includes(attrName)) {
|
||||||
return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
|
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 el = elements[i]
|
||||||
const elName = el.nodeName.toLowerCase()
|
const elName = el.nodeName.toLowerCase()
|
||||||
|
|
||||||
if (allowlistKeys.indexOf(elName) === -1) {
|
if (!allowlistKeys.includes(elName)) {
|
||||||
el.parentNode.removeChild(el)
|
el.parentNode.removeChild(el)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
"unicorn/no-for-loop": "off",
|
"unicorn/no-for-loop": "off",
|
||||||
"unicorn/no-null": "off",
|
"unicorn/no-null": "off",
|
||||||
"unicorn/prefer-dataset": "off",
|
"unicorn/prefer-dataset": "off",
|
||||||
"unicorn/prefer-includes": "off",
|
|
||||||
"unicorn/prefer-node-append": "off",
|
"unicorn/prefer-node-append": "off",
|
||||||
"unicorn/prefer-query-selector": "off",
|
"unicorn/prefer-query-selector": "off",
|
||||||
"unicorn/prevent-abbreviations": "off"
|
"unicorn/prevent-abbreviations": "off"
|
||||||
|
|
Loading…
Add table
Reference in a new issue