Skip to content

falsy attachments don't work when passed as a prop #16018

Closed
@jjones315

Description

@jjones315

Describe the bug

When trying to conditionally attach to a component when the attachment expression is false a run time error occurs.
for example

<Child1 {@attach enabled && attachment}>
</Child1>

will result in the error
TypeError: (get(...) && attachment) is not a function

while passing enabled down and putting the attachment expression in the Child component works as expected.

Reproduction

https://svelte.dev/playground/08d0da19e5204af9ba1d3103af029d69?version=5.33.4

click the "Enabled" checkbox to disable the attachment. notice the error. comment out <Child1... and <Child2... works as expected

Logs

Uncaught TypeError: (get(...) && attachment) is not a function

	in Child1.svelte
	in App.svelte

    at [@attach] (playground:output:3957:69)
    at eval (playground:output:3184:63)
    at update_reaction (playground:output:1949:57)
    at update_effect (playground:output:2115:19)
    at flush_queued_effects (playground:output:2230:7)
    at flush_queued_root_effects (playground:output:2201:6)

System Info

running in repl@5.33.4. don't have access to my machine atm

Severity

annoyance

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