Add instance-map for element dollar-methods
This commit is contained in:
parent
8d9820cffe
commit
357af9342d
1 changed files with 3 additions and 1 deletions
|
@ -44,13 +44,15 @@ export default Class => {
|
|||
if (name.startsWith("$")) {
|
||||
const prop = Object.getOwnPropertyDescriptor(Class.prototype, name)
|
||||
if (typeof prop.value == "function") {
|
||||
const queue = []
|
||||
Class.queues = new WeakMap()
|
||||
Class.prototype[name.slice(1)] = function(...args) {
|
||||
const queue = Class.queues.has(this) ? queues.get(this) : []
|
||||
if (!queue.length) queueMicrotask(() => {
|
||||
this[name](...queue)
|
||||
queue.length = 0
|
||||
})
|
||||
queue.push(args)
|
||||
Class.queues.set(this, queue)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue