"unicorn/prefer-dom-node-dataset": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-query-selector": "off",
- "unicorn/prefer-spread": "off",
"unicorn/prefer-string-replace-all": "off",
"unicorn/prevent-abbreviations": "off"
},
// can be removed later when multiple key/instances are fine to be used
if (!instanceMap.has(key) && instanceMap.size !== 0) {
// eslint-disable-next-line no-console
- console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`)
+ console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${[...instanceMap.keys()][0]}.`)
return
}
const SelectorEngine = {
find(selector, element = document.documentElement) {
- return [].concat(...Element.prototype.querySelectorAll.call(element, selector))
+ return [...Element.prototype.querySelectorAll.call(element, selector)]
},
findOne(selector, element = document.documentElement) {
},
children(element, selector) {
- return [].concat(...element.children).filter(child => child.matches(selector))
+ return [...element.children].filter(child => child.matches(selector))
},
parents(element, selector) {
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
- for (const element of [].concat(...document.body.children)) {
+ const children = [...document.body.children]
+ for (const element of children) {
EventHandler.on(element, 'mouseover', noop)
}
}
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
- for (const element of [].concat(...document.body.children)) {
+ const children = [...document.body.children]
+ for (const element of children) {
EventHandler.off(element, 'mouseover', noop)
}
}
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement) {
- for (const element of [].concat(...document.body.children)) {
+ const children = [...document.body.children]
+ for (const element of children) {
EventHandler.on(element, 'mouseover', noop)
}
}
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
- for (const element of [].concat(...document.body.children)) {
+ const children = [...document.body.children]
+ for (const element of children) {
EventHandler.off(element, 'mouseover', noop)
}
}
const domParser = new window.DOMParser()
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
- const elements = [].concat(...createdDocument.body.querySelectorAll('*'))
+ const elements = [...createdDocument.body.querySelectorAll('*')]
for (const element of elements) {
const elementName = element.nodeName.toLowerCase()
continue
}
- const attributeList = [].concat(...element.attributes)
- const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || [])
+ const attributeList = [...element.attributes]
+ const allowedAttributes = [...allowList['*'] || [], ...allowList[elementName] || []]
for (const attribute of attributeList) {
if (!allowedAttribute(attribute, allowedAttributes)) {
import '../../dist/carousel'
window.addEventListener('load', () => {
- [].concat(...document.querySelectorAll('[data-bs-toggle="tooltip"]'))
+ [...document.querySelectorAll('[data-bs-toggle="tooltip"]')]
.map(tooltipNode => new Tooltip(tooltipNode))
})
import { Tooltip } from '../../../dist/js/bootstrap.esm.js'
window.addEventListener('load', () => {
- [].concat(...document.querySelectorAll('[data-bs-toggle="tooltip"]'))
+ [...document.querySelectorAll('[data-bs-toggle="tooltip"]')]
.map(tooltipNode => new Tooltip(tooltipNode))
})
const collapseEl1 = fixtureEl.querySelector('#collapse1')
const collapseEl2 = fixtureEl.querySelector('#collapse2')
- const collapseList = [].concat(...fixtureEl.querySelectorAll('.collapse'))
+ const collapseList = [...fixtureEl.querySelectorAll('.collapse')]
.map(el => new Collapse(el, {
parent,
toggle: false
].join('')
const list = fixtureEl.querySelector('ul')
- const liList = [].concat(...fixtureEl.querySelectorAll('li'))
+ const liList = [...fixtureEl.querySelectorAll('li')]
const result = SelectorEngine.children(list, 'li')
expect(result).toEqual(liList)
const testEl = fixtureEl.querySelector('#test')
- expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
+ expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual([...fixtureEl.querySelectorAll('.target')])
})
it('should get elements if several ids are given', () => {
const testEl = fixtureEl.querySelector('#test')
- expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
+ expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual([...fixtureEl.querySelectorAll('.target')])
})
it('should get elements if several ids with special chars are given', () => {
const testEl = fixtureEl.querySelector('#test')
- expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
+ expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual([...fixtureEl.querySelectorAll('.target')])
})
it('should get elements in array, from href if no data-bs-target set', () => {
const testEl = fixtureEl.querySelector('#test')
- expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
+ expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual([...fixtureEl.querySelectorAll('.target')])
})
it('should return empty array if elements not found', () => {
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
- const forms = document.querySelectorAll('.needs-validation')
+ const forms = document.querySelectorAll('.needs-validation');
// Loop over them and prevent submission
- Array.from(forms).forEach(form => {
+ [...forms].forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
/* global bootstrap: false */
(() => {
'use strict'
- const tooltipTriggerList = Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
+ const tooltipTriggerList = [...document.querySelectorAll('[data-bs-toggle="tooltip"]')]
tooltipTriggerList.forEach(tooltipTriggerEl => {
new bootstrap.Tooltip(tooltipTriggerEl)
})
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
- const forms = document.querySelectorAll('.needs-validation')
+ const forms = document.querySelectorAll('.needs-validation');
// Loop over them and prevent submission
- Array.from(forms).forEach(form => {
+ [...forms].forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()