mirror of https://github.com/sveltejs/svelte
parent
ed9df1fff3
commit
3c4d8b5c2c
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let x = 'no';
|
||||
</script>
|
||||
|
||||
<p>Bar: {x}</p>
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let x = 'yes';
|
||||
</script>
|
||||
|
||||
<p>Foo: {x}</p>
|
@ -0,0 +1,31 @@
|
||||
export default {
|
||||
html: `
|
||||
<p>Foo: yes</p>
|
||||
<p>x in parent: undefined</p>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
component.a = false;
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>Bar: no</p>
|
||||
<p>x in parent: undefined</p>
|
||||
`);
|
||||
|
||||
component.a = true;
|
||||
assert.equal(component.x, undefined);
|
||||
component.x = 'maybe';
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>Foo: yes</p>
|
||||
<p>x in parent: maybe</p>
|
||||
`);
|
||||
|
||||
component.a = false;
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>Bar: no</p>
|
||||
<p>x in parent: maybe</p>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import Foo from './Foo.html';
|
||||
import Bar from './Bar.html';
|
||||
|
||||
export let a = true;
|
||||
export let x;
|
||||
</script>
|
||||
|
||||
<svelte:component this="{a ? Foo : Bar}" bind:x/>
|
||||
|
||||
<p>x in parent: {x}</p>
|
Loading…
Reference in new issue