mirror of https://github.com/sveltejs/svelte
commit
6036f00dee
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let x = 'no';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>Bar: {x}</p>
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let x = 'yes';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>Foo: {x}</p>
|
@ -0,0 +1,31 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<p>Foo: yes</p>
|
||||||
|
<p>x in parent: yes</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
component.a = false;
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>Bar: yes</p>
|
||||||
|
<p>x in parent: yes</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.a = true;
|
||||||
|
assert.equal(component.x, 'yes');
|
||||||
|
component.x = undefined;
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>Foo: undefined</p>
|
||||||
|
<p>x in parent: undefined</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.a = false;
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>Bar: no</p>
|
||||||
|
<p>x in parent: no</p>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,15 @@
|
|||||||
|
<script>
|
||||||
|
import Foo from './Foo.html';
|
||||||
|
import Bar from './Bar.html';
|
||||||
|
|
||||||
|
export let a = true;
|
||||||
|
export let x;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if a}
|
||||||
|
<Foo bind:x/>
|
||||||
|
{:else}
|
||||||
|
<Bar bind:x/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<p>x in parent: {x}</p>
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let x = 'no';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>Bar: {x}</p>
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let x = 'yes';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>Foo: {x}</p>
|
@ -0,0 +1,31 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<p>Foo: yes</p>
|
||||||
|
<p>x in parent: yes</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
component.a = false;
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>Bar: yes</p>
|
||||||
|
<p>x in parent: yes</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.a = true;
|
||||||
|
assert.equal(component.x, 'yes');
|
||||||
|
component.x = undefined;
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>Foo: undefined</p>
|
||||||
|
<p>x in parent: undefined</p>
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.a = false;
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>Bar: no</p>
|
||||||
|
<p>x in parent: no</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>
|
@ -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