mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 17:40:34 +03:00
Revert "refactor: batch updates using requestIdleCallback, use setTimeout as fallback"
This reverts commit 8c75ec1356.
This commit is contained in:
@@ -1,10 +1,4 @@
|
|||||||
import { rootConfigKey } from '../shared/constants'
|
import { rootConfigKey } from '../shared/constants'
|
||||||
import { hasGlobalWindow } from '../utils/window'
|
|
||||||
|
|
||||||
const scheduleRefresh = (hasGlobalWindow && window.requestIdleCallback) || function (cb, { timeout }) {
|
|
||||||
return setTimeout(cb, timeout)
|
|
||||||
}
|
|
||||||
const cancelRefresh = (hasGlobalWindow && window.cancelIdleCallback) || clearTimeout
|
|
||||||
|
|
||||||
// store an id to keep track of DOM updates
|
// store an id to keep track of DOM updates
|
||||||
let batchId = null
|
let batchId = null
|
||||||
@@ -38,10 +32,10 @@ export function batchUpdate (callback, timeout) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelRefresh(batchId)
|
clearTimeout(batchId)
|
||||||
batchId = scheduleRefresh(() => {
|
batchId = setTimeout(() => {
|
||||||
callback()
|
callback()
|
||||||
}, { timeout })
|
}, timeout)
|
||||||
|
|
||||||
return batchId
|
return batchId
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user