mirror of https://github.com/sveltejs/svelte
only fire onrender hooks once component is in the DOM – fixes #18
parent
8b365084e6
commit
0f464d79b2
@ -0,0 +1,9 @@
|
|||||||
|
<p ref:x>{{inDocument}}</p>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
onrender () {
|
||||||
|
this.set({ inDocument: document.contains( this.refs.x ) })
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,10 @@
|
|||||||
|
export default {
|
||||||
|
html: `<div><p>true</p></div>`,
|
||||||
|
|
||||||
|
test ( assert, component, target ) {
|
||||||
|
component.set({ foo: true });
|
||||||
|
assert.htmlEqual( target.innerHTML, `<div><p>true</p>\n<p>true</p></div>` );
|
||||||
|
|
||||||
|
component.teardown();
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,17 @@
|
|||||||
|
<div>
|
||||||
|
<Widget/>
|
||||||
|
|
||||||
|
{{#if foo}}
|
||||||
|
<Widget/>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Widget from './Widget.html';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
Widget
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in new issue