mirror of https://github.com/sveltejs/svelte
[fix] bind:this during onMount in manually-created component (#6920)
parent
683c39adb7
commit
5a8851436f
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let element;
|
||||
let bound = false;
|
||||
onMount(() => {
|
||||
if (element) bound = true;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<div bind:this={element}></div>
|
||||
<p>
|
||||
Bound? {bound}
|
||||
</p>
|
@ -0,0 +1,11 @@
|
||||
export default {
|
||||
async test({ assert, target }) {
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<div id="target"><div></div>
|
||||
<p>
|
||||
Bound? true
|
||||
</p>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Mount from './Mount.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
onMount(() => {
|
||||
const component = new Mount({
|
||||
target: document.querySelector('#target'),
|
||||
props: {},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="target" />
|
Loading…
Reference in new issue