-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: bind activeElement
and pointerLockElement
in <svelte:document>
#11879
Conversation
🦋 Changeset detectedLatest commit: 92f8b46 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
50199a9
to
020104e
Compare
Question: The listener fires once when losing or gaining focus, but fires twice when changing focus between two elements (element 1 loses focus, element 2 gains focus). Should it be debounced? Is it feasible to? |
Thank you. We can't use
We can solve this by checking |
Thank you! |
Ah gotcha, missed the |
@@ -1,7 +1,7 @@ | |||
[ | |||
{ | |||
"code": "bind_invalid_name", | |||
"message": "`bind:clientWidth` is not a valid binding. Possible bindings for <svelte:document> are focused, fullscreenElement, visibilityState, this", | |||
"message": "`bind:clientWidth` is not a valid binding. Possible bindings for <svelte:document> are focused, activeElement, fullscreenElement, pointerLockElement, visibilityState, this", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not strictly related to this PR, but a note to self: what is focused
? document.focused
isn't a thing so this seems odd, maybe a bug? also it'd be nice if these things were sorted alphabetically rather than randomly. will investigate after lunch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, looks like we added focused
to all elements a while back. it should probably exclude <svelte:document>
and some other things. can look into that as a separate PR
JSDOM doesn't implement the pointer lock API as far as I can tell, so I don't think a test can be created for it. I have made sure it works in the REPL, though. |
Yeah, we work around that limitation for svelte/packages/svelte/tests/runtime-legacy/samples/document-binding-fullscreen/_config.js Lines 18 to 23 in f3c291d
...but it feels like a bit of a pointless test at that point to be honest |
thanks! |
Adds support for
bind:activeElement
andbind:pointerLockElement
to<svelte:document>
. Closes #2671.I want to add tests (if necessary, because
bind:visibilityState
seems to be untested?), but I need some guidance on where exactly they would go.Svelte 5 rewrite
Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (
main
).If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is
svelte-4
and notmain
.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint