-
-
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
complain if named slots other than direct descendant of component #4509
Merged
Conduitry
merged 7 commits into
sveltejs:master
from
tanhauhau:tanhauhau/feat-warn-named-slots-other-than-top-level
Mar 15, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d185a20
complain if named slots other than direct descendant of component
tanhauhau b43cf2d
adjust error message
Conduitry 6f634b8
remove if/each slot special check
tanhauhau 45632d0
allow slot not to be top level if it is within a custom element
tanhauhau cea1193
update error message
tanhauhau af13983
Merge branch 'master' into pr/4509
Conduitry 4b1002f
update changelog
Conduitry 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 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 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
1 change: 1 addition & 0 deletions
1
test/runtime/samples/component-slot-nested-error-2/Nested.svelte
This file contains 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 @@ | ||
<slot name="slot2"></slot> |
3 changes: 3 additions & 0 deletions
3
test/runtime/samples/component-slot-nested-error-2/_config.js
This file contains 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 { | ||
error: [`Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`] | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/component-slot-nested-error-2/main.svelte
This file contains 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> | ||
import Nested from "./Nested.svelte"; | ||
</script> | ||
|
||
<Nested> | ||
<div slot="slot1"> | ||
<div> | ||
<div slot="slot2" /> | ||
</div> | ||
</div> | ||
</Nested> |
1 change: 1 addition & 0 deletions
1
test/runtime/samples/component-slot-nested-error-3/Nested.svelte
This file contains 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 @@ | ||
<slot name="slot2"></slot> |
3 changes: 3 additions & 0 deletions
3
test/runtime/samples/component-slot-nested-error-3/_config.js
This file contains 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 { | ||
error: [`Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`] | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/component-slot-nested-error-3/main.svelte
This file contains 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> | ||
import Nested from "./Nested.svelte"; | ||
</script> | ||
|
||
<Nested> | ||
<div> | ||
<div> | ||
<div slot="slot2" /> | ||
</div> | ||
</div> | ||
</Nested> |
This file contains 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 @@ | ||
<slot name="slot2"></slot> |
This file contains 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 { | ||
error: [`Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`] | ||
}; |
This file contains 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,9 @@ | ||
<script> | ||
import Nested from "./Nested.svelte"; | ||
</script> | ||
|
||
<Nested> | ||
<div slot="slot1"> | ||
<div slot="slot2" /> | ||
</div> | ||
</Nested> |
9 changes: 9 additions & 0 deletions
9
test/validator/samples/component-slotted-custom-element-2/errors.json
This file contains 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,9 @@ | ||
[ | ||
{ | ||
"code": "invalid-slotted-content", | ||
"message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", | ||
"start": { "line": 10, "column": 9, "character": 138 }, | ||
"end": { "line": 10, "column": 19, "character": 148 }, | ||
"pos": 138 | ||
} | ||
] |
14 changes: 14 additions & 0 deletions
14
test/validator/samples/component-slotted-custom-element-2/input.svelte
This file contains 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,14 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
let thing = false; | ||
</script> | ||
|
||
<custom-element> | ||
<Nested> | ||
{#if thing} | ||
<div> | ||
<div slot='bar' /> | ||
</div> | ||
{/if} | ||
</Nested> | ||
</custom-element> |
1 change: 1 addition & 0 deletions
1
test/validator/samples/component-slotted-custom-element/errors.json
This file contains 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 @@ | ||
[] |
15 changes: 15 additions & 0 deletions
15
test/validator/samples/component-slotted-custom-element/input.svelte
This file contains 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,15 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
let thing = false; | ||
</script> | ||
|
||
<Nested> | ||
<custom-element> | ||
<div> | ||
<div slot='foo' /> | ||
</div> | ||
{#if thing} | ||
<div slot='bar' /> | ||
{/if} | ||
</custom-element> | ||
</Nested> |
2 changes: 1 addition & 1 deletion
2
test/validator/samples/component-slotted-each-block/errors.json
This file contains 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can actually allow it if it is within custom element, since we are going to create them just like a normal element, browser will figure out itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this relates to #1689 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the error message be adjusted then? Something like 'must be a direct child of a component or a descendant of a custom element'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup! updated the error message