-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Initial data seems to be not affecting the window scroll binding #938
Comments
The REPL you provided is broken cause the state is not in proper json format. You need to put quotes on |
Hm, I expected it to be POJO instead of fully valid json. At least I would
consider it confusing for beginners coming from the guide where data is
inside JS and keys are unquoted.
But for me it even doesn’t work if I leave the state an empty object and
expect the component’s default data to kick in.
…On Wed, Nov 22, 2017 at 19:43 Efthymis Sarmpanis ***@***.***> wrote:
The REPL you provided is broken cause the state is not in proper json
format. You need to put quotes on y and everything works as expected REPL
<https://svelte.technology/repl?version=1.42.0&gist=e08311353c79873af502ec137f5cfce3>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#938 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAgGCHBLb2zOeeGM61IZ0bmFJYurdpUOks5s5E8xgaJpZM4QnLUZ>
.
|
It is true that REPL is poorly documented, but if you check out the examples you can kind of understand its usage. I agree that it needs proper documentation. Another thing is that REPL is compiled on load and I believe it is not recompiled after the changes. That is why when you remove the field the state does not change. See this REPL which uses an empty object. |
The REPL is supposed to show an error if the data is invalid JSON. Will raise an issue about that. It's weird that it doesn't respect the |
I will check again but I believe I’ve tested it with empty state object
couple of times before also trying the unit value there.
I could also work on a PR that would let pojo format in the state panel.
…On Wed, Nov 22, 2017 at 20:10 Rich Harris ***@***.***> wrote:
The REPL is supposed to show an error if the data is invalid JSON. Will
raise an issue about that.
It's weird that it doesn't respect the data provided by the component
itself — definitely a bug.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#938 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAgGCGlb-GgW9Rb2MbKiuEOB1479No1cks5s5FVogaJpZM4QnLUZ>
.
|
@Rich-Harris the original REPL of this issue does prompt you with On the other hand, how would a component know if a A cool feature in REPL though, would be to have a |
Indeed my original repl does show the error, I didn't notice it (which is bad for me, but also fro the UX:) |
set window scroll from bindings on initialisation
Fixed in 2.15, finally! |
sync svelte docs Co-authored-by: Rich-Harris <[email protected]>
I should mentions it's by no means a problem for my real project but I decided it might be worth sharing.
It looks like if we bind a value to window's
scrollY
the components' initial data (both default or passed to the constructor) is thrown away and replaced with the actual scroll position which is usually 0;Repro: https://svelte.technology/repl?version=1.42.0&gist=2afe785004bcdc4c1bcca6f03f2ed7f9
The text was updated successfully, but these errors were encountered: