Merge 0b2270d417
into 5f8314cb7f
This commit is contained in:
commit
9604d3b887
|
@ -83,12 +83,12 @@ function parseName(name: string): [string, EventListenerOptions | undefined] {
|
||||||
return [event, options]
|
return [event, options]
|
||||||
}
|
}
|
||||||
|
|
||||||
// To avoid the overhead of repeatedly calling Date.now(), we cache
|
// To avoid the overhead of repeatedly calling performance.now(), we cache
|
||||||
// and use the same timestamp for all event listeners attached in the same tick.
|
// and use the same timestamp for all event listeners attached in the same tick.
|
||||||
let cachedNow: number = 0
|
let cachedNow: number = 0
|
||||||
const p = /*@__PURE__*/ Promise.resolve()
|
const p = /*@__PURE__*/ Promise.resolve()
|
||||||
const getNow = () =>
|
const getNow = () =>
|
||||||
cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = Date.now()))
|
cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = performance.now()))
|
||||||
|
|
||||||
function createInvoker(
|
function createInvoker(
|
||||||
initialValue: EventValue,
|
initialValue: EventValue,
|
||||||
|
@ -108,7 +108,7 @@ function createInvoker(
|
||||||
// The handler would only fire if the event passed to it was fired
|
// The handler would only fire if the event passed to it was fired
|
||||||
// AFTER it was attached.
|
// AFTER it was attached.
|
||||||
if (!e._vts) {
|
if (!e._vts) {
|
||||||
e._vts = Date.now()
|
e._vts = performance.now()
|
||||||
} else if (e._vts <= invoker.attached) {
|
} else if (e._vts <= invoker.attached) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue