-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[docs] Update tutorial on component binding #6852
[docs] Update tutorial on component binding #6852
Conversation
Updated sample code to remove boilerplate code and removed note warning about an error that is no longer present
Interesting, in that case I'm guessing we should also update https://svelte.dev/docs#bind_component as well? svelte/site/content/docs/02-template-syntax.md Line 1351 in 883c47b
|
Removed note about an error that no longer exists and removed boilerplate code from an example
@ignatiusmb I've added the matching change to the docs |
I'd definitely want to bisect first to figure out when that changed and see whether it was intentional and backed by a test before changing this, because this sounds like something that could easily change back while changing something else if it's not specifying tested for. |
This was fixed in 3.16.7:
With regards to whether this is intentional, in the 3.16.6 repl above, if you swap lines 8 and 9 it runs fine. That is, before this was changed: |
I'm not sure about this change, it looks like it's possible now because |
@bluwy This is specifically referring to binding, so I'm not sure that it's relevant if it breaks by putting it directly in the markup. The current recommendation of the docs also gives an error if inserted directly into the markup:
|
Even if it works with this PR's change, we don't want to lead users to the mindset that |
The first reason for adopting Svelte given on the homepage is "write less code", so the tutorial shouldn't be encouraging writing boilerplate code. If the change in my PR doesn't capture the nuance of the language or something then we can amend it to be clearer to new users, but as it stands the tutorial and documentation explicitly state something that is not true. |
I dont think an extra |
The statement
is not wrong. using it within event handler happens to just work, because (implementation detail that could change anytime) we evaluate it lazily to allow dynamically get the latest however, this do not work in other scenarios, such as:
|
Updated sample code to remove boilerplate code and removed note warning about an error that is no longer present. It seems like previously it was not possible to directly reference a function on a child component, but this is no longer the case.
Discussed this in the discourse and someone said this error was fixed in 3.17 - at a guess, by this issue: #4166 (but I'm new to Svelte so could be completely wrong about that)