document DOM binding undefined warning

A child's DOM node bound from a parent's empty prop throws a warning. This explains it and shows how to suppress.
pull/2726/head
Scotty Simpson 6 years ago committed by GitHub
parent ec74b21c37
commit 22c17f9b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -553,6 +553,27 @@ To get a reference to a DOM node, use `bind:this`.
<canvas bind:this={canvasElement}></canvas>
```
Note that binding a property of a parent component to a child component's DOM node will throw a warning unless the property is assigned a default value:
```html
<!-- Child.svelte -->
<script>
export let inputElement
</script>
<input bind:this={inputElement} />
...
<!-- Parent.svelte -->
<script>
let inputElement
</script>
<Child bind:inputElement>
```
Assign a non-`undefined` value in either component to suppress the warning.
### Component bindings

Loading…
Cancel
Save