Skip to content

Action lifecycle in custom elements #5989

Closed
@arackaf

Description

@arackaf

Is this about svelte@next? This project is currently in a pre-release stage and breaking changes may occur at any time. Please do not post any kind of bug reports or questions on GitHub about it.

No.

Describe the bug

Right now, when you put an action on a component that's compiled into a custom element, the action runs immediately, upon creation, with the destroy callback never running.

It would seem that the more correct behavior would be for the action to run when the web component is connected, with the destroy callback running when disconnected.

The fix would likely be related to the code in this PR, which hasn't quite merged yet

#4522

Logs

n/a

To Reproduce

No repro - I've never been able to get custom elements to run in the REPL.

Expected behavior
A clear and concise description of what you expected to happen.

See above.

Stacktraces
If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread's readability:

Stack trace

Stack trace goes here...

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)

Chrome

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)

Mac

  • Svelte version (Please check you can reproduce the issue with the latest release!)

3.32.3

  • Whether your project uses Webpack or Rollup

webpack

Severity
How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Svelte entirely?

Minor

Note: the more honest and specific you are here the more we will take you seriously.

Additional context
Add any other context about the problem here.

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