Skip to content
New issue

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

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

Already on GitHub? # to your account

Make dom.URL.searchParams readonly (val) #871

Merged
merged 1 commit into from
Nov 30, 2024
Merged

Conversation

raquo
Copy link
Contributor

@raquo raquo commented Nov 30, 2024

URL.searchParams is a readonly field. The URLSearchParams object itself is mutable, but the reference is immutable and stable.

https://url.spec.whatwg.org/#dom-url-searchparams
https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams

Note – in JS strict mode (typical for JS bundlers), const url = new URL('http://localhost/').searchParams = new URLSearchParams({foo: "123"}) throws a TypeError saying that searchParams is a readonly field, but in the browser dev console, such an assignment will fail silently instead. You can check that the assignment failed by printing url.searchParams.size == 0 or comparing the new and old references.

My testing and reading of the spec seems to confirm that it should be a val, not a def, at least I couldn't find anything contradicting that.

@zetashift zetashift merged commit 8c4ee12 into scala-js:main Nov 30, 2024
5 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants