mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
Fix Util.reflow
function and add documentation (#34543)
* add documentation to reflow function * refactor to void as it should be Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
parent
365b9e5af0
commit
5541179b38
@ -188,7 +188,18 @@ const findShadowRoot = element => {
|
||||
|
||||
const noop = () => {}
|
||||
|
||||
const reflow = element => element.offsetHeight
|
||||
/**
|
||||
* Trick to restart an element's animation
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @return void
|
||||
*
|
||||
* @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
|
||||
*/
|
||||
const reflow = element => {
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
element.offsetHeight
|
||||
}
|
||||
|
||||
const getjQuery = () => {
|
||||
const { jQuery } = window
|
||||
|
@ -543,8 +543,9 @@ describe('Util', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Util.reflow(div)).toEqual(0)
|
||||
const spy = spyOnProperty(div, 'offsetHeight')
|
||||
Util.reflow(div)
|
||||
expect(spy).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user