mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
41 lines
920 B
JavaScript
41 lines
920 B
JavaScript
const fixtureId = 'fixture'
|
|
|
|
export const getFixture = () => {
|
|
let fixtureEl = document.getElementById(fixtureId)
|
|
|
|
if (!fixtureEl) {
|
|
fixtureEl = document.createElement('div')
|
|
fixtureEl.setAttribute('id', fixtureId)
|
|
fixtureEl.style.position = 'absolute'
|
|
fixtureEl.style.top = '-10000px'
|
|
fixtureEl.style.left = '-10000px'
|
|
fixtureEl.style.width = '10000px'
|
|
fixtureEl.style.height = '10000px'
|
|
document.body.appendChild(fixtureEl)
|
|
}
|
|
|
|
return fixtureEl
|
|
}
|
|
|
|
export const clearFixture = () => {
|
|
const fixtureEl = getFixture()
|
|
|
|
fixtureEl.innerHTML = ''
|
|
}
|
|
|
|
export const createEvent = (eventName, params = {}) => {
|
|
const e = document.createEvent('Event')
|
|
|
|
e.initEvent(eventName, Boolean(params.bubbles), Boolean(params.cancelable))
|
|
return e
|
|
}
|
|
|
|
export const jQueryMock = {
|
|
elements: undefined,
|
|
fn: {},
|
|
each(fn) {
|
|
this.elements.forEach(el => {
|
|
fn.call(el)
|
|
})
|
|
}
|
|
}
|