Skip to content

Commit ca0e5df

Browse files
committed
update parser and js tests
1 parent be0a3aa commit ca0e5df

File tree

46 files changed

+312
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+312
-58
lines changed

test/hydration/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let compileOptions = null;
1414

1515
const sveltePath = process.cwd();
1616

17-
describe.only('hydration', () => {
17+
describe('hydration', () => {
1818
before(() => {
1919
const svelte = loadSvelte();
2020

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<script>
2+
export let w;
3+
export let h;
4+
</script>
5+
16
<div bind:offsetWidth={w} bind:offsetHeight={h}>
27
some content
38
</div>

test/js/samples/debug-empty/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function create_fragment(ctx) {
1414
text2 = createText("!");
1515
text3 = createText("\n");
1616
debugger;
17-
addLoc(h1, file, 0, 0, 0);
17+
addLoc(h1, file, 4, 0, 38);
1818
},
1919

2020
l: function claim(nodes) {
+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
<script>
2+
export let name;
3+
</script>
4+
15
<h1>Hello {name}!</h1>
26
{@debug}

test/js/samples/debug-foo-bar-baz-things/expected.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function get_each_context(ctx, list, i) {
99
return child_ctx;
1010
}
1111

12-
// (1:0) {#each things as thing}
12+
// (8:0) {#each things as thing}
1313
function create_each_block(ctx) {
1414
var span, text0_value = ctx.thing.name, text0, text1;
1515

@@ -24,7 +24,7 @@ function create_each_block(ctx) {
2424
console.log({ foo, bar, baz, thing });
2525
debugger;
2626
}
27-
addLoc(span, file, 1, 1, 25);
27+
addLoc(span, file, 8, 1, 116);
2828
},
2929

3030
m: function mount(target, anchor) {
@@ -75,7 +75,7 @@ function create_fragment(ctx) {
7575
p = createElement("p");
7676
text1 = createText("foo: ");
7777
text2 = createText(ctx.foo);
78-
addLoc(p, file, 5, 0, 91);
78+
addLoc(p, file, 12, 0, 182);
7979
},
8080

8181
l: function claim(nodes) {

test/js/samples/debug-foo-bar-baz-things/input.svelte

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<script>
2+
export let things;
3+
export let foo;
4+
export let bar;
5+
export let baz;
6+
</script>
7+
18
{#each things as thing}
29
<span>{thing.name}</span>
310
{@debug foo, bar, baz, thing}

test/js/samples/debug-foo/expected.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function get_each_context(ctx, list, i) {
99
return child_ctx;
1010
}
1111

12-
// (1:0) {#each things as thing}
12+
// (6:0) {#each things as thing}
1313
function create_each_block(ctx) {
1414
var span, text0_value = ctx.thing.name, text0, text1;
1515

@@ -24,7 +24,7 @@ function create_each_block(ctx) {
2424
console.log({ foo });
2525
debugger;
2626
}
27-
addLoc(span, file, 1, 1, 25);
27+
addLoc(span, file, 6, 1, 82);
2828
},
2929

3030
m: function mount(target, anchor) {
@@ -75,7 +75,7 @@ function create_fragment(ctx) {
7575
p = createElement("p");
7676
text1 = createText("foo: ");
7777
text2 = createText(ctx.foo);
78-
addLoc(p, file, 5, 0, 74);
78+
addLoc(p, file, 10, 0, 131);
7979
},
8080

8181
l: function claim(nodes) {

test/js/samples/debug-foo/input.svelte

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<script>
2+
export let things;
3+
export let foo;
4+
</script>
5+
16
{#each things as thing}
27
<span>{thing.name}</span>
38
{@debug foo}

test/js/samples/debug-ssr-foo/expected.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { create_ssr_component, debug, each, escape } from "svelte/internal";
44
const SvelteComponent = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
55
let { things, foo } = $$props;
66

7+
if ($$props.things === void 0 && $$bindings.things && things !== void 0) $$bindings.things(things);
8+
if ($$props.foo === void 0 && $$bindings.foo && foo !== void 0) $$bindings.foo(foo);
9+
710
return `${each(things, (thing) => `<span>${escape(thing.name)}</span>
8-
${debug(null, 2, 2, { foo })}`)}
11+
${debug(null, 7, 2, { foo })}`)}
912
1013
<p>foo: ${escape(foo)}</p>`;
1114
});

test/js/samples/debug-ssr-foo/input.svelte

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<script>
2+
export let things;
3+
export let foo;
4+
</script>
5+
16
{#each things as thing}
27
<span>{thing.name}</span>
38
{@debug foo}

test/js/samples/deconflict-builtins/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
77
return child_ctx;
88
}
99

10-
// (1:0) {#each createElement as node}
10+
// (5:0) {#each createElement as node}
1111
function create_each_block(ctx) {
1212
var span, text_value = ctx.node, text;
1313

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let createElement;
3+
</script>
4+
15
{#each createElement as node}
26
<span>{node}</span>
37
{/each}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
<script>
2+
export let bar;
3+
</script>
4+
15
<div data-foo='bar'/>
26
<div data-foo='{bar}'/>

test/js/samples/dont-invalidate-this/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ class SvelteComponent extends SvelteComponent_1 {
3939
}
4040
}
4141

42-
export default SvelteComponent;
42+
export default SvelteComponent;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
<script>
2+
export let bar;
3+
</script>
4+
15
<div data-foo='bar'/>
26
<div data-foo='{bar}'/>

test/js/samples/dont-use-dataset-in-svg/input.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let bar;
3+
</script>
4+
15
<svg>
26
<g data-foo='bar'/>
37
<g data-foo='{bar}'/>

test/js/samples/each-block-array-literal/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
77
return child_ctx;
88
}
99

10-
// (1:0) {#each [a, b, c, d, e] as num}
10+
// (9:0) {#each [a, b, c, d, e] as num}
1111
function create_each_block(ctx) {
1212
var span, text_value = ctx.num, text;
1313

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<script>
2+
export let a;
3+
export let b;
4+
export let c;
5+
export let d;
6+
export let e;
7+
</script>
8+
19
{#each [a, b, c, d, e] as num}
210
<span>{num}</span>
311
{/each}

test/js/samples/each-block-changed-check/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function get_each_context(ctx, list, i) {
88
return child_ctx;
99
}
1010

11-
// (1:0) {#each comments as comment, i}
11+
// (8:0) {#each comments as comment, i}
1212
function create_each_block(ctx) {
1313
var div, strong, text0, text1, span, text2_value = ctx.comment.author, text2, text3, text4_value = ctx.elapsed(ctx.comment.time, ctx.time), text4, text5, text6, raw_value = ctx.comment.html, raw_before;
1414

test/js/samples/each-block-changed-check/input.svelte

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<script>
2+
export let comments;
3+
export let elapsed;
4+
export let time;
5+
export let foo;
6+
</script>
7+
18
{#each comments as comment, i}
29
<div class='comment'>
310
<strong>{i}</strong>

test/js/samples/each-block-keyed/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
77
return child_ctx;
88
}
99

10-
// (1:0) {#each things as thing (thing.id)}
10+
// (5:0) {#each things as thing (thing.id)}
1111
function create_each_block(key_1, ctx) {
1212
var div, text_value = ctx.thing.name, text;
1313

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let things;
3+
</script>
4+
15
{#each things as thing (thing.id)}
26
<div>{thing.name}</div>
37
{/each}

test/js/samples/if-block-no-update/expected.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* generated by Svelte vX.Y.Z */
22
import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal";
33

4-
// (3:0) {:else}
4+
// (7:0) {:else}
55
function create_else_block(ctx) {
66
var p;
77

@@ -23,7 +23,7 @@ function create_else_block(ctx) {
2323
};
2424
}
2525

26-
// (1:0) {#if foo}
26+
// (5:0) {#if foo}
2727
function create_if_block(ctx) {
2828
var p;
2929

test/js/samples/if-block-no-update/input.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let foo;
3+
</script>
4+
15
{#if foo}
26
<p>foo!</p>
37
{:else}

test/js/samples/if-block-simple/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* generated by Svelte vX.Y.Z */
22
import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal";
33

4-
// (1:0) {#if foo}
4+
// (5:0) {#if foo}
55
function create_if_block(ctx) {
66
var p;
77

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let foo;
3+
</script>
4+
15
{#if foo}
26
<p>foo!</p>
37
{/if}
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
<script>
2+
export let color;
3+
export let x;
4+
export let y;
5+
</script>
6+
17
<div style='color: {color}; transform: translate({x}px,{y}px);'></div>
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<script>
2+
export let data;
3+
</script>
4+
15
<div style='background: url(data:image/png;base64,{data})'></div>
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<script>
2+
export let color;
3+
</script>
4+
15
<div style='color: {color}'></div>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
<div style='{style}'></div>
2-
<div style='{key}: {value}'></div>
1+
<script>
2+
export let style;
3+
export let key;
4+
export let value;
5+
</script>
6+
7+
<div style={style}></div>
8+
<div style="{key}: {value}"></div>
+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<script>
2+
export let files;
3+
</script>
4+
15
<input type="file" multiple bind:files>
+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<script>
2+
export let value;
3+
</script>
4+
15
<input type=range bind:value>
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<script>
2+
export let foo;
3+
</script>
4+
15
<input type='checkbox' bind:checked={foo}>
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
<script>
2+
export let buffered;
3+
export let seekable;
4+
export let played;
5+
export let currentTime;
6+
export let duration;
7+
export let paused;
8+
export let volume;
9+
</script>
10+
111
<audio bind:buffered bind:seekable bind:played bind:currentTime bind:duration bind:paused bind:volume/>

test/js/samples/reactive-values-non-writable-dependencies/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let a = 1;
1717
let b = 2;
1818

1919
function instance($$self, $$props, $$invalidate) {
20-
20+
2121

2222
let max;
2323

test/js/samples/select-dynamic-value/input.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let current;
3+
</script>
4+
15
<select value={current}>
26
<option value="1">1</option>
37
<option value="2">2</option>

test/js/samples/title/input.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
export let custom;
3+
</script>
4+
15
<svelte:head>
26
<title>a {custom} title</title>
37
</svelte:head>

0 commit comments

Comments
 (0)