Skip to content

site: clearer examples for <slot let:name> #4125

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

Merged
merged 1 commit into from
Feb 23, 2020

Conversation

mdempsky
Copy link
Contributor

In the first example, "item" is used to describe three logically
distinct objects: (1) the name of the slot's property; (2) the JS
variable used within FancyList.svelte's {#each} block; and (3) the JS
variable used within App.svelte. To make it clearer that these are
three different objects, give them different names.

The second example can continue reusing the same name for all of the
objects to demonstrate there's no collision between them. But we can
also simplify the example to take further advantage of shorthand
rules.

In the first example, "item" is used to describe three logically
distinct objects: (1) the name of the slot's property; (2) the JS
variable used within FancyList.svelte's {#each} block; and (3) the JS
variable used within App.svelte. To make it clearer that these are
three different objects, give them different names.

The second example can continue reusing the same name for all of the
objects to demonstrate there's no collision between them. But we can
also simplify the example to take further advantage of shorthand
rules.
@mdempsky
Copy link
Contributor Author

For context, I found learning about this feature confusing. I'm used to "X=Y" means "set variable X to value Y". However "let:foo={bar}" actually means "declare variable 'bar' and set it to the value of property 'foo'". The examples didn't make this clear because "let:item={item}" confuses which instance of the identifier "item" does what. I had to copy the code into the REPL and play around with it to figure this out.

@Conduitry Conduitry merged commit a53da7e into sveltejs:master Feb 23, 2020
jesseskinner pushed a commit to jesseskinner/svelte that referenced this pull request Feb 27, 2020
taylorzane pushed a commit to taylorzane/svelte that referenced this pull request Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants