Skip to content
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

[ext/web] Event.timeStamp is always 0 #23467

Open
lowlighter opened this issue Apr 20, 2024 · 5 comments
Open

[ext/web] Event.timeStamp is always 0 #23467

lowlighter opened this issue Apr 20, 2024 · 5 comments
Labels
ext/web related to the ext/web crate feat new feature (which has been agreed to/accepted) web related to Web APIs

Comments

@lowlighter
Copy link
Contributor

Version: Deno 1.42.4

Currently any Event.timeStamp is always set to 0

timeStamp: 0,

The timeStamp read-only property of the Event interface returns the time (in milliseconds) at which the event was created.

https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp

It should be set to performance.now() or similar to match more closely what is expected

Motivation
Make possible to test cases that requires this property to be non-zero:

const oldEvent = new Event()
await delay(5)
const lastEvent = new Event()
a.lastUpdated = oldEvent.timeStamp+1

a.addEventListener(event => {
  if (event.timeStamp < a.lastUpdated)
    return
  expect(event).toBe(lastEvent)
})

a.dispatchEvent(oldEvent)
a.dispatchEvent(lastEvent)

The above is not possible currently, because timeStamp property is readonly

@dsherret
Copy link
Member

dsherret commented Apr 20, 2024

@lowlighter
Copy link
Contributor Author

Is there a specific motivation behind this spec deviation ?

@dsherret
Copy link
Member

dsherret commented Apr 20, 2024

Performance: #20191

I feel like there should be some way to opt into this behaviour though

@lowlighter
Copy link
Contributor Author

Yeah it'd be nice, or at least somehow expose the _attributes symbol so users are able to override properties from the event despite them being readonly

@lucacasonato
Copy link
Member

Mh, I still wonder if we can re-implement this in some way...

@lucacasonato lucacasonato added feat new feature (which has been agreed to/accepted) web related to Web APIs ext/web related to the ext/web crate labels Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/web related to the ext/web crate feat new feature (which has been agreed to/accepted) web related to Web APIs
Projects
None yet
Development

No branches or pull requests

3 participants