Skip to content

<slot let:name={value}> not working in customElement (nor is {#if}, {#each}, etc.) #4402

Closed as not planned
@campbeln

Description

@campbeln

Custom elements as defined by <svelte:options tag="custom-element" /> + rollup.config.js's plugins: [ svelte( { customElement: true } ) ] are not parsing incoming slot definitions. For example:

<!-- customElement.svelte -->
<svelte:options tag="custom-element" />
<script>
	let hovering = null;
	function enter() {
		hovering = true;
	}
	function leave() {
		hovering = false;
	}
</script>
<div on:mouseenter={enter} on:mouseleave={leave}>
	<slot hovering={hovering}>default slot content hovering value = [{hovering}]</slot>
</div>


<!-- index.html -->
<custom-element let:hovering={status}>
	<div>hovering = [{status}]</div>
</custom-element><!-- renders unparsed as `hovering = [{status}]` and never changes on hover events -->

<custom-element></custom-element><!-- renders parsed as `default slot content hovering value = [null]` with `[null]` changing to `[true]`/`[false]` as the user hovers -->

This issue is keeping us from moving to Svelte.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions