-
-
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
feat: conditional slots #8304
feat: conditional slots #8304
Conversation
@tanhauhau is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
1497cf4
to
347774a
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
8e2e473
to
b4df71f
Compare
af38d89
to
07d4350
Compare
Seems like there is a bug in Svelte which make $$slots.default being true even if the slot is not there. The code should work once sveltejs/svelte#8304 is fixed.
* Add menu in expanded tile when provided by viewer or searchResults widget * Setup tile menu in dashboard's search results * Attempt to fix separator display when no result navigator. Seems like there is a bug in Svelte which make $$slots.default being true even if the slot is not there. The code should work once sveltejs/svelte#8304 is fixed. * Update our package versions * Use ng14 branch of Pastanaga the time for us to upgrade our apps to ng15 * Fix tests
Does this make it work with Eg. would this work: <script>
// an array of tuples, [['slotName', SlotContent],...];
const someDynamicSlots = getSlots();
</script>
<ChildComponent>
{#each someDynamicSlots as [name, Content]}
<Content slot={name} />
{/each}
</ChildComponent> This is useful when at compile time you don't know which or how many slots you have, but that might be out of scope for this. |
--------- Co-authored-by: Simon Holthausen <[email protected]>
…s#7442) --------- Co-authored-by: Ivan Hofer <[email protected]> Co-authored-by: Simon H <[email protected]> Co-authored-by: Ignatius Bagus <[email protected]> Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Simon Holthausen <[email protected]>
Null and undefined `value` bindings should always be set to an empty string. This allows native browser validation of `required` fields to work as expected with placeholder options. Placeholder options bound to null are necessary in forms where the field is conditionally required, and the bound value is posted to an API endpoint which requires it to be a nullable number or object rather than a string. fixes sveltejs#8312
Svelte 5 will substantially rewrite how things works under the hood. Adding such a big enhancement prior to us knowing if it and how it would work in Svelte 5 feels dangerous, so we're holding off from merging until we have more confidence in how Svelte 5 shapes out. Sorry to make everyone wait a little longer, but we're very aware of people wanting such a feature and are thinking actively about it. |
Will this make conditionally forwarding named slots in svelte 4 possible? Right now I get this error if I try to conditionally forward (meaning, only forward it if it was specified) a named slot: <!--
Error: Element with a slot='...' attribute must be
a child of a component or a descendant of a custom element
-->
{#if $$slots.title}<slot name="title" slot="title" />{/if} btw, the (clumsy) workaround I found so far is to add an optional <!-- Title.svelte -->
<script>
export let slots = $$slots // allow to override $$slots
</script>
<div>
{#if slots.title}<h3><slot name="title" /></h3>{/if}
<slot />
</div> |
Closing since slots are superseded by snippets in Svelte 5, which provide the necessary flexibility |
Implementing sveltejs/rfcs#64
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests
npm test
and lint the project withnpm run lint