mirror of https://github.com/sveltejs/svelte
parent
f4e66c0e72
commit
e6ef5af6ba
@ -0,0 +1,3 @@
|
|||||||
|
<h1>Bar</h1>
|
||||||
|
<slot></slot>
|
||||||
|
<slot name='other'></slot>
|
@ -0,0 +1 @@
|
|||||||
|
<div>baz</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
<h1>Foo</h1>
|
||||||
|
<slot name='other'></slot>
|
||||||
|
<slot></slot>
|
@ -0,0 +1,37 @@
|
|||||||
|
export default {
|
||||||
|
data: {
|
||||||
|
x: true
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<h1>Foo</h1>
|
||||||
|
<div slot='other'>what goes up must come down</div>
|
||||||
|
<p>element</p>
|
||||||
|
you're it
|
||||||
|
<p>neither foo nor bar</p>
|
||||||
|
text
|
||||||
|
<span>a</span>
|
||||||
|
<span>b</span>
|
||||||
|
<span>c</span>
|
||||||
|
<div>baz</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
test(assert, component, target) {
|
||||||
|
component.set({
|
||||||
|
x: false
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<h1>Bar</h1>
|
||||||
|
<p>element</p>
|
||||||
|
you're it
|
||||||
|
<p>neither foo nor bar</p>
|
||||||
|
text
|
||||||
|
<span>a</span>
|
||||||
|
<span>b</span>
|
||||||
|
<span>c</span>
|
||||||
|
<div>baz</div>
|
||||||
|
<div slot='other'>what goes up must come down</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,45 @@
|
|||||||
|
<:Switch { x ? Foo : Bar } x='{{x}}'>
|
||||||
|
<p>element</p>
|
||||||
|
|
||||||
|
{{tag}}
|
||||||
|
|
||||||
|
{{#if foo}}
|
||||||
|
<p>foo</p>
|
||||||
|
{{elseif bar}}
|
||||||
|
<p>bar</p>
|
||||||
|
{{else}}
|
||||||
|
<p>neither foo nor bar</p>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
text
|
||||||
|
|
||||||
|
{{#each things as thing}}
|
||||||
|
<span>{{thing}}</span>
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
<Baz/>
|
||||||
|
|
||||||
|
<div slot='other'>what goes up must come down</div>
|
||||||
|
</:Switch>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Foo from './Foo.html';
|
||||||
|
import Bar from './Bar.html';
|
||||||
|
import Baz from './Baz.html';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
Foo,
|
||||||
|
Bar,
|
||||||
|
|
||||||
|
tag: 'you\'re it',
|
||||||
|
things: ['a', 'b', 'c']
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Baz
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in new issue