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 = { ...@@ -10,14 +10,14 @@ const DOMAttributeNames = {
export default class HeadManager { export default class HeadManager {
constructor () { constructor () {
this.requestId = null this.updatePromise = null
} }
updateHead (head) { updateHead (head) {
// perform batch update const promise = this.updatePromise = Promise.resolve().then(() => {
window.cancelAnimationFrame(this.requestId) if (promise !== this.updatePromise) return
this.requestId = window.requestAnimationFrame(() => {
this.requestId = null this.updatePromise = null
this.doUpdateHead(head) 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