test that private state doesnt leak into parent

pull/7738/head
Richard Harris 7 years ago
parent c464a11cdf
commit 1cb7a0a3e3

@ -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…
Cancel
Save