Skip to content

Support optional transitions #7352

Open
@MathiasWP

Description

@MathiasWP

Describe the problem

It is possible to set transitions via props when creating Svelte components:

<script>
export let transition;
</script>

<p transition:transition|local>Hi!</p>

However, they cannot be optional:

<script>
export let transition = undefined;
</script>

<p transition:transition|local>Hi!</p>

Error thrown if transition is undefined:
Screenshot 2022-03-09 at 11 41 32

Describe the proposed solution

Check if transition is a function before running it.

The current implementation does not check if fn is of type "function"
Screenshot 2022-03-09 at 11 42 50

Alternatives considered

Setting a default empty empty function:

<script>
export let transition = () => {};
</script>

<p transition:transition|local>Hi!</p>

However, this is a potential memory leak until this pr is merged.

Importance

would make my life easier

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