mirror of https://github.com/sveltejs/svelte
commit
403d21eca1
@ -0,0 +1,27 @@
|
|||||||
|
let count = 0;
|
||||||
|
let value = 'foo';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value() {
|
||||||
|
count++;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<div>foo</div>
|
||||||
|
<div>foo</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
test({ assert, component, target }) {
|
||||||
|
value = 'bar';
|
||||||
|
component.id = 1;
|
||||||
|
|
||||||
|
assert.equal(count, 4);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<div>bar</div>
|
||||||
|
<div>bar</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
export let id = 0;
|
||||||
|
export let value;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each ['foo', 'bar'] as key (id + key)}
|
||||||
|
<div>{value()}</div>
|
||||||
|
{/each}
|
@ -0,0 +1,9 @@
|
|||||||
|
// destructure to store value
|
||||||
|
export default {
|
||||||
|
skip_if_ssr: true, // pending https://github.com/sveltejs/svelte/issues/3582
|
||||||
|
html: `<h1>2 2 xxx 5 6 9 10 2</h1>`,
|
||||||
|
async test({ assert, target, component }) {
|
||||||
|
await component.update();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<h1>11 11 yyy 12 13 14 15 11</h1>`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
<script>
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
let eid = writable(1);
|
||||||
|
let foo;
|
||||||
|
const u = writable(2);
|
||||||
|
const v = writable(3);
|
||||||
|
const w = writable(4);
|
||||||
|
const x = writable(5);
|
||||||
|
const y = writable(6);
|
||||||
|
[$u, $v, $w] = [
|
||||||
|
{id: eid = writable(foo = 2), name: 'xxx'},
|
||||||
|
5,
|
||||||
|
6
|
||||||
|
];
|
||||||
|
({ a: $x, b: $y } = { a: 9, b: 10 });
|
||||||
|
$: z = $u.id;
|
||||||
|
|
||||||
|
export function update() {
|
||||||
|
[$u, $v, $w] = [
|
||||||
|
{id: eid = writable(foo = 11), name: 'yyy'},
|
||||||
|
12,
|
||||||
|
13
|
||||||
|
];
|
||||||
|
({ a: $x, b: $y } = { a: 14, b: 15 });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{foo} {$eid} {$u.name} {$v} {$w} {$x} {$y} {$z}</h1>
|
@ -1,3 +1,9 @@
|
|||||||
|
// destructure to store
|
||||||
export default {
|
export default {
|
||||||
html: `<h1>2 2 xxx 5 6</h1>`
|
html: `<h1>2 2 xxx 5 6 9 10 2</h1>`,
|
||||||
|
skip_if_ssr: true,
|
||||||
|
async test({ assert, target, component }) {
|
||||||
|
await component.update();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<h1>11 11 yyy 12 13 14 15 11</h1>`);
|
||||||
|
}
|
||||||
};
|
};
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
const obj = {
|
||||||
|
foo : "bar",
|
||||||
|
action(element, { leet }) {
|
||||||
|
element.foo = this.foo + leet;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button use:obj.action={{ leet: 1337 }}>action</button>
|
||||||
|
<button use:foo.action={{ leet: 1337 }}>action</button>
|
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "missing-declaration",
|
||||||
|
"end": {
|
||||||
|
"character": 217,
|
||||||
|
"column": 39,
|
||||||
|
"line": 11
|
||||||
|
},
|
||||||
|
"message": "'foo' is not defined",
|
||||||
|
"pos": 186,
|
||||||
|
"start": {
|
||||||
|
"character": 186,
|
||||||
|
"column": 8,
|
||||||
|
"line": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,15 @@
|
|||||||
|
[{
|
||||||
|
"message": "The 'passive' and 'nonpassive' modifiers cannot be used together",
|
||||||
|
"code": "invalid-event-modifier",
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5,
|
||||||
|
"character": 5
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 51,
|
||||||
|
"character": 51
|
||||||
|
},
|
||||||
|
"pos": 5
|
||||||
|
}]
|
@ -0,0 +1,3 @@
|
|||||||
|
<div on:touchstart|nonpassive|passive={handleWheel}>
|
||||||
|
oops
|
||||||
|
</div>
|
Loading…
Reference in new issue