mirror of https://github.com/twbs/bootstrap.git
fix: remove make array util function (#30430)
This commit is contained in:
parent
98c4598696
commit
26d86fce2a
|
@ -12,7 +12,6 @@ import {
|
||||||
getElementFromSelector,
|
getElementFromSelector,
|
||||||
getTransitionDurationFromElement,
|
getTransitionDurationFromElement,
|
||||||
isVisible,
|
isVisible,
|
||||||
makeArray,
|
|
||||||
reflow,
|
reflow,
|
||||||
triggerTransitionEnd,
|
triggerTransitionEnd,
|
||||||
typeCheckConfig
|
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())
|
EventHandler.on(itemImg, EVENT_DRAG_START, e => e.preventDefault())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -358,7 +357,7 @@ class Carousel {
|
||||||
|
|
||||||
_getItemIndex(element) {
|
_getItemIndex(element) {
|
||||||
this._items = element && element.parentNode ?
|
this._items = element && element.parentNode ?
|
||||||
makeArray(SelectorEngine.find(SELECTOR_ITEM, element.parentNode)) :
|
SelectorEngine.find(SELECTOR_ITEM, element.parentNode) :
|
||||||
[]
|
[]
|
||||||
|
|
||||||
return this._items.indexOf(element)
|
return this._items.indexOf(element)
|
||||||
|
@ -601,7 +600,8 @@ EventHandler
|
||||||
.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
|
.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
|
||||||
|
|
||||||
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
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++) {
|
for (let i = 0, len = carousels.length; i < len; i++) {
|
||||||
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY))
|
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY))
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
getElementFromSelector,
|
getElementFromSelector,
|
||||||
getTransitionDurationFromElement,
|
getTransitionDurationFromElement,
|
||||||
isElement,
|
isElement,
|
||||||
makeArray,
|
|
||||||
reflow,
|
reflow,
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
|
@ -72,16 +71,17 @@ class Collapse {
|
||||||
this._isTransitioning = false
|
this._isTransitioning = false
|
||||||
this._element = element
|
this._element = element
|
||||||
this._config = this._getConfig(config)
|
this._config = this._getConfig(config)
|
||||||
this._triggerArray = makeArray(SelectorEngine.find(
|
this._triggerArray = SelectorEngine.find(
|
||||||
`${SELECTOR_DATA_TOGGLE}[href="#${element.id}"],` +
|
`${SELECTOR_DATA_TOGGLE}[href="#${element.id}"],` +
|
||||||
`${SELECTOR_DATA_TOGGLE}[data-target="#${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++) {
|
for (let i = 0, len = toggleList.length; i < len; i++) {
|
||||||
const elem = toggleList[i]
|
const elem = toggleList[i]
|
||||||
const selector = getSelectorFromElement(elem)
|
const selector = getSelectorFromElement(elem)
|
||||||
const filterElement = makeArray(SelectorEngine.find(selector))
|
const filterElement = SelectorEngine.find(selector)
|
||||||
.filter(foundElem => foundElem === element)
|
.filter(foundElem => foundElem === element)
|
||||||
|
|
||||||
if (selector !== null && filterElement.length) {
|
if (selector !== null && filterElement.length) {
|
||||||
|
@ -133,7 +133,7 @@ class Collapse {
|
||||||
let activesData
|
let activesData
|
||||||
|
|
||||||
if (this._parent) {
|
if (this._parent) {
|
||||||
actives = makeArray(SelectorEngine.find(SELECTOR_ACTIVES, this._parent))
|
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent)
|
||||||
.filter(elem => {
|
.filter(elem => {
|
||||||
if (typeof this._config.parent === 'string') {
|
if (typeof this._config.parent === 'string') {
|
||||||
return elem.getAttribute('data-parent') === this._config.parent
|
return elem.getAttribute('data-parent') === this._config.parent
|
||||||
|
@ -307,7 +307,7 @@ class Collapse {
|
||||||
|
|
||||||
const selector = `${SELECTOR_DATA_TOGGLE}[data-parent="${parent}"]`
|
const selector = `${SELECTOR_DATA_TOGGLE}[data-parent="${parent}"]`
|
||||||
|
|
||||||
makeArray(SelectorEngine.find(selector, parent))
|
SelectorEngine.find(selector, parent)
|
||||||
.forEach(element => {
|
.forEach(element => {
|
||||||
const selected = getElementFromSelector(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 triggerData = Manipulator.getDataAttributes(this)
|
||||||
const selector = getSelectorFromElement(this)
|
const selector = getSelectorFromElement(this)
|
||||||
const selectorElements = makeArray(SelectorEngine.find(selector))
|
const selectorElements = SelectorEngine.find(selector)
|
||||||
|
|
||||||
selectorElements.forEach(element => {
|
selectorElements.forEach(element => {
|
||||||
const data = Data.getData(element, DATA_KEY)
|
const data = Data.getData(element, DATA_KEY)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { find as findFn, findOne } from './polyfill'
|
import { find as findFn, findOne } from './polyfill'
|
||||||
import { makeArray } from '../util/index'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ------------------------------------------------------------------------
|
* ------------------------------------------------------------------------
|
||||||
|
@ -22,7 +21,7 @@ const SelectorEngine = {
|
||||||
},
|
},
|
||||||
|
|
||||||
find(selector, element = document.documentElement) {
|
find(selector, element = document.documentElement) {
|
||||||
return findFn.call(element, selector)
|
return [].concat(...findFn.call(element, selector))
|
||||||
},
|
},
|
||||||
|
|
||||||
findOne(selector, element = document.documentElement) {
|
findOne(selector, element = document.documentElement) {
|
||||||
|
@ -30,9 +29,9 @@ const SelectorEngine = {
|
||||||
},
|
},
|
||||||
|
|
||||||
children(element, selector) {
|
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) {
|
parents(element, selector) {
|
||||||
|
@ -59,7 +58,7 @@ const SelectorEngine = {
|
||||||
let previous = element.previousElementSibling
|
let previous = element.previousElementSibling
|
||||||
|
|
||||||
while (previous) {
|
while (previous) {
|
||||||
if (this.matches(previous, selector)) {
|
if (previous.matches(selector)) {
|
||||||
return [previous]
|
return [previous]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
getElementFromSelector,
|
getElementFromSelector,
|
||||||
isElement,
|
isElement,
|
||||||
isVisible,
|
isVisible,
|
||||||
makeArray,
|
|
||||||
noop,
|
noop,
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
|
@ -190,8 +189,8 @@ class Dropdown {
|
||||||
// only needed because of broken event delegation on iOS
|
// only needed because of broken event delegation on iOS
|
||||||
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
||||||
if ('ontouchstart' in document.documentElement &&
|
if ('ontouchstart' in document.documentElement &&
|
||||||
!makeArray(SelectorEngine.closest(parent, SELECTOR_NAVBAR_NAV)).length) {
|
!SelectorEngine.closest(parent, SELECTOR_NAVBAR_NAV)) {
|
||||||
makeArray(document.body.children)
|
[].concat(...document.body.children)
|
||||||
.forEach(elem => EventHandler.on(elem, 'mouseover', null, noop()))
|
.forEach(elem => EventHandler.on(elem, 'mouseover', null, noop()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +377,8 @@ class Dropdown {
|
||||||
return
|
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++) {
|
for (let i = 0, len = toggles.length; i < len; i++) {
|
||||||
const parent = Dropdown.getParentFromElement(toggles[i])
|
const parent = Dropdown.getParentFromElement(toggles[i])
|
||||||
const context = Data.getData(toggles[i], DATA_KEY)
|
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
|
// If this is a touch-enabled device we remove the extra
|
||||||
// empty mouseover listeners we added for iOS support
|
// empty mouseover listeners we added for iOS support
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
makeArray(document.body.children)
|
[].concat(...document.body.children)
|
||||||
.forEach(elem => EventHandler.off(elem, 'mouseover', null, noop()))
|
.forEach(elem => EventHandler.off(elem, 'mouseover', null, noop()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ class Dropdown {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = makeArray(SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent))
|
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent)
|
||||||
.filter(isVisible)
|
.filter(isVisible)
|
||||||
|
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import {
|
||||||
getElementFromSelector,
|
getElementFromSelector,
|
||||||
getTransitionDurationFromElement,
|
getTransitionDurationFromElement,
|
||||||
isVisible,
|
isVisible,
|
||||||
makeArray,
|
|
||||||
reflow,
|
reflow,
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
|
@ -456,7 +455,7 @@ class Modal {
|
||||||
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
|
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
|
||||||
|
|
||||||
// Adjust fixed content padding
|
// Adjust fixed content padding
|
||||||
makeArray(SelectorEngine.find(SELECTOR_FIXED_CONTENT))
|
SelectorEngine.find(SELECTOR_FIXED_CONTENT)
|
||||||
.forEach(element => {
|
.forEach(element => {
|
||||||
const actualPadding = element.style.paddingRight
|
const actualPadding = element.style.paddingRight
|
||||||
const calculatedPadding = window.getComputedStyle(element)['padding-right']
|
const calculatedPadding = window.getComputedStyle(element)['padding-right']
|
||||||
|
@ -465,7 +464,7 @@ class Modal {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Adjust sticky content margin
|
// Adjust sticky content margin
|
||||||
makeArray(SelectorEngine.find(SELECTOR_STICKY_CONTENT))
|
SelectorEngine.find(SELECTOR_STICKY_CONTENT)
|
||||||
.forEach(element => {
|
.forEach(element => {
|
||||||
const actualMargin = element.style.marginRight
|
const actualMargin = element.style.marginRight
|
||||||
const calculatedMargin = window.getComputedStyle(element)['margin-right']
|
const calculatedMargin = window.getComputedStyle(element)['margin-right']
|
||||||
|
@ -486,7 +485,7 @@ class Modal {
|
||||||
|
|
||||||
_resetScrollbar() {
|
_resetScrollbar() {
|
||||||
// Restore fixed content padding
|
// Restore fixed content padding
|
||||||
makeArray(SelectorEngine.find(SELECTOR_FIXED_CONTENT))
|
SelectorEngine.find(SELECTOR_FIXED_CONTENT)
|
||||||
.forEach(element => {
|
.forEach(element => {
|
||||||
const padding = Manipulator.getDataAttribute(element, 'padding-right')
|
const padding = Manipulator.getDataAttribute(element, 'padding-right')
|
||||||
if (typeof padding !== 'undefined') {
|
if (typeof padding !== 'undefined') {
|
||||||
|
@ -496,7 +495,7 @@ class Modal {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Restore sticky content and navbar-toggler margin
|
// Restore sticky content and navbar-toggler margin
|
||||||
makeArray(SelectorEngine.find(`${SELECTOR_STICKY_CONTENT}`))
|
SelectorEngine.find(`${SELECTOR_STICKY_CONTENT}`)
|
||||||
.forEach(element => {
|
.forEach(element => {
|
||||||
const margin = Manipulator.getDataAttribute(element, 'margin-right')
|
const margin = Manipulator.getDataAttribute(element, 'margin-right')
|
||||||
if (typeof margin !== 'undefined') {
|
if (typeof margin !== 'undefined') {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
getjQuery,
|
getjQuery,
|
||||||
getSelectorFromElement,
|
getSelectorFromElement,
|
||||||
getUID,
|
getUID,
|
||||||
makeArray,
|
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
import Data from './dom/data'
|
import Data from './dom/data'
|
||||||
|
@ -116,7 +115,7 @@ class ScrollSpy {
|
||||||
|
|
||||||
this._scrollHeight = this._getScrollHeight()
|
this._scrollHeight = this._getScrollHeight()
|
||||||
|
|
||||||
const targets = makeArray(SelectorEngine.find(this._selector))
|
const targets = SelectorEngine.find(this._selector)
|
||||||
|
|
||||||
targets
|
targets
|
||||||
.map(element => {
|
.map(element => {
|
||||||
|
@ -286,7 +285,7 @@ class ScrollSpy {
|
||||||
}
|
}
|
||||||
|
|
||||||
_clear() {
|
_clear() {
|
||||||
makeArray(SelectorEngine.find(this._selector))
|
SelectorEngine.find(this._selector)
|
||||||
.filter(node => node.classList.contains(CLASS_NAME_ACTIVE))
|
.filter(node => node.classList.contains(CLASS_NAME_ACTIVE))
|
||||||
.forEach(node => node.classList.remove(CLASS_NAME_ACTIVE))
|
.forEach(node => node.classList.remove(CLASS_NAME_ACTIVE))
|
||||||
}
|
}
|
||||||
|
@ -324,7 +323,7 @@ class ScrollSpy {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
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)))
|
.forEach(spy => new ScrollSpy(spy, Manipulator.getDataAttributes(spy)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
emulateTransitionEnd,
|
emulateTransitionEnd,
|
||||||
getElementFromSelector,
|
getElementFromSelector,
|
||||||
getTransitionDurationFromElement,
|
getTransitionDurationFromElement,
|
||||||
makeArray,
|
|
||||||
reflow
|
reflow
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
import Data from './dom/data'
|
import Data from './dom/data'
|
||||||
|
@ -85,7 +84,7 @@ class Tab {
|
||||||
|
|
||||||
if (listElement) {
|
if (listElement) {
|
||||||
const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE
|
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]
|
previous = previous[previous.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +189,7 @@ class Tab {
|
||||||
const dropdownElement = SelectorEngine.closest(element, SELECTOR_DROPDOWN)
|
const dropdownElement = SelectorEngine.closest(element, SELECTOR_DROPDOWN)
|
||||||
|
|
||||||
if (dropdownElement) {
|
if (dropdownElement) {
|
||||||
makeArray(SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE))
|
SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE)
|
||||||
.forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE))
|
.forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
getTransitionDurationFromElement,
|
getTransitionDurationFromElement,
|
||||||
getUID,
|
getUID,
|
||||||
isElement,
|
isElement,
|
||||||
makeArray,
|
|
||||||
noop,
|
noop,
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
|
@ -301,7 +300,7 @@ class Tooltip {
|
||||||
// only needed because of broken event delegation on iOS
|
// only needed because of broken event delegation on iOS
|
||||||
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
makeArray(document.body.children).forEach(element => {
|
[].concat(...document.body.children).forEach(element => {
|
||||||
EventHandler.on(element, 'mouseover', noop())
|
EventHandler.on(element, 'mouseover', noop())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -354,7 +353,7 @@ class Tooltip {
|
||||||
// If this is a touch-enabled device we remove the extra
|
// If this is a touch-enabled device we remove the extra
|
||||||
// empty mouseover listeners we added for iOS support
|
// empty mouseover listeners we added for iOS support
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
makeArray(document.body.children)
|
[].concat(...document.body.children)
|
||||||
.forEach(element => EventHandler.off(element, 'mouseover', noop))
|
.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 => {
|
const isVisible = element => {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return false
|
return false
|
||||||
|
@ -200,7 +192,6 @@ export {
|
||||||
isElement,
|
isElement,
|
||||||
emulateTransitionEnd,
|
emulateTransitionEnd,
|
||||||
typeCheckConfig,
|
typeCheckConfig,
|
||||||
makeArray,
|
|
||||||
isVisible,
|
isVisible,
|
||||||
findShadowRoot,
|
findShadowRoot,
|
||||||
noop,
|
noop,
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { makeArray } from './index'
|
|
||||||
|
|
||||||
const uriAttrs = [
|
const uriAttrs = [
|
||||||
'background',
|
'background',
|
||||||
'cite',
|
'cite',
|
||||||
|
@ -103,7 +101,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
|
||||||
const domParser = new window.DOMParser()
|
const domParser = new window.DOMParser()
|
||||||
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
|
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
|
||||||
const whitelistKeys = Object.keys(whiteList)
|
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++) {
|
for (let i = 0, len = elements.length; i < len; i++) {
|
||||||
const el = elements[i]
|
const el = elements[i]
|
||||||
|
@ -115,7 +113,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const attributeList = makeArray(el.attributes)
|
const attributeList = [].concat(...el.attributes)
|
||||||
const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])
|
const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])
|
||||||
|
|
||||||
attributeList.forEach(attr => {
|
attributeList.forEach(attr => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Alert from '../../src/alert'
|
import Alert from '../../src/alert'
|
||||||
import { makeArray, getTransitionDurationFromElement } from '../../src/util/index'
|
import { getTransitionDurationFromElement } from '../../src/util/index'
|
||||||
|
|
||||||
/** Test helpers */
|
/** Test helpers */
|
||||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||||
|
@ -30,7 +30,7 @@ describe('Alert', () => {
|
||||||
const button = document.querySelector('button')
|
const button = document.querySelector('button')
|
||||||
|
|
||||||
button.click()
|
button.click()
|
||||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should close an alert without instantiating it manually with the parent selector', () => {
|
it('should close an alert without instantiating it manually with the parent selector', () => {
|
||||||
|
@ -43,7 +43,7 @@ describe('Alert', () => {
|
||||||
const button = document.querySelector('button')
|
const button = document.querySelector('button')
|
||||||
|
|
||||||
button.click()
|
button.click()
|
||||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe('Alert', () => {
|
||||||
const alert = new Alert(alertEl)
|
const alert = new Alert(alertEl)
|
||||||
|
|
||||||
alertEl.addEventListener('closed.bs.alert', () => {
|
alertEl.addEventListener('closed.bs.alert', () => {
|
||||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||||
expect(spy).not.toHaveBeenCalled()
|
expect(spy).not.toHaveBeenCalled()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -75,7 +75,7 @@ describe('Alert', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
alertEl.addEventListener('closed.bs.alert', () => {
|
alertEl.addEventListener('closed.bs.alert', () => {
|
||||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Collapse from '../../src/collapse'
|
import Collapse from '../../src/collapse'
|
||||||
import EventHandler from '../../src/dom/event-handler'
|
import EventHandler from '../../src/dom/event-handler'
|
||||||
import { makeArray } from '../../src/util/index'
|
|
||||||
|
|
||||||
/** Test helpers */
|
/** Test helpers */
|
||||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||||
|
@ -139,7 +138,7 @@ describe('Collapse', () => {
|
||||||
const collapseEl1 = fixtureEl.querySelector('#collapse1')
|
const collapseEl1 = fixtureEl.querySelector('#collapse1')
|
||||||
const collapseEl2 = fixtureEl.querySelector('#collapse2')
|
const collapseEl2 = fixtureEl.querySelector('#collapse2')
|
||||||
|
|
||||||
const collapseList = makeArray(fixtureEl.querySelectorAll('.collapse'))
|
const collapseList = [].concat(...fixtureEl.querySelectorAll('.collapse'))
|
||||||
.map(el => new Collapse(el, {
|
.map(el => new Collapse(el, {
|
||||||
parent,
|
parent,
|
||||||
toggle: false
|
toggle: false
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import SelectorEngine from '../../../src/dom/selector-engine'
|
import SelectorEngine from '../../../src/dom/selector-engine'
|
||||||
import { makeArray } from '../../../src/util/index'
|
|
||||||
|
|
||||||
/** Test helpers */
|
/** Test helpers */
|
||||||
import { getFixture, clearFixture } from '../../helpers/fixture'
|
import { getFixture, clearFixture } from '../../helpers/fixture'
|
||||||
|
@ -29,7 +28,7 @@ describe('SelectorEngine', () => {
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
|
|
||||||
expect(makeArray(SelectorEngine.find('div', fixtureEl))).toEqual([div])
|
expect(SelectorEngine.find('div', fixtureEl)).toEqual([div])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should find elements globaly', () => {
|
it('should find elements globaly', () => {
|
||||||
|
@ -37,7 +36,7 @@ describe('SelectorEngine', () => {
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('#test')
|
const div = fixtureEl.querySelector('#test')
|
||||||
|
|
||||||
expect(makeArray(SelectorEngine.find('#test'))).toEqual([div])
|
expect(SelectorEngine.find('#test')).toEqual([div])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle :scope selectors', () => {
|
it('should handle :scope selectors', () => {
|
||||||
|
@ -52,7 +51,7 @@ describe('SelectorEngine', () => {
|
||||||
const listEl = fixtureEl.querySelector('ul')
|
const listEl = fixtureEl.querySelector('ul')
|
||||||
const aActive = fixtureEl.querySelector('.active')
|
const aActive = fixtureEl.querySelector('.active')
|
||||||
|
|
||||||
expect(makeArray(SelectorEngine.find(':scope > li > .active', listEl))).toEqual([aActive])
|
expect(SelectorEngine.find(':scope > li > .active', listEl)).toEqual([aActive])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -75,8 +74,8 @@ describe('SelectorEngine', () => {
|
||||||
</ul>`
|
</ul>`
|
||||||
|
|
||||||
const list = fixtureEl.querySelector('ul')
|
const list = fixtureEl.querySelector('ul')
|
||||||
const liList = makeArray(fixtureEl.querySelectorAll('li'))
|
const liList = [].concat(...fixtureEl.querySelectorAll('li'))
|
||||||
const result = makeArray(SelectorEngine.children(list, 'li'))
|
const result = SelectorEngine.children(list, 'li')
|
||||||
|
|
||||||
expect(result).toEqual(liList)
|
expect(result).toEqual(liList)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Modal from '../../src/modal'
|
import Modal from '../../src/modal'
|
||||||
import EventHandler from '../../src/dom/event-handler'
|
import EventHandler from '../../src/dom/event-handler'
|
||||||
import { makeArray } from '../../src/util/index'
|
|
||||||
|
|
||||||
/** Test helpers */
|
/** Test helpers */
|
||||||
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
||||||
|
@ -31,9 +30,9 @@ describe('Modal', () => {
|
||||||
document.body.classList.remove('modal-open')
|
document.body.classList.remove('modal-open')
|
||||||
document.body.removeAttribute('style')
|
document.body.removeAttribute('style')
|
||||||
document.body.removeAttribute('data-padding-right')
|
document.body.removeAttribute('data-padding-right')
|
||||||
const backdropList = makeArray(document.querySelectorAll('.modal-backdrop'))
|
|
||||||
|
|
||||||
backdropList.forEach(backdrop => {
|
document.querySelectorAll('.modal-backdrop')
|
||||||
|
.forEach(backdrop => {
|
||||||
document.body.removeChild(backdrop)
|
document.body.removeChild(backdrop)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import Popover from '../../src/popover'
|
import Popover from '../../src/popover'
|
||||||
import { makeArray } from '../../src/util/index'
|
|
||||||
|
|
||||||
/** Test helpers */
|
/** Test helpers */
|
||||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||||
|
@ -14,7 +13,7 @@ describe('Popover', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
clearFixture()
|
clearFixture()
|
||||||
|
|
||||||
const popoverList = makeArray(document.querySelectorAll('.popover'))
|
const popoverList = document.querySelectorAll('.popover')
|
||||||
|
|
||||||
popoverList.forEach(popoverEl => {
|
popoverList.forEach(popoverEl => {
|
||||||
document.body.removeChild(popoverEl)
|
document.body.removeChild(popoverEl)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Tooltip from '../../src/tooltip'
|
import Tooltip from '../../src/tooltip'
|
||||||
import EventHandler from '../../src/dom/event-handler'
|
import EventHandler from '../../src/dom/event-handler'
|
||||||
import { makeArray, noop } from '../../src/util/index'
|
import { noop } from '../../src/util/index'
|
||||||
|
|
||||||
/** Test helpers */
|
/** Test helpers */
|
||||||
import { getFixture, clearFixture, jQueryMock, createEvent } from '../helpers/fixture'
|
import { getFixture, clearFixture, jQueryMock, createEvent } from '../helpers/fixture'
|
||||||
|
@ -15,9 +15,7 @@ describe('Tooltip', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
clearFixture()
|
clearFixture()
|
||||||
|
|
||||||
const tooltipList = makeArray(document.querySelectorAll('.tooltip'))
|
document.querySelectorAll('.tooltip').forEach(tooltipEl => {
|
||||||
|
|
||||||
tooltipList.forEach(tooltipEl => {
|
|
||||||
document.body.removeChild(tooltipEl)
|
document.body.removeChild(tooltipEl)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -244,20 +244,6 @@ describe('Util', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('makeArray', () => {
|
|
||||||
it('should convert node list to array', () => {
|
|
||||||
const nodeList = document.querySelectorAll('div')
|
|
||||||
|
|
||||||
expect(Array.isArray(nodeList)).toEqual(false)
|
|
||||||
expect(Array.isArray(Util.makeArray(nodeList))).toEqual(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return an empty array if the nodeList is undefined', () => {
|
|
||||||
expect(Util.makeArray(null)).toEqual([])
|
|
||||||
expect(Util.makeArray(undefined)).toEqual([])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('isVisible', () => {
|
describe('isVisible', () => {
|
||||||
it('should return false if the element is not defined', () => {
|
it('should return false if the element is not defined', () => {
|
||||||
expect(Util.isVisible(null)).toEqual(false)
|
expect(Util.isVisible(null)).toEqual(false)
|
||||||
|
|
Loading…
Reference in New Issue