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();
describe.only('hydration', () => {
describe('hydration', () => {
before(() => {
const svelte = loadSvelte();

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

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

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

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

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

@ -1,3 +1,8 @@
<script>
export let things;
export let foo;
</script>
{#each things as thing}
<span>{thing.name}</span>
{@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) => {
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>
${debug(null, 2, 2, { foo })}`)}
${debug(null, 7, 2, { foo })}`)}
<p>foo: ${escape(foo)}</p>`;
});

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

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

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

@ -1,2 +1,6 @@
<script>
export let bar;
</script>
<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}'/>

@ -1,3 +1,7 @@
<script>
export let bar;
</script>
<svg>
<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;
}
// (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) {
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}
<span>{num}</span>
{/each}

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

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

@ -7,7 +7,7 @@ function get_each_context(ctx, list, i) {
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) {
var div, text_value = ctx.thing.name, text;

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

@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */
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) {
var p;
@ -23,7 +23,7 @@ function create_else_block(ctx) {
};
}
// (1:0) {#if foo}
// (5:0) {#if foo}
function create_if_block(ctx) {
var p;

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

@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */
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) {
var p;

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

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

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

@ -1,2 +1,8 @@
<div style='{style}'></div>
<div style='{key}: {value}'></div>
<script>
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>

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

@ -1 +1,5 @@
<script>
export let foo;
</script>
<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/>

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

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

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

@ -1,7 +1,7 @@
/* 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";
// (2:1) {#if a}
// (10:1) {#if a}
function create_if_block_4(ctx) {
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) {
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) {
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) {
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) {
var p;

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

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

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

@ -1,24 +1,30 @@
{
"html": {
"start": 0,
"end": 18,
"start": 30,
"end": 48,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 18,
"start": 28,
"end": 30,
"type": "Text",
"data": "\n\n"
},
{
"start": 30,
"end": 48,
"type": "InlineComponent",
"name": "Widget",
"attributes": [
{
"start": 8,
"end": 16,
"start": 38,
"end": 46,
"type": "Binding",
"name": "foo",
"modifiers": [],
"expression": {
"start": 13,
"end": 16,
"start": 43,
"end": 46,
"type": "Identifier",
"name": "foo"
}
@ -28,7 +34,37 @@
}
]
},
"css": null,
"instance": null,
"module": null
"instance": {
"start": 0,
"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}>

@ -1,25 +1,31 @@
{
"html": {
"start": 0,
"end": 25,
"start": 31,
"end": 56,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 25,
"start": 29,
"end": 31,
"type": "Text",
"data": "\n\n"
},
{
"start": 31,
"end": 56,
"type": "Element",
"name": "input",
"attributes": [
{
"start": 7,
"end": 24,
"start": 38,
"end": 55,
"type": "Binding",
"name": "value",
"modifiers": [],
"expression": {
"type": "Identifier",
"start": 19,
"end": 23,
"start": 50,
"end": 54,
"name": "name"
}
}
@ -28,7 +34,37 @@
}
]
},
"css": null,
"instance": null,
"module": null
"instance": {
"start": 0,
"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>

@ -1,25 +1,31 @@
{
"html": {
"start": 0,
"end": 33,
"start": 30,
"end": 63,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 33,
"start": 28,
"end": 30,
"type": "Text",
"data": "\n\n"
},
{
"start": 30,
"end": 63,
"type": "Element",
"name": "canvas",
"attributes": [
{
"start": 8,
"end": 23,
"start": 38,
"end": 53,
"type": "Binding",
"name": "this",
"modifiers": [],
"expression": {
"type": "Identifier",
"start": 19,
"end": 22,
"start": 49,
"end": 52,
"name": "foo"
}
}
@ -28,7 +34,37 @@
}
]
},
"css": null,
"instance": null,
"module": null
"instance": {
"start": 0,
"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