Skip to content

The system automatically updates the time, resulting in event loss #13494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/runtime-dom/src/modules/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ function parseName(name: string): [string, EventListenerOptions | undefined] {
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.
let cachedNow: number = 0
const p = /*@__PURE__*/ Promise.resolve()
const getNow = () =>
cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = Date.now()))
cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = performance.now()))

function createInvoker(
initialValue: EventValue,
Expand All @@ -108,7 +108,7 @@ function createInvoker(
// The handler would only fire if the event passed to it was fired
// AFTER it was attached.
if (!e._vts) {
e._vts = Date.now()
e._vts = performance.now()
} else if (e._vts <= invoker.attached) {
return
}
Expand Down