mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-28 22:39:11 +02:00
fix: remove make array util function (#30430)
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
getElementFromSelector,
|
||||
getTransitionDurationFromElement,
|
||||
isVisible,
|
||||
makeArray,
|
||||
reflow,
|
||||
triggerTransitionEnd,
|
||||
typeCheckConfig
|
||||
@@ -322,7 +321,7 @@ class Carousel {
|
||||
}
|
||||
}
|
||||
|
||||
makeArray(SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)).forEach(itemImg => {
|
||||
SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
|
||||
EventHandler.on(itemImg, EVENT_DRAG_START, e => e.preventDefault())
|
||||
})
|
||||
|
||||
@@ -358,7 +357,7 @@ class Carousel {
|
||||
|
||||
_getItemIndex(element) {
|
||||
this._items = element && element.parentNode ?
|
||||
makeArray(SelectorEngine.find(SELECTOR_ITEM, element.parentNode)) :
|
||||
SelectorEngine.find(SELECTOR_ITEM, element.parentNode) :
|
||||
[]
|
||||
|
||||
return this._items.indexOf(element)
|
||||
@@ -601,7 +600,8 @@ EventHandler
|
||||
.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
|
||||
|
||||
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
||||
const carousels = makeArray(SelectorEngine.find(SELECTOR_DATA_RIDE))
|
||||
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
|
||||
|
||||
for (let i = 0, len = carousels.length; i < len; i++) {
|
||||
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY))
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ import {
|
||||
getElementFromSelector,
|
||||
getTransitionDurationFromElement,
|
||||
isElement,
|
||||
makeArray,
|
||||
reflow,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
@@ -72,16 +71,17 @@ class Collapse {
|
||||
this._isTransitioning = false
|
||||
this._element = element
|
||||
this._config = this._getConfig(config)
|
||||
this._triggerArray = makeArray(SelectorEngine.find(
|
||||
this._triggerArray = SelectorEngine.find(
|
||||
`${SELECTOR_DATA_TOGGLE}[href="#${element.id}"],` +
|
||||
`${SELECTOR_DATA_TOGGLE}[data-target="#${element.id}"]`
|
||||
))
|
||||
)
|
||||
|
||||
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
|
||||
|
||||
const toggleList = makeArray(SelectorEngine.find(SELECTOR_DATA_TOGGLE))
|
||||
for (let i = 0, len = toggleList.length; i < len; i++) {
|
||||
const elem = toggleList[i]
|
||||
const selector = getSelectorFromElement(elem)
|
||||
const filterElement = makeArray(SelectorEngine.find(selector))
|
||||
const filterElement = SelectorEngine.find(selector)
|
||||
.filter(foundElem => foundElem === element)
|
||||
|
||||
if (selector !== null && filterElement.length) {
|
||||
@@ -133,7 +133,7 @@ class Collapse {
|
||||
let activesData
|
||||
|
||||
if (this._parent) {
|
||||
actives = makeArray(SelectorEngine.find(SELECTOR_ACTIVES, this._parent))
|
||||
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent)
|
||||
.filter(elem => {
|
||||
if (typeof this._config.parent === 'string') {
|
||||
return elem.getAttribute('data-parent') === this._config.parent
|
||||
@@ -307,7 +307,7 @@ class Collapse {
|
||||
|
||||
const selector = `${SELECTOR_DATA_TOGGLE}[data-parent="${parent}"]`
|
||||
|
||||
makeArray(SelectorEngine.find(selector, parent))
|
||||
SelectorEngine.find(selector, parent)
|
||||
.forEach(element => {
|
||||
const selected = getElementFromSelector(element)
|
||||
|
||||
@@ -390,7 +390,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
|
||||
|
||||
const triggerData = Manipulator.getDataAttributes(this)
|
||||
const selector = getSelectorFromElement(this)
|
||||
const selectorElements = makeArray(SelectorEngine.find(selector))
|
||||
const selectorElements = SelectorEngine.find(selector)
|
||||
|
||||
selectorElements.forEach(element => {
|
||||
const data = Data.getData(element, DATA_KEY)
|
||||
|
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
import { find as findFn, findOne } from './polyfill'
|
||||
import { makeArray } from '../util/index'
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
@@ -22,7 +21,7 @@ const SelectorEngine = {
|
||||
},
|
||||
|
||||
find(selector, element = document.documentElement) {
|
||||
return findFn.call(element, selector)
|
||||
return [].concat(...findFn.call(element, selector))
|
||||
},
|
||||
|
||||
findOne(selector, element = document.documentElement) {
|
||||
@@ -30,9 +29,9 @@ const SelectorEngine = {
|
||||
},
|
||||
|
||||
children(element, selector) {
|
||||
const children = makeArray(element.children)
|
||||
const children = [].concat(...element.children)
|
||||
|
||||
return children.filter(child => this.matches(child, selector))
|
||||
return children.filter(child => child.matches(selector))
|
||||
},
|
||||
|
||||
parents(element, selector) {
|
||||
@@ -59,7 +58,7 @@ const SelectorEngine = {
|
||||
let previous = element.previousElementSibling
|
||||
|
||||
while (previous) {
|
||||
if (this.matches(previous, selector)) {
|
||||
if (previous.matches(selector)) {
|
||||
return [previous]
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@ import {
|
||||
getElementFromSelector,
|
||||
isElement,
|
||||
isVisible,
|
||||
makeArray,
|
||||
noop,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
@@ -190,8 +189,8 @@ class Dropdown {
|
||||
// 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 &&
|
||||
!makeArray(SelectorEngine.closest(parent, SELECTOR_NAVBAR_NAV)).length) {
|
||||
makeArray(document.body.children)
|
||||
!SelectorEngine.closest(parent, SELECTOR_NAVBAR_NAV)) {
|
||||
[].concat(...document.body.children)
|
||||
.forEach(elem => EventHandler.on(elem, 'mouseover', null, noop()))
|
||||
}
|
||||
|
||||
@@ -378,7 +377,8 @@ class Dropdown {
|
||||
return
|
||||
}
|
||||
|
||||
const toggles = makeArray(SelectorEngine.find(SELECTOR_DATA_TOGGLE))
|
||||
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
|
||||
|
||||
for (let i = 0, len = toggles.length; i < len; i++) {
|
||||
const parent = Dropdown.getParentFromElement(toggles[i])
|
||||
const context = Data.getData(toggles[i], DATA_KEY)
|
||||
@@ -414,7 +414,7 @@ class Dropdown {
|
||||
// If this is a touch-enabled device we remove the extra
|
||||
// empty mouseover listeners we added for iOS support
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
makeArray(document.body.children)
|
||||
[].concat(...document.body.children)
|
||||
.forEach(elem => EventHandler.off(elem, 'mouseover', null, noop()))
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ class Dropdown {
|
||||
return
|
||||
}
|
||||
|
||||
const items = makeArray(SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent))
|
||||
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent)
|
||||
.filter(isVisible)
|
||||
|
||||
if (!items.length) {
|
||||
|
@@ -12,7 +12,6 @@ import {
|
||||
getElementFromSelector,
|
||||
getTransitionDurationFromElement,
|
||||
isVisible,
|
||||
makeArray,
|
||||
reflow,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
@@ -456,7 +455,7 @@ class Modal {
|
||||
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
|
||||
|
||||
// Adjust fixed content padding
|
||||
makeArray(SelectorEngine.find(SELECTOR_FIXED_CONTENT))
|
||||
SelectorEngine.find(SELECTOR_FIXED_CONTENT)
|
||||
.forEach(element => {
|
||||
const actualPadding = element.style.paddingRight
|
||||
const calculatedPadding = window.getComputedStyle(element)['padding-right']
|
||||
@@ -465,7 +464,7 @@ class Modal {
|
||||
})
|
||||
|
||||
// Adjust sticky content margin
|
||||
makeArray(SelectorEngine.find(SELECTOR_STICKY_CONTENT))
|
||||
SelectorEngine.find(SELECTOR_STICKY_CONTENT)
|
||||
.forEach(element => {
|
||||
const actualMargin = element.style.marginRight
|
||||
const calculatedMargin = window.getComputedStyle(element)['margin-right']
|
||||
@@ -486,7 +485,7 @@ class Modal {
|
||||
|
||||
_resetScrollbar() {
|
||||
// Restore fixed content padding
|
||||
makeArray(SelectorEngine.find(SELECTOR_FIXED_CONTENT))
|
||||
SelectorEngine.find(SELECTOR_FIXED_CONTENT)
|
||||
.forEach(element => {
|
||||
const padding = Manipulator.getDataAttribute(element, 'padding-right')
|
||||
if (typeof padding !== 'undefined') {
|
||||
@@ -496,7 +495,7 @@ class Modal {
|
||||
})
|
||||
|
||||
// Restore sticky content and navbar-toggler margin
|
||||
makeArray(SelectorEngine.find(`${SELECTOR_STICKY_CONTENT}`))
|
||||
SelectorEngine.find(`${SELECTOR_STICKY_CONTENT}`)
|
||||
.forEach(element => {
|
||||
const margin = Manipulator.getDataAttribute(element, 'margin-right')
|
||||
if (typeof margin !== 'undefined') {
|
||||
|
@@ -9,7 +9,6 @@ import {
|
||||
getjQuery,
|
||||
getSelectorFromElement,
|
||||
getUID,
|
||||
makeArray,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
import Data from './dom/data'
|
||||
@@ -116,7 +115,7 @@ class ScrollSpy {
|
||||
|
||||
this._scrollHeight = this._getScrollHeight()
|
||||
|
||||
const targets = makeArray(SelectorEngine.find(this._selector))
|
||||
const targets = SelectorEngine.find(this._selector)
|
||||
|
||||
targets
|
||||
.map(element => {
|
||||
@@ -286,7 +285,7 @@ class ScrollSpy {
|
||||
}
|
||||
|
||||
_clear() {
|
||||
makeArray(SelectorEngine.find(this._selector))
|
||||
SelectorEngine.find(this._selector)
|
||||
.filter(node => node.classList.contains(CLASS_NAME_ACTIVE))
|
||||
.forEach(node => node.classList.remove(CLASS_NAME_ACTIVE))
|
||||
}
|
||||
@@ -324,7 +323,7 @@ class ScrollSpy {
|
||||
*/
|
||||
|
||||
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
||||
makeArray(SelectorEngine.find(SELECTOR_DATA_SPY))
|
||||
SelectorEngine.find(SELECTOR_DATA_SPY)
|
||||
.forEach(spy => new ScrollSpy(spy, Manipulator.getDataAttributes(spy)))
|
||||
})
|
||||
|
||||
|
@@ -11,7 +11,6 @@ import {
|
||||
emulateTransitionEnd,
|
||||
getElementFromSelector,
|
||||
getTransitionDurationFromElement,
|
||||
makeArray,
|
||||
reflow
|
||||
} from './util/index'
|
||||
import Data from './dom/data'
|
||||
@@ -85,7 +84,7 @@ class Tab {
|
||||
|
||||
if (listElement) {
|
||||
const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE
|
||||
previous = makeArray(SelectorEngine.find(itemSelector, listElement))
|
||||
previous = SelectorEngine.find(itemSelector, listElement)
|
||||
previous = previous[previous.length - 1]
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ class Tab {
|
||||
const dropdownElement = SelectorEngine.closest(element, SELECTOR_DROPDOWN)
|
||||
|
||||
if (dropdownElement) {
|
||||
makeArray(SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE))
|
||||
SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE)
|
||||
.forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE))
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,6 @@ import {
|
||||
getTransitionDurationFromElement,
|
||||
getUID,
|
||||
isElement,
|
||||
makeArray,
|
||||
noop,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
@@ -301,7 +300,7 @@ class Tooltip {
|
||||
// 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) {
|
||||
makeArray(document.body.children).forEach(element => {
|
||||
[].concat(...document.body.children).forEach(element => {
|
||||
EventHandler.on(element, 'mouseover', noop())
|
||||
})
|
||||
}
|
||||
@@ -354,7 +353,7 @@ class Tooltip {
|
||||
// If this is a touch-enabled device we remove the extra
|
||||
// empty mouseover listeners we added for iOS support
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
makeArray(document.body.children)
|
||||
[].concat(...document.body.children)
|
||||
.forEach(element => EventHandler.off(element, 'mouseover', noop))
|
||||
}
|
||||
|
||||
|
@@ -127,14 +127,6 @@ const typeCheckConfig = (componentName, config, configTypes) => {
|
||||
})
|
||||
}
|
||||
|
||||
const makeArray = nodeList => {
|
||||
if (!nodeList) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [].slice.call(nodeList)
|
||||
}
|
||||
|
||||
const isVisible = element => {
|
||||
if (!element) {
|
||||
return false
|
||||
@@ -200,7 +192,6 @@ export {
|
||||
isElement,
|
||||
emulateTransitionEnd,
|
||||
typeCheckConfig,
|
||||
makeArray,
|
||||
isVisible,
|
||||
findShadowRoot,
|
||||
noop,
|
||||
|
@@ -5,8 +5,6 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import { makeArray } from './index'
|
||||
|
||||
const uriAttrs = [
|
||||
'background',
|
||||
'cite',
|
||||
@@ -103,7 +101,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
|
||||
const domParser = new window.DOMParser()
|
||||
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
|
||||
const whitelistKeys = Object.keys(whiteList)
|
||||
const elements = makeArray(createdDocument.body.querySelectorAll('*'))
|
||||
const elements = [].concat(...createdDocument.body.querySelectorAll('*'))
|
||||
|
||||
for (let i = 0, len = elements.length; i < len; i++) {
|
||||
const el = elements[i]
|
||||
@@ -115,7 +113,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
|
||||
continue
|
||||
}
|
||||
|
||||
const attributeList = makeArray(el.attributes)
|
||||
const attributeList = [].concat(...el.attributes)
|
||||
const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])
|
||||
|
||||
attributeList.forEach(attr => {
|
||||
|
Reference in New Issue
Block a user