mirror of
https://github.com/tabler/tabler.git
synced 2026-08-29 21:31:28 +04:00
34 lines
863 B
TypeScript
34 lines
863 B
TypeScript
const FIXTURE_ID = 'fixture'
|
|
|
|
export const getFixture = (): HTMLElement => {
|
|
let el = document.getElementById(FIXTURE_ID)
|
|
|
|
if (!el) {
|
|
el = document.createElement('div')
|
|
el.id = FIXTURE_ID
|
|
el.style.position = 'absolute'
|
|
el.style.top = '-10000px'
|
|
el.style.left = '-10000px'
|
|
el.style.width = '10000px'
|
|
el.style.height = '10000px'
|
|
document.body.append(el)
|
|
}
|
|
|
|
return el
|
|
}
|
|
|
|
export const clearFixture = (): void => {
|
|
getFixture().innerHTML = ''
|
|
}
|
|
|
|
export const createEvent = (eventName: string, parameters: EventInit = {}): Event => {
|
|
return new Event(eventName, parameters)
|
|
}
|
|
|
|
export const clearBodyAndDocument = (): void => {
|
|
for (const attribute of ['data-bs-padding-right', 'data-tblr-padding-right', 'style']) {
|
|
document.documentElement.removeAttribute(attribute)
|
|
document.body.removeAttribute(attribute)
|
|
}
|
|
}
|