Skip to content

feat: add optional compiler-ignore attribute to <slot> #8057

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

Conversation

dane-skipper
Copy link

@dane-skipper dane-skipper commented Nov 25, 2022

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with [feat], [fix], [chore], or [docs].
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

Reason for existence

Closes #8056.
This PR adds an ability to tell Svelte to not compile a <slot> into a Slot so that a developer using Svelte can optionally choose to use a <slot> with behavioral characteristics as defined in the Web Component spec.
Changes are non-breaking, and test execution should reflect that.
Docs have also been updated.

A note on implementation design

There seemed to be a number of places where the compiler-ignore Attribute could have been evaluated and operated upon (e.g. during parsing).
To me, it seemed best to do so during compilation, immediately before the selection of the constructor, through which a given Node would get compiled.

@baseballyama
Copy link
Member

I don't think we should add such an option because already we can use a native slot if we use <svelte:element this="slot">.
Personally, we should have only one way to achieve one thing.

So my opinion is that how about adding documentation about it?

@dane-skipper
Copy link
Author

I was unaware of that option -- thank you for pointing that out! I also agree with the point of only having one way to do things.
I'll revise this PR to only add relevant documentation

@baseballyama
Copy link
Member

We discussed that we will update only the docs in this PR.
So until updating this point, I will change the status to draft.

@baseballyama baseballyama marked this pull request as draft December 31, 2022 08:12
@benmccann benmccann changed the title [feat] adds optional compiler-ignore attribute to <slot> feat: add optional compiler-ignore attribute to <slot> Jan 12, 2023
@baseballyama
Copy link
Member

close in favor of #8326.
(I tried to push a new commit but I don't have permission, so I created a new PR.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instruct compiler to treat designated <slot>s as regular Elements
2 participants