Commit f7ee5032 authored by Naoyuki Kanezawa's avatar Naoyuki Kanezawa Committed by Guillermo Rauch

use Promise to update head (#574)

parent 1fbf3248
......@@ -10,14 +10,14 @@ const DOMAttributeNames = {
export default class HeadManager {
constructor () {
this.requestId = null
this.updatePromise = null
}
updateHead (head) {
// perform batch update
window.cancelAnimationFrame(this.requestId)
this.requestId = window.requestAnimationFrame(() => {
this.requestId = null
const promise = this.updatePromise = Promise.resolve().then(() => {
if (promise !== this.updatePromise) return
this.updatePromise = null
this.doUpdateHead(head)
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment