update parser and js tests

pull/2230/head
Richard Harris 6 years ago
parent be0a3aafbd
commit ca0e5df0d8

@ -14,7 +14,7 @@ let compileOptions = null;
const sveltePath = process.cwd(); const sveltePath = process.cwd();
describe.only('hydration', () => { describe('hydration', () => {
before(() => { before(() => {
const svelte = loadSvelte(); const svelte = loadSvelte();

@ -1,3 +1,8 @@
<script>
export let w;
export let h;
</script>
<div bind:offsetWidth={w} bind:offsetHeight={h}> <div bind:offsetWidth={w} bind:offsetHeight={h}>
some content some content
</div> </div>

@ -14,7 +14,7 @@ function create_fragment(ctx) {
text2 = createText("!"); text2 = createText("!");
text3 = createText("\n"); text3 = createText("\n");
debugger; debugger;
addLoc(h1, file, 0, 0, 0); addLoc(h1, file, 4, 0, 38);
}, },
l: function claim(nodes) { l: function claim(nodes) {

@ -1,2 +1,6 @@
<script>
export let name;
</script>
<h1>Hello {name}!</h1> <h1>Hello {name}!</h1>
{@debug} {@debug}

@ -9,7 +9,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (1:0) {#each things as thing} // (8:0) {#each things as thing}
function create_each_block(ctx) { function create_each_block(ctx) {
var span, text0_value = ctx.thing.name, text0, text1; var span, text0_value = ctx.thing.name, text0, text1;
@ -24,7 +24,7 @@ function create_each_block(ctx) {
console.log({ foo, bar, baz, thing }); console.log({ foo, bar, baz, thing });
debugger; debugger;
} }
addLoc(span, file, 1, 1, 25); addLoc(span, file, 8, 1, 116);
}, },
m: function mount(target, anchor) { m: function mount(target, anchor) {
@ -75,7 +75,7 @@ function create_fragment(ctx) {
p = createElement("p"); p = createElement("p");
text1 = createText("foo: "); text1 = createText("foo: ");
text2 = createText(ctx.foo); text2 = createText(ctx.foo);
addLoc(p, file, 5, 0, 91); addLoc(p, file, 12, 0, 182);
}, },
l: function claim(nodes) { l: function claim(nodes) {

@ -1,3 +1,10 @@
<script>
export let things;
export let foo;
export let bar;
export let baz;
</script>
{#each things as thing} {#each things as thing}
<span>{thing.name}</span> <span>{thing.name}</span>
{@debug foo, bar, baz, thing} {@debug foo, bar, baz, thing}

@ -9,7 +9,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (1:0) {#each things as thing} // (6:0) {#each things as thing}
function create_each_block(ctx) { function create_each_block(ctx) {
var span, text0_value = ctx.thing.name, text0, text1; var span, text0_value = ctx.thing.name, text0, text1;
@ -24,7 +24,7 @@ function create_each_block(ctx) {
console.log({ foo }); console.log({ foo });
debugger; debugger;
} }
addLoc(span, file, 1, 1, 25); addLoc(span, file, 6, 1, 82);
}, },
m: function mount(target, anchor) { m: function mount(target, anchor) {
@ -75,7 +75,7 @@ function create_fragment(ctx) {
p = createElement("p"); p = createElement("p");
text1 = createText("foo: "); text1 = createText("foo: ");
text2 = createText(ctx.foo); text2 = createText(ctx.foo);
addLoc(p, file, 5, 0, 74); addLoc(p, file, 10, 0, 131);
}, },
l: function claim(nodes) { l: function claim(nodes) {

@ -1,3 +1,8 @@
<script>
export let things;
export let foo;
</script>
{#each things as thing} {#each things as thing}
<span>{thing.name}</span> <span>{thing.name}</span>
{@debug foo} {@debug foo}

@ -4,8 +4,11 @@ import { create_ssr_component, debug, each, escape } from "svelte/internal";
const SvelteComponent = create_ssr_component(($$result, $$props, $$bindings, $$slots) => { const SvelteComponent = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
let { things, foo } = $$props; let { things, foo } = $$props;
if ($$props.things === void 0 && $$bindings.things && things !== void 0) $$bindings.things(things);
if ($$props.foo === void 0 && $$bindings.foo && foo !== void 0) $$bindings.foo(foo);
return `${each(things, (thing) => `<span>${escape(thing.name)}</span> return `${each(things, (thing) => `<span>${escape(thing.name)}</span>
${debug(null, 2, 2, { foo })}`)} ${debug(null, 7, 2, { foo })}`)}
<p>foo: ${escape(foo)}</p>`; <p>foo: ${escape(foo)}</p>`;
}); });

@ -1,3 +1,8 @@
<script>
export let things;
export let foo;
</script>
{#each things as thing} {#each things as thing}
<span>{thing.name}</span> <span>{thing.name}</span>
{@debug foo} {@debug foo}

@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (1:0) {#each createElement as node} // (5:0) {#each createElement as node}
function create_each_block(ctx) { function create_each_block(ctx) {
var span, text_value = ctx.node, text; var span, text_value = ctx.node, text;

@ -1,3 +1,7 @@
<script>
export let createElement;
</script>
{#each createElement as node} {#each createElement as node}
<span>{node}</span> <span>{node}</span>
{/each} {/each}

@ -1,2 +1,6 @@
<script>
export let bar;
</script>
<div data-foo='bar'/> <div data-foo='bar'/>
<div data-foo='{bar}'/> <div data-foo='{bar}'/>

@ -39,4 +39,4 @@ class SvelteComponent extends SvelteComponent_1 {
} }
} }
export default SvelteComponent; export default SvelteComponent;

@ -1,2 +1,6 @@
<script>
export let bar;
</script>
<div data-foo='bar'/> <div data-foo='bar'/>
<div data-foo='{bar}'/> <div data-foo='{bar}'/>

@ -1,3 +1,7 @@
<script>
export let bar;
</script>
<svg> <svg>
<g data-foo='bar'/> <g data-foo='bar'/>
<g data-foo='{bar}'/> <g data-foo='{bar}'/>

Before

Width:  |  Height:  |  Size: 56 B

After

Width:  |  Height:  |  Size: 93 B

@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (1:0) {#each [a, b, c, d, e] as num} // (9:0) {#each [a, b, c, d, e] as num}
function create_each_block(ctx) { function create_each_block(ctx) {
var span, text_value = ctx.num, text; var span, text_value = ctx.num, text;

@ -1,3 +1,11 @@
<script>
export let a;
export let b;
export let c;
export let d;
export let e;
</script>
{#each [a, b, c, d, e] as num} {#each [a, b, c, d, e] as num}
<span>{num}</span> <span>{num}</span>
{/each} {/each}

@ -8,7 +8,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (1:0) {#each comments as comment, i} // (8:0) {#each comments as comment, i}
function create_each_block(ctx) { function create_each_block(ctx) {
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; 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;

@ -1,3 +1,10 @@
<script>
export let comments;
export let elapsed;
export let time;
export let foo;
</script>
{#each comments as comment, i} {#each comments as comment, i}
<div class='comment'> <div class='comment'>
<strong>{i}</strong> <strong>{i}</strong>

@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (1:0) {#each things as thing (thing.id)} // (5:0) {#each things as thing (thing.id)}
function create_each_block(key_1, ctx) { function create_each_block(key_1, ctx) {
var div, text_value = ctx.thing.name, text; var div, text_value = ctx.thing.name, text;

@ -1,3 +1,7 @@
<script>
export let things;
</script>
{#each things as thing (thing.id)} {#each things as thing (thing.id)}
<div>{thing.name}</div> <div>{thing.name}</div>
{/each} {/each}

@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal";
// (3:0) {:else} // (7:0) {:else}
function create_else_block(ctx) { function create_else_block(ctx) {
var p; var p;
@ -23,7 +23,7 @@ function create_else_block(ctx) {
}; };
} }
// (1:0) {#if foo} // (5:0) {#if foo}
function create_if_block(ctx) { function create_if_block(ctx) {
var p; var p;

@ -1,3 +1,7 @@
<script>
export let foo;
</script>
{#if foo} {#if foo}
<p>foo!</p> <p>foo!</p>
{:else} {:else}

@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; import { SvelteComponent as SvelteComponent_1, createComment, createElement, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal";
// (1:0) {#if foo} // (5:0) {#if foo}
function create_if_block(ctx) { function create_if_block(ctx) {
var p; var p;

@ -1,3 +1,7 @@
<script>
export let foo;
</script>
{#if foo} {#if foo}
<p>foo!</p> <p>foo!</p>
{/if} {/if}

@ -1 +1,7 @@
<script>
export let color;
export let x;
export let y;
</script>
<div style='color: {color}; transform: translate({x}px,{y}px);'></div> <div style='color: {color}; transform: translate({x}px,{y}px);'></div>

@ -1 +1,5 @@
<script>
export let data;
</script>
<div style='background: url(data:image/png;base64,{data})'></div> <div style='background: url(data:image/png;base64,{data})'></div>

@ -1 +1,5 @@
<script>
export let color;
</script>
<div style='color: {color}'></div> <div style='color: {color}'></div>

@ -1,2 +1,8 @@
<div style='{style}'></div> <script>
<div style='{key}: {value}'></div> export let style;
export let key;
export let value;
</script>
<div style={style}></div>
<div style="{key}: {value}"></div>

@ -1 +1,5 @@
<script>
export let files;
</script>
<input type="file" multiple bind:files> <input type="file" multiple bind:files>

@ -1 +1,5 @@
<script>
export let value;
</script>
<input type=range bind:value> <input type=range bind:value>

@ -1 +1,5 @@
<script>
export let foo;
</script>
<input type='checkbox' bind:checked={foo}> <input type='checkbox' bind:checked={foo}>

@ -1 +1,11 @@
<script>
export let buffered;
export let seekable;
export let played;
export let currentTime;
export let duration;
export let paused;
export let volume;
</script>
<audio bind:buffered bind:seekable bind:played bind:currentTime bind:duration bind:paused bind:volume/> <audio bind:buffered bind:seekable bind:played bind:currentTime bind:duration bind:paused bind:volume/>

@ -17,7 +17,7 @@ let a = 1;
let b = 2; let b = 2;
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {
let max; let max;

@ -1,3 +1,7 @@
<script>
export let current;
</script>
<select value={current}> <select value={current}>
<option value="1">1</option> <option value="1">1</option>
<option value="2">2</option> <option value="2">2</option>

@ -1,3 +1,7 @@
<script>
export let custom;
</script>
<svelte:head> <svelte:head>
<title>a {custom} title</title> <title>a {custom} title</title>
</svelte:head> </svelte:head>

@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { SvelteComponent as SvelteComponent_1, append, createComment, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal"; import { SvelteComponent as SvelteComponent_1, append, createComment, createElement, createText, detachNode, flush, init, insert, noop, safe_not_equal } from "svelte/internal";
// (2:1) {#if a} // (10:1) {#if a}
function create_if_block_4(ctx) { function create_if_block_4(ctx) {
var p; var p;
@ -23,7 +23,7 @@ function create_if_block_4(ctx) {
}; };
} }
// (8:1) {#if b} // (16:1) {#if b}
function create_if_block_3(ctx) { function create_if_block_3(ctx) {
var p; var p;
@ -45,7 +45,7 @@ function create_if_block_3(ctx) {
}; };
} }
// (12:1) {#if c} // (20:1) {#if c}
function create_if_block_2(ctx) { function create_if_block_2(ctx) {
var p; var p;
@ -67,7 +67,7 @@ function create_if_block_2(ctx) {
}; };
} }
// (18:1) {#if d} // (26:1) {#if d}
function create_if_block_1(ctx) { function create_if_block_1(ctx) {
var p; var p;
@ -89,7 +89,7 @@ function create_if_block_1(ctx) {
}; };
} }
// (25:0) {#if e} // (33:0) {#if e}
function create_if_block(ctx) { function create_if_block(ctx) {
var p; var p;

@ -1,3 +1,11 @@
<script>
export let a;
export let b;
export let c;
export let d;
export let e;
</script>
<div> <div>
{#if a} {#if a}
<p>a</p> <p>a</p>

@ -1,3 +1,7 @@
<script>
export let y;
</script>
<svelte:window bind:scrollY={y}/> <svelte:window bind:scrollY={y}/>
<p>scrolled to {y}</p> <p>scrolled to {y}</p>

@ -1 +1,5 @@
<script>
let foo;
</script>
<Widget bind:foo/> <Widget bind:foo/>

@ -1,24 +1,30 @@
{ {
"html": { "html": {
"start": 0, "start": 30,
"end": 18, "end": 48,
"type": "Fragment", "type": "Fragment",
"children": [ "children": [
{ {
"start": 0, "start": 28,
"end": 18, "end": 30,
"type": "Text",
"data": "\n\n"
},
{
"start": 30,
"end": 48,
"type": "InlineComponent", "type": "InlineComponent",
"name": "Widget", "name": "Widget",
"attributes": [ "attributes": [
{ {
"start": 8, "start": 38,
"end": 16, "end": 46,
"type": "Binding", "type": "Binding",
"name": "foo", "name": "foo",
"modifiers": [], "modifiers": [],
"expression": { "expression": {
"start": 13, "start": 43,
"end": 16, "end": 46,
"type": "Identifier", "type": "Identifier",
"name": "foo" "name": "foo"
} }
@ -28,7 +34,37 @@
} }
] ]
}, },
"css": null, "instance": {
"instance": null, "start": 0,
"module": null "end": 28,
"context": "default",
"content": {
"type": "Program",
"start": 8,
"end": 19,
"body": [
{
"type": "VariableDeclaration",
"start": 10,
"end": 18,
"declarations": [
{
"type": "VariableDeclarator",
"start": 14,
"end": 17,
"id": {
"type": "Identifier",
"start": 14,
"end": 17,
"name": "foo"
},
"init": null
}
],
"kind": "let"
}
],
"sourceType": "module"
}
}
} }

@ -1 +1,5 @@
<script>
let name;
</script>
<input bind:value={name}> <input bind:value={name}>

@ -1,25 +1,31 @@
{ {
"html": { "html": {
"start": 0, "start": 31,
"end": 25, "end": 56,
"type": "Fragment", "type": "Fragment",
"children": [ "children": [
{ {
"start": 0, "start": 29,
"end": 25, "end": 31,
"type": "Text",
"data": "\n\n"
},
{
"start": 31,
"end": 56,
"type": "Element", "type": "Element",
"name": "input", "name": "input",
"attributes": [ "attributes": [
{ {
"start": 7, "start": 38,
"end": 24, "end": 55,
"type": "Binding", "type": "Binding",
"name": "value", "name": "value",
"modifiers": [], "modifiers": [],
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 19, "start": 50,
"end": 23, "end": 54,
"name": "name" "name": "name"
} }
} }
@ -28,7 +34,37 @@
} }
] ]
}, },
"css": null, "instance": {
"instance": null, "start": 0,
"module": null "end": 29,
"context": "default",
"content": {
"type": "Program",
"start": 8,
"end": 20,
"body": [
{
"type": "VariableDeclaration",
"start": 10,
"end": 19,
"declarations": [
{
"type": "VariableDeclarator",
"start": 14,
"end": 18,
"id": {
"type": "Identifier",
"start": 14,
"end": 18,
"name": "name"
},
"init": null
}
],
"kind": "let"
}
],
"sourceType": "module"
}
}
} }

@ -1 +1,5 @@
<script>
let foo;
</script>
<canvas bind:this={foo}></canvas> <canvas bind:this={foo}></canvas>

@ -1,25 +1,31 @@
{ {
"html": { "html": {
"start": 0, "start": 30,
"end": 33, "end": 63,
"type": "Fragment", "type": "Fragment",
"children": [ "children": [
{ {
"start": 0, "start": 28,
"end": 33, "end": 30,
"type": "Text",
"data": "\n\n"
},
{
"start": 30,
"end": 63,
"type": "Element", "type": "Element",
"name": "canvas", "name": "canvas",
"attributes": [ "attributes": [
{ {
"start": 8, "start": 38,
"end": 23, "end": 53,
"type": "Binding", "type": "Binding",
"name": "this", "name": "this",
"modifiers": [], "modifiers": [],
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 19, "start": 49,
"end": 22, "end": 52,
"name": "foo" "name": "foo"
} }
} }
@ -28,7 +34,37 @@
} }
] ]
}, },
"css": null, "instance": {
"instance": null, "start": 0,
"module": null "end": 28,
"context": "default",
"content": {
"type": "Program",
"start": 8,
"end": 19,
"body": [
{
"type": "VariableDeclaration",
"start": 10,
"end": 18,
"declarations": [
{
"type": "VariableDeclarator",
"start": 14,
"end": 17,
"id": {
"type": "Identifier",
"start": 14,
"end": 17,
"name": "foo"
},
"init": null
}
],
"kind": "let"
}
],
"sourceType": "module"
}
}
} }
Loading…
Cancel
Save