mirror of https://github.com/sveltejs/svelte
parent
8d1a9fb328
commit
0acd7903f0
@ -0,0 +1,24 @@
|
||||
export default {
|
||||
props: {
|
||||
array: [
|
||||
[1, 2, 3, 4, 5],
|
||||
[6, 7, 8],
|
||||
[9, 10, 11, 12],
|
||||
[13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
|
||||
]
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>First: 1, Half: 3, Last: 5, Length: 5</p>
|
||||
<p>First: 6, Half: 7, Last: 8, Length: 3</p>
|
||||
<p>First: 9, Half: 11, Last: 12, Length: 4</p>
|
||||
<p>First: 13, Half: 18, Last: 22, Length: 10</p>
|
||||
`,
|
||||
|
||||
test({ assert, component, target }) {
|
||||
component.array = [[23, 24, 25, 26, 27, 28, 29]];
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<p>First: 23, Half: 26, Last: 29, Length: 7</p>
|
||||
`);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
export let array;
|
||||
</script>
|
||||
|
||||
{#each array as { 0: first, length, [length - 1]: last, [Math.floor(length / 2)]: half }}
|
||||
<p>First: {first}, Half: {half}, Last: {last}, Length: {length}</p>
|
||||
{/each}
|
||||
@ -0,0 +1,26 @@
|
||||
export default {
|
||||
props: {
|
||||
firstString: 'cats',
|
||||
secondString: 'dogs',
|
||||
objectsArray: [
|
||||
{ dogs: 'woof', cats: 'meow', stac: 'stack', DOGS: 'WOOF' },
|
||||
{ dogs: 'A German sheppard', cats: 'A tailless cat', stac: 'A jenga tower', DOGS: 'A GERMAN SHEPPARD' },
|
||||
{ dogs: 'dogs', cats: 'cats', stac: 'stac', DOGS: 'DOGS' }
|
||||
]
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>cats: meow</p>
|
||||
<p>dogs: woof</p>
|
||||
<p>stac: stack</p>
|
||||
<p>DOGS: WOOF</p>
|
||||
<p>cats: A tailless cat</p>
|
||||
<p>dogs: A German sheppard</p>
|
||||
<p>stac: A jenga tower</p>
|
||||
<p>DOGS: A GERMAN SHEPPARD</p>
|
||||
<p>cats: cats</p>
|
||||
<p>dogs: dogs</p>
|
||||
<p>stac: stac</p>
|
||||
<p>DOGS: DOGS</p>
|
||||
`
|
||||
};
|
||||
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export let objectsArray;
|
||||
export let firstString;
|
||||
export let secondString;
|
||||
</script>
|
||||
|
||||
{#each objectsArray as { [firstString]: firstProp, [secondString]: secondProp, [firstString.split('').reverse().join('')]: reverseFirst, [secondString.toUpperCase()]: upperSecond } }
|
||||
<p>{firstString}: {firstProp}</p>
|
||||
<p>{secondString}: {secondProp}</p>
|
||||
<p>{firstString.split('').reverse().join('')}: {reverseFirst}</p>
|
||||
<p>{secondString.toUpperCase()}: {upperSecond}</p>
|
||||
{/each}
|
||||
Loading…
Reference in new issue