Skip to content

bind:this fails with store #3591

@davidaq

Description

@davidaq

Describe the bug
Using bind:this and a writable store together doesn't provide expected behavior.

Logs
No error log.

To Reproduce
Can be reproduced in REPL:

<script>
import { writable } from 'svelte/store'
let ref = writable(null)
</script>

<h1 bind:this={$ref}>HELLO</h1>
<i>{$ref ? $ref.innerHTML : ''}</i>

Expected behavior
Expect to see two lines of "HELLO". The second "HELLO" inside <i> didn't show up as expected.

Severity
Can be worked around.

Work around

<script>
import { writable } from 'svelte/store'
let ref = writable({})
</script>

<h1 bind:this={$ref.el}>HELLO</h1>
<i>{$ref.el ? $ref.el.innerHTML : ''}</i>

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