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

fix(runtime): Declare Window.self and DedicatedWorkerGlobalScope.name with util.writable() #12378

Merged
merged 6 commits into from
Oct 11, 2021

Conversation

andreubotella
Copy link
Contributor

Window's self property and DedicatedWorkerGlobalScope's name property are defined as Web IDL read-only attributes with the [Replaceable] extended attribute, meaning that their setter will redefine the property as a data property with the set value, rather than changing some internal state. Deno currently defines them as read-only data properties instead.

Given that Web IDL requires all attributes to be accessor properties rather than data properties, but Deno exposes almost all of those properties as either read-only or writable data properties, it makes sense to expose [Replaceable] properties as writable as well – as is already the case with WindowOrWorkerGlobalScope's performance property.

Andreu Botella added 2 commits October 9, 2021 01:06
…ame` with `util.writable()`

`Window`'s `self` property and `DedicatedWorkerGlobalScope`'s `name`
property are defined as Web IDL read-only attributes with the
`[Replaceable]` extended attribute, meaning that their setter will
redefine the property as a data property with the set value, rather than
changing some internal state. Deno currently defines them as read-only
data properties instead.

Given that Web IDL requires all attributes to be accessor properties
rather than data properties, but Deno exposes almost all of those
properties as either read-only or writable data properties, it makes
sense to expose `[Replaceable]` properties as writable as well – as is
already the case with `WindowOrWorkerGlobalScope`'s `performance`
property.
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test that will verify if worker will still be working once you replace self?

@andreubotella
Copy link
Contributor Author

andreubotella commented Oct 9, 2021

Do we have a test that will verify if worker will still be working once you replace self?

self in workers isn't replaceable, just on the main thread. And replacing it there shouldn't break anything, but I'll still add a test to make extra sure.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Andreu!

@bartlomieju bartlomieju merged commit fbcbbd7 into denoland:main Oct 11, 2021
@andreubotella andreubotella deleted the replaceable branch October 11, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants