-
-
Couldn't load subscription status.
- Fork 4.7k
Do not expose default slot let bindings to named slots #6049
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9a28416
should not extend scope for across slots
tanhauhau 2c41d2e
disallow named slots inheriting let: scope from default slots
tanhauhau bc115a8
fix tests
tanhauhau a4fbc31
fix test
tanhauhau cdccbbe
Merge branch 'version-4' into tanhauhau/gh-5865
gtm-nayan bd1bd4f
fix
gtm-nayan 6111352
add runtime tests
gtm-nayan c4bf84a
rename test since it doesn't inherit anymore
gtm-nayan 3ed219e
fix lint
gtm-nayan a983324
remove warnings
gtm-nayan f7b1ff8
add compile script
gtm-nayan 36f98ac
document script
gtm-nayan b27dd26
improve warning
gtm-nayan c6e3e6d
fix test
gtm-nayan 8680210
handle renames
gtm-nayan 46cdb12
fix lint
gtm-nayan 7fa1615
gather names from all parents instead of just the nearest
gtm-nayan 0cb7561
remove unused import
gtm-nayan aa0f756
add reminder
gtm-nayan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Compile all Svelte files in a directory to JS and CSS files | ||
| // Usage: node scripts/compile-test.js <directory> | ||
|
|
||
| import { mkdirSync, readFileSync, writeFileSync } from 'fs'; | ||
| import path from 'path'; | ||
| import glob from 'tiny-glob/sync.js'; | ||
| import { compile } from '../src/compiler/index.js'; | ||
|
|
||
| const cwd = path.resolve(process.argv[2]); | ||
|
|
||
| const options = [ | ||
| ['normal', {}], | ||
| ['hydrate', { hydratable: true }], | ||
| ['ssr', { generate: 'ssr' }] | ||
| ]; | ||
| for (const file of glob('**/*.svelte', { cwd })) { | ||
| const contents = readFileSync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, ''); | ||
| let w; | ||
| for (const [name, opts] of options) { | ||
| const dir = `${cwd}/_output/${name}`; | ||
|
|
||
| const { js, css, warnings } = compile(contents, { | ||
| ...opts, | ||
| filename: file | ||
| }); | ||
|
|
||
| if (warnings.length) { | ||
| w = warnings; | ||
| } | ||
|
|
||
| mkdirSync(dir, { recursive: true }); | ||
| js.code && writeFileSync(`${dir}/${file.replace(/\.svelte$/, '.js')}`, js.code); | ||
| css.code && writeFileSync(`${dir}/${file.replace(/\.svelte$/, '.css')}`, css.code); | ||
| } | ||
|
|
||
| if (w) { | ||
| console.log(`Warnings for ${file}:`); | ||
| console.log(w); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/component-slot-default-in-each/Nested.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <script> | ||
| let promise = new Promise(resolve => resolve(10)); | ||
| </script> | ||
|
|
||
| {#each {length: 3} as _, i} | ||
| <slot item={i}/> | ||
| {/each} | ||
|
|
||
| {#await promise then value} | ||
| <slot {value}/> | ||
| {/await} |
7 changes: 7 additions & 0 deletions
7
test/runtime/samples/component-slot-default-in-each/_config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default { | ||
| html: ` | ||
| <div>0 - undefined</div> | ||
| <div>1 - undefined</div> | ||
| <div>2 - undefined</div> | ||
| ` | ||
| }; |
7 changes: 7 additions & 0 deletions
7
test/runtime/samples/component-slot-default-in-each/main.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <script> | ||
| import Nested from './Nested.svelte'; | ||
| </script> | ||
|
|
||
| <Nested let:item let:value> | ||
| <div>{item} - {value}</div> | ||
| </Nested> |
3 changes: 3 additions & 0 deletions
3
test/runtime/samples/component-slot-let-scope-2/Nested.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <slot /> | ||
| <slot thing={2} name="thing"/> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default { | ||
| html: '<span>undefined</span><span>2</span>' | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <script> | ||
| import Nested from './Nested.svelte'; | ||
| </script> | ||
|
|
||
| <Nested let:thing> | ||
| <span>{thing}</span> | ||
| <svelte:fragment slot="thing" let:thing><span>{thing}</span></svelte:fragment> | ||
| </Nested> |
2 changes: 0 additions & 2 deletions
2
...named-inherits-default-lets/Nested.svelte → .../component-slot-let-scope-3/Nested.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| <script> | ||
| import { onDestroy } from 'svelte'; | ||
|
|
||
| let count = 0; | ||
|
|
||
| function increment() { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.