Skip to content
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

Conversation

tanhauhau
Copy link
Member

@tanhauhau tanhauhau commented Mar 5, 2020

Fixes #3385

allow nested named slots if it is within custom element

@tanhauhau tanhauhau force-pushed the tanhauhau/feat-warn-named-slots-other-than-top-level branch from d9ece3c to 0e219ab Compare March 5, 2020 06:30
@tanhauhau tanhauhau force-pushed the tanhauhau/feat-warn-named-slots-other-than-top-level branch from 0e219ab to d185a20 Compare March 6, 2020 10:20
@tanhauhau tanhauhau added the slot label Mar 6, 2020
@@ -395,7 +395,7 @@ export default class Element extends Node {
component.slot_outlets.add(name);
}

if (!(parent.type === 'InlineComponent' || (parent.type === 'Element' && /-/.test(parent.name)))) {
if (!(parent.type === 'InlineComponent' || within_custom_element(parent))) {
Copy link
Member Author

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

Copy link
Member Author

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)

Copy link
Member

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'?

Copy link
Member Author

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

@Conduitry Conduitry merged commit 5bb5ba4 into sveltejs:master Mar 15, 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.

Compiler shouldn't allow named slots other than at top level inside component
2 participants