Skip to content

slot props break when there are too many variables #4481

@cdhanna

Description

@cdhanna

Describe the bug
Lets say I have an app.svelte and a Hoverable.svelte component. In the hoverable component, I have a slot prop that I want to expose back to the app svelte code. That works, until app.svelte defines many variables. Specifically, when the hoverable component changes the value of the slot prop, the change is not getting picked up by the app svelte code.

Logs
I don't see any relevant logs :(

To Reproduce
I copied the slot-prop example from the docs, but changed it to have a bunch of extra variables.
https://svelte.dev/repl/e5a158392c174c7594963d5a1e0308ca?version=3.19.0

Its worth pointing out that in 3.15, this bug doesn't exist. You can have a bunch of variables, and still get the expected slot-prop behaviour.
https://svelte.dev/repl/e5a158392c174c7594963d5a1e0308ca?version=3.15.0

Expected behavior
When I hover over the Hoverable component, it should read true. When I am not, it should read false.

Stacktraces
I don't see any interesting stack trace.

Information about your Svelte project:

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)
    Google Chrome | 79.0.3945.130 (Official Build) (64-bit)
    Revision | e22de67c28798d98833a7137c0e22876237fc40a-refs/branch-heads/3945@{create initial data for dynamic components in correct place #1047}
    JavaScript | V8 7.9.317.33

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)
    macOS Version 10.14.5 (Build 18F203)

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

  • Whether your project uses Webpack or Rollup
    I use rollup for my project, but I can repro in the repl.

Severity
I'm fine down-grading to 3.15 to avoid this bug, but it feels like a pretty significant problem.

Additional context
Its worth pointing out that I came across this bug in a component that didn't obviously have a bunch of top-level variables. I was designing a component that had a few top level variables, some bindings, some event passing, some slot props, etc... I noticed my slot-prop changes weren't getting picked up in the parent component, and it drove me nuts for almost a whole day. Eventually, as I started removing bits and bits of code to isolate the problem, it started working again. Finally, it got to the point where it worked, until I added an unused top level variable.
As I was looking around, I came across this merged feature in 3.16 #3945 . I haven't read the PR in full, but from skimming it, my gut tells me its related to my bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions