mirror of https://github.com/sveltejs/svelte
commit
a0127cad83
@ -1,14 +1,13 @@
|
||||
import * as acorn from 'acorn';
|
||||
import { Node } from 'acorn';
|
||||
import * as code_red from 'code-red';
|
||||
|
||||
const Parser = acorn.Parser;
|
||||
|
||||
export const parse = (source: string) => Parser.parse(source, {
|
||||
export const parse = (source: string): Node => code_red.parse(source, {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 11,
|
||||
locations: true
|
||||
});
|
||||
|
||||
export const parse_expression_at = (source: string, index: number) => Parser.parseExpressionAt(source, index, {
|
||||
export const parse_expression_at = (source: string, index: number): Node => code_red.parseExpressionAt(source, index, {
|
||||
ecmaVersion: 11,
|
||||
locations: true
|
||||
});
|
@ -0,0 +1 @@
|
||||
.foo.svelte-xyz{color:red}[class~="bar"].svelte-xyz{background:blue}
|
@ -0,0 +1,13 @@
|
||||
<div class="
|
||||
foo
|
||||
bar
|
||||
"></div>
|
||||
|
||||
<style>
|
||||
.foo {
|
||||
color: red;
|
||||
}
|
||||
[class~="bar"] {
|
||||
background: blue;
|
||||
}
|
||||
</style>
|
@ -1 +1 @@
|
||||
<div class='foo'></div>
|
||||
<div class='foo' title='bar'></div>
|
@ -0,0 +1,2 @@
|
||||
Display:
|
||||
<slot></slot>
|
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
let val;
|
||||
</script>
|
||||
|
||||
<input bind:value={val} />
|
||||
<slot {val}></slot>
|
@ -0,0 +1,30 @@
|
||||
export default {
|
||||
html: `
|
||||
<input>
|
||||
`,
|
||||
async test({ assert, target, snapshot, component, window }) {
|
||||
const input = target.querySelector('input');
|
||||
|
||||
input.value = 'a';
|
||||
await input.dispatchEvent(new window.Event('input'));
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<input>
|
||||
Display: a
|
||||
`
|
||||
);
|
||||
|
||||
input.value = 'abc';
|
||||
await input.dispatchEvent(new window.Event('input'));
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<input>
|
||||
Display: abc
|
||||
`
|
||||
);
|
||||
},
|
||||
};
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import Input from "./Input.svelte";
|
||||
import Display from "./Display.svelte";
|
||||
</script>
|
||||
|
||||
<Input let:val={foo}>
|
||||
{#if foo}
|
||||
<Display>{foo}</Display>
|
||||
{/if}
|
||||
</Input>
|
@ -0,0 +1,7 @@
|
||||
export default {
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
error: `Cannot have duplicate keys in a keyed each`
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
const array = [1, 2, 3, 1];
|
||||
</script>
|
||||
|
||||
{#each array as item (item)}
|
||||
{item}
|
||||
{/each}
|
Loading…
Reference in new issue