-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
(Re)introduce <svelte:document>? #3310
Comments
As described in the linked ticket, There's nothing really in the way of adding this again, but the question is whether it would cause more confusion than it's worth. Even if we mention in the docs the differences between the events emitted in different browsers, issues will almost certainly be opened about Svelte 'bugs' in certain browsers or about feature requests to make it behave the same across browsers. |
I agree, I think it's great that Svelte aims to work with the DOM, warts and all. But the warts include the caveats around Having That being said, Thank you for considering it! |
|
So at the current status, if I'd like to add event listener to document (for example, listen to visibility change), the only option have is document.addEventListener / removeEventListener? |
@naorye right now, yes, unless you can use an event from |
I think |
Another Specifically, I need Please introduce |
One more use case is Cordova/Ionic. These frameworks have Device Ready event, which fires on document object only. It would be really great to see svelte:document back. I can understand the reasons why it was removed but there are quite legitimate use cases for it. |
Any updates? I don't think implementing this would take too much time and effort, since we used to have it in the past. |
I think the solution to this is to lean on the 'warnings' API for problematic events; this is already something you do with A11y warnings... |
Another reason: iOS rarely fires |
Closes #3310 --------- Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Simon H <[email protected]>
|
Is your feature request related to a problem? Please describe.
I noticed Svelte used to have a
<svelte:document>
but then it got removed. However, listeners ondocument
work a bit differently than ondocument.body
. For example, amousemove
/mouseup
event on document.body stops the minute you move the cursor out of the browser viewport, but on document they keep getting fired.Describe the solution you'd like
A
<svelte:document>
element to work with events on theDocument
object (especially events that happen exclusively on a document).Describe alternatives you've considered
You can add events to
document
imperatively, but a declarative alternative would be nicer.How important is this feature to you?
I've just started exploring Svelte, so I've not tried many things in it. For my particular usecase I would not be able to use
<svelte:document>
but, for the sake of completeness, I think it would be a good addition.The text was updated successfully, but these errors were encountered: