mirror of https://github.com/sveltejs/svelte
commit
a0285fc5f0
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,5 @@
|
|||||||
|
{#await thePromise}
|
||||||
|
<p>loading...</p>
|
||||||
|
{:catch theError}
|
||||||
|
<p>oh no! {theError.message}</p>
|
||||||
|
{/await}
|
@ -0,0 +1,168 @@
|
|||||||
|
{
|
||||||
|
"html": {
|
||||||
|
"start": 0,
|
||||||
|
"end": 99,
|
||||||
|
"type": "Fragment",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"start": 0,
|
||||||
|
"end": 99,
|
||||||
|
"type": "AwaitBlock",
|
||||||
|
"expression": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 8,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "thePromise"
|
||||||
|
},
|
||||||
|
"value": null,
|
||||||
|
"error": "theError",
|
||||||
|
"pending": {
|
||||||
|
"start": 19,
|
||||||
|
"end": 39,
|
||||||
|
"type": "PendingBlock",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"start": 19,
|
||||||
|
"end": 21,
|
||||||
|
"type": "Text",
|
||||||
|
"raw": "\n\t",
|
||||||
|
"data": "\n\t"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 21,
|
||||||
|
"end": 38,
|
||||||
|
"type": "Element",
|
||||||
|
"name": "p",
|
||||||
|
"attributes": [],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"start": 24,
|
||||||
|
"end": 34,
|
||||||
|
"type": "Text",
|
||||||
|
"raw": "loading...",
|
||||||
|
"data": "loading..."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 38,
|
||||||
|
"end": 39,
|
||||||
|
"type": "Text",
|
||||||
|
"raw": "\n",
|
||||||
|
"data": "\n"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"skip": false
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"start": null,
|
||||||
|
"end": null,
|
||||||
|
"type": "ThenBlock",
|
||||||
|
"children": [],
|
||||||
|
"skip": true
|
||||||
|
},
|
||||||
|
"catch": {
|
||||||
|
"start": 39,
|
||||||
|
"end": 91,
|
||||||
|
"type": "CatchBlock",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"start": 56,
|
||||||
|
"end": 58,
|
||||||
|
"type": "Text",
|
||||||
|
"raw": "\n\t",
|
||||||
|
"data": "\n\t"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 58,
|
||||||
|
"end": 90,
|
||||||
|
"type": "Element",
|
||||||
|
"name": "p",
|
||||||
|
"attributes": [],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"start": 61,
|
||||||
|
"end": 68,
|
||||||
|
"type": "Text",
|
||||||
|
"raw": "oh no! ",
|
||||||
|
"data": "oh no! "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 68,
|
||||||
|
"end": 86,
|
||||||
|
"type": "MustacheTag",
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"start": 69,
|
||||||
|
"end": 85,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 12
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 69,
|
||||||
|
"end": 77,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 12
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "theError"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 78,
|
||||||
|
"end": 85,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "message"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 90,
|
||||||
|
"end": 91,
|
||||||
|
"type": "Text",
|
||||||
|
"raw": "\n",
|
||||||
|
"data": "\n"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"skip": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"code": "invalid-catch-placement",
|
||||||
|
"message": "Cannot have an {:catch} block outside an {#await ...} block",
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7,
|
||||||
|
"character": 7
|
||||||
|
},
|
||||||
|
"pos": 7
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
{:catch theValue}
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"code": "invalid-then-placement",
|
||||||
|
"message": "Cannot have an {:then} block outside an {#await ...} block",
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6,
|
||||||
|
"character": 6
|
||||||
|
},
|
||||||
|
"pos": 6
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
{:then theValue}
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `<input readonly>`
|
||||||
|
};
|
@ -0,0 +1 @@
|
|||||||
|
<input READONLY={true} REQUIRED={false}>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `<input>`
|
||||||
|
};
|
@ -0,0 +1 @@
|
|||||||
|
<input {...{ foo: null }} readonly={false} required={false} disabled={null}>
|
@ -0,0 +1,4 @@
|
|||||||
|
export default {
|
||||||
|
skip_if_ssr: true,
|
||||||
|
html: `<div>object</div>`
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
const foo = writable();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div bind:this={$foo}>{typeof $foo}</div>
|
@ -0,0 +1,18 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
primary: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `<div class="test-class primary" role="button"></div>`,
|
||||||
|
|
||||||
|
test({ assert, component, target, window }) {
|
||||||
|
component.primary = true;
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<div class="test-class primary" role="button"></div>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
let primary = true;
|
||||||
|
let elem;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={elem}
|
||||||
|
class="test-class"
|
||||||
|
class:primary
|
||||||
|
{...{ role: 'button' }}
|
||||||
|
></div>
|
@ -0,0 +1,4 @@
|
|||||||
|
export default {
|
||||||
|
html: `<text>hello world</text>`,
|
||||||
|
preserveIdentifiers: true,
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
let foo = 'hello world'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<text>{foo}</text>
|
@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<div>1</div>
|
||||||
|
<div>2</div>
|
||||||
|
<div>3</div>
|
||||||
|
`
|
||||||
|
};
|
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
const arr = [1, 2, 3];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each arr as item ((() => item)())}
|
||||||
|
<div>
|
||||||
|
{item}
|
||||||
|
</div>
|
||||||
|
{/each}
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `blah blah blah blah`
|
||||||
|
};
|
@ -0,0 +1,32 @@
|
|||||||
|
<script>
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
const foo = writable(true);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if $foo}
|
||||||
|
blah
|
||||||
|
{:else}
|
||||||
|
{#if bar()}
|
||||||
|
<Bar/>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if $foo}
|
||||||
|
blah
|
||||||
|
{:else}
|
||||||
|
{#if bar}
|
||||||
|
<Baz/>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if $foo}
|
||||||
|
blah
|
||||||
|
{:else if bar()}
|
||||||
|
<Bar/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if $foo}
|
||||||
|
blah
|
||||||
|
{:else if bar}
|
||||||
|
<Bar/>
|
||||||
|
{/if}
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `<h1>1 2</h1>`
|
||||||
|
};
|
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
let foo = 0;
|
||||||
|
let bar;
|
||||||
|
$: {
|
||||||
|
bar = foo + 1;
|
||||||
|
if (foo) {
|
||||||
|
break $;
|
||||||
|
}
|
||||||
|
bar = foo + 2;
|
||||||
|
}
|
||||||
|
foo = 1;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{foo} {bar}</h1>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `@foo`
|
||||||
|
};
|
@ -0,0 +1 @@
|
|||||||
|
{(() => '@foo')()}
|
@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
html: `<div class='foo bar'>hello</div>`,
|
||||||
|
test({ assert, component, target }) {
|
||||||
|
component.blah = 'goodbye';
|
||||||
|
assert.htmlEqual(target.innerHTML, `<div class='foo bar'>goodbye</div>`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let blah = 'hello';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class='foo' class:bar={true} {...{}}>{blah}</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `<input>`
|
||||||
|
};
|
@ -0,0 +1 @@
|
|||||||
|
<input placeholder='foo' {...{ placeholder: null }}>
|
@ -1,4 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
|
compileOptions: { dev: true }, // tests `@validate_store` code generation
|
||||||
|
|
||||||
html: `
|
html: `
|
||||||
<p>42</p>
|
<p>42</p>
|
||||||
`
|
`
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
let subscribeCalled = false;
|
||||||
|
|
||||||
|
const fakeStore = val => ({
|
||||||
|
subscribe: cb => {
|
||||||
|
cb(val);
|
||||||
|
return {
|
||||||
|
unsubscribe: () => {
|
||||||
|
subscribeCalled = true;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
foo: fakeStore(1),
|
||||||
|
},
|
||||||
|
html: `
|
||||||
|
<h1>1</h1>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target }) {
|
||||||
|
component.foo = fakeStore(5);
|
||||||
|
|
||||||
|
return assert.htmlEqual(target.innerHTML, `<h1>5</h1>`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
export let foo = writable(0);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{$foo}</h1>
|
Loading…
Reference in new issue