Skip to content

"Cannot read property '0' of undefined" when a component tracks more than 32 values and uses a slotted component with a prop on the slot. #4624

@dimfeld

Description

@dimfeld

My scenario: A main component includes a slotted child component. The child component has a slot which passes a prop back to the parent. The main component is tracking enough variables to make dirty be an array. When the slot prop changes, an error occurs.

To Reproduce
Open this REPL, open the console, and click the Toggle button. See that an error occurs: Cannot read property '0' of undefined.
https://svelte.dev/repl/8f6205fdd9d04a5aa250c1c67f6efbce?version=3.20.1

When the child component's slot prop changes, an error is thrown as the update is communicated back to the parent. It appears that the call to get_slot_changes in the child component's update function is returning undefined.

Expected behavior
No error is thrown.

Information about your Svelte project:
Svelte 3.20.1 (see REPL)

Severity

Important but not blocking. Svelte 3.15 before the dirty bitmask change works, so I've been able to revert to that, but I am using some features that were added in later versions, such as referencing a slot variable in an attribute of the slot (e.g. <tr slot="row" let:row class:finished={row.finished}>...). I have worked around the lack of 3.16+ features for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions