diff --git a/test/js/samples/hydrated-void-element/_config.js b/test/js/samples/hydrated-void-element/_config.js
index 84c0d733ef..af1bf11a52 100644
--- a/test/js/samples/hydrated-void-element/_config.js
+++ b/test/js/samples/hydrated-void-element/_config.js
@@ -2,4 +2,4 @@ export default {
options: {
hydratable: true
}
-};
\ No newline at end of file
+};
diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js
index f225c221bf..c67b33fa85 100644
--- a/test/js/samples/if-block-no-update/expected.js
+++ b/test/js/samples/if-block-no-update/expected.js
@@ -88,7 +88,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { foo } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
};
diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js
index b9fad863e2..4cdd73cddb 100644
--- a/test/js/samples/if-block-simple/expected.js
+++ b/test/js/samples/if-block-simple/expected.js
@@ -42,12 +42,12 @@ function create_fragment(ctx) {
},
p(ctx, [dirty]) {
if (/*foo*/ ctx[0]) {
- if (!if_block) {
+ if (if_block) {
+
+ } else {
if_block = create_if_block(ctx);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
- } else {
-
}
} else if (if_block) {
if_block.d(1);
@@ -66,7 +66,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { foo } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
};
diff --git a/test/js/samples/import-meta/expected.js b/test/js/samples/import-meta/expected.js
new file mode 100644
index 0000000000..ba77398321
--- /dev/null
+++ b/test/js/samples/import-meta/expected.js
@@ -0,0 +1,53 @@
+/* generated by Svelte vX.Y.Z */
+import {
+ SvelteComponent,
+ detach,
+ init,
+ insert,
+ noop,
+ safe_not_equal,
+ space,
+ text
+} from "svelte/internal";
+
+function create_fragment(ctx) {
+ let t0;
+ let t1;
+ let t2_value = import.meta.url + "";
+ let t2;
+
+ return {
+ c() {
+ t0 = text(/*url*/ ctx[0]);
+ t1 = space();
+ t2 = text(t2_value);
+ },
+ m(target, anchor) {
+ insert(target, t0, anchor);
+ insert(target, t1, anchor);
+ insert(target, t2, anchor);
+ },
+ p: noop,
+ i: noop,
+ o: noop,
+ d(detaching) {
+ if (detaching) detach(t0);
+ if (detaching) detach(t1);
+ if (detaching) detach(t2);
+ }
+ };
+}
+
+function instance($$self) {
+ const url = import.meta.url;
+ return [url];
+}
+
+class Component extends SvelteComponent {
+ constructor(options) {
+ super();
+ init(this, options, instance, create_fragment, safe_not_equal, {});
+ }
+}
+
+export default Component;
\ No newline at end of file
diff --git a/test/js/samples/import-meta/input.svelte b/test/js/samples/import-meta/input.svelte
new file mode 100644
index 0000000000..a5ce32dd77
--- /dev/null
+++ b/test/js/samples/import-meta/input.svelte
@@ -0,0 +1,6 @@
+
+
+{url}
+{import.meta.url}
diff --git a/test/js/samples/initial-context/expected.js b/test/js/samples/initial-context/expected.js
new file mode 100644
index 0000000000..592e2a709e
--- /dev/null
+++ b/test/js/samples/initial-context/expected.js
@@ -0,0 +1,59 @@
+/* generated by Svelte vX.Y.Z */
+import {
+ SvelteComponent,
+ detach,
+ element,
+ init,
+ insert,
+ listen,
+ noop,
+ safe_not_equal
+} from "svelte/internal";
+
+function create_fragment(ctx) {
+ let button;
+ let mounted;
+ let dispose;
+
+ return {
+ c() {
+ button = element("button");
+ },
+ m(target, anchor) {
+ insert(target, button, anchor);
+
+ if (!mounted) {
+ dispose = listen(button, "click", /*click_handler*/ ctx[1]);
+ mounted = true;
+ }
+ },
+ p: noop,
+ i: noop,
+ o: noop,
+ d(detaching) {
+ if (detaching) detach(button);
+ mounted = false;
+ dispose();
+ }
+ };
+}
+
+function instance($$self, $$props, $$invalidate) {
+ let foo;
+
+ function unreferenced() {
+ $$invalidate(0, foo = 1);
+ }
+
+ const click_handler = () => $$invalidate(0, foo = 2);
+ return [foo, click_handler];
+}
+
+class Component extends SvelteComponent {
+ constructor(options) {
+ super();
+ init(this, options, instance, create_fragment, safe_not_equal, {});
+ }
+}
+
+export default Component;
\ No newline at end of file
diff --git a/test/js/samples/initial-context/input.svelte b/test/js/samples/initial-context/input.svelte
new file mode 100644
index 0000000000..22ec290514
--- /dev/null
+++ b/test/js/samples/initial-context/input.svelte
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js
index 84a38abd7b..0a9d0a1e8e 100644
--- a/test/js/samples/inline-style-optimized-multiple/expected.js
+++ b/test/js/samples/inline-style-optimized-multiple/expected.js
@@ -44,7 +44,7 @@ function instance($$self, $$props, $$invalidate) {
let { x } = $$props;
let { y } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("color" in $$props) $$invalidate(0, color = $$props.color);
if ("x" in $$props) $$invalidate(1, x = $$props.x);
if ("y" in $$props) $$invalidate(2, y = $$props.y);
diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js
index 77870348a5..0debb03585 100644
--- a/test/js/samples/inline-style-optimized-url/expected.js
+++ b/test/js/samples/inline-style-optimized-url/expected.js
@@ -37,7 +37,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { data } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("data" in $$props) $$invalidate(0, data = $$props.data);
};
diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js
index 5bef284f09..b7db0f1cf3 100644
--- a/test/js/samples/inline-style-optimized/expected.js
+++ b/test/js/samples/inline-style-optimized/expected.js
@@ -37,7 +37,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { color } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("color" in $$props) $$invalidate(0, color = $$props.color);
};
diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js
index fdff685ead..0688f14b9b 100644
--- a/test/js/samples/inline-style-unoptimized/expected.js
+++ b/test/js/samples/inline-style-unoptimized/expected.js
@@ -54,7 +54,7 @@ function instance($$self, $$props, $$invalidate) {
let { key } = $$props;
let { value } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("style" in $$props) $$invalidate(0, style = $$props.style);
if ("key" in $$props) $$invalidate(1, key = $$props.key);
if ("value" in $$props) $$invalidate(2, value = $$props.value);
diff --git a/test/js/samples/input-files/expected.js b/test/js/samples/input-files/expected.js
index 2a2254fbd7..8adc7443f5 100644
--- a/test/js/samples/input-files/expected.js
+++ b/test/js/samples/input-files/expected.js
@@ -13,6 +13,7 @@ import {
function create_fragment(ctx) {
let input;
+ let mounted;
let dispose;
return {
@@ -23,13 +24,18 @@ function create_fragment(ctx) {
},
m(target, anchor) {
insert(target, input, anchor);
- dispose = listen(input, "change", /*input_change_handler*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(input, "change", /*input_change_handler*/ ctx[1]);
+ mounted = true;
+ }
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(input);
+ mounted = false;
dispose();
}
};
@@ -43,7 +49,7 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(0, files);
}
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("files" in $$props) $$invalidate(0, files = $$props.files);
};
diff --git a/test/js/samples/input-no-initial-value/expected.js b/test/js/samples/input-no-initial-value/expected.js
index d588f0bf73..3354aa3111 100644
--- a/test/js/samples/input-no-initial-value/expected.js
+++ b/test/js/samples/input-no-initial-value/expected.js
@@ -20,6 +20,7 @@ function create_fragment(ctx) {
let input;
let t0;
let button;
+ let mounted;
let dispose;
return {
@@ -39,10 +40,14 @@ function create_fragment(ctx) {
append(form, t0);
append(form, button);
- dispose = [
- listen(input, "input", /*input_input_handler*/ ctx[2]),
- listen(form, "submit", /*handleSubmit*/ ctx[1])
- ];
+ if (!mounted) {
+ dispose = [
+ listen(input, "input", /*input_input_handler*/ ctx[2]),
+ listen(form, "submit", /*handleSubmit*/ ctx[1])
+ ];
+
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*test*/ 1 && input.value !== /*test*/ ctx[0]) {
@@ -53,6 +58,7 @@ function create_fragment(ctx) {
o: noop,
d(detaching) {
if (detaching) detach(form);
+ mounted = false;
run_all(dispose);
}
};
diff --git a/test/js/samples/input-range/expected.js b/test/js/samples/input-range/expected.js
index 12dfd3e90e..a855ca3653 100644
--- a/test/js/samples/input-range/expected.js
+++ b/test/js/samples/input-range/expected.js
@@ -16,6 +16,7 @@ import {
function create_fragment(ctx) {
let input;
+ let mounted;
let dispose;
return {
@@ -27,10 +28,14 @@ function create_fragment(ctx) {
insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]);
- dispose = [
- listen(input, "change", /*input_change_input_handler*/ ctx[1]),
- listen(input, "input", /*input_change_input_handler*/ ctx[1])
- ];
+ if (!mounted) {
+ dispose = [
+ listen(input, "change", /*input_change_input_handler*/ ctx[1]),
+ listen(input, "input", /*input_change_input_handler*/ ctx[1])
+ ];
+
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*value*/ 1) {
@@ -41,6 +46,7 @@ function create_fragment(ctx) {
o: noop,
d(detaching) {
if (detaching) detach(input);
+ mounted = false;
run_all(dispose);
}
};
@@ -54,7 +60,7 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(0, value);
}
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("value" in $$props) $$invalidate(0, value = $$props.value);
};
diff --git a/test/js/samples/input-value/expected.js b/test/js/samples/input-value/expected.js
index 21c7bfc83b..781a2ae603 100644
--- a/test/js/samples/input-value/expected.js
+++ b/test/js/samples/input-value/expected.js
@@ -20,6 +20,7 @@ function create_fragment(ctx) {
let h1;
let t1;
let t2;
+ let mounted;
let dispose;
return {
@@ -37,7 +38,11 @@ function create_fragment(ctx) {
insert(target, h1, anchor);
append(h1, t1);
append(h1, t2);
- dispose = listen(input, "input", /*onInput*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(input, "input", /*onInput*/ ctx[1]);
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*name*/ 1 && input.value !== /*name*/ ctx[0]) {
@@ -52,6 +57,7 @@ function create_fragment(ctx) {
if (detaching) detach(input);
if (detaching) detach(t0);
if (detaching) detach(h1);
+ mounted = false;
dispose();
}
};
diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js
index fefe867e14..6c5b215623 100644
--- a/test/js/samples/input-without-blowback-guard/expected.js
+++ b/test/js/samples/input-without-blowback-guard/expected.js
@@ -13,6 +13,7 @@ import {
function create_fragment(ctx) {
let input;
+ let mounted;
let dispose;
return {
@@ -23,7 +24,11 @@ function create_fragment(ctx) {
m(target, anchor) {
insert(target, input, anchor);
input.checked = /*foo*/ ctx[0];
- dispose = listen(input, "change", /*input_change_handler*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(input, "change", /*input_change_handler*/ ctx[1]);
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*foo*/ 1) {
@@ -34,6 +39,7 @@ function create_fragment(ctx) {
o: noop,
d(detaching) {
if (detaching) detach(input);
+ mounted = false;
dispose();
}
};
@@ -47,7 +53,7 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(0, foo);
}
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
};
diff --git a/test/js/samples/instrumentation-script-if-no-block/expected.js b/test/js/samples/instrumentation-script-if-no-block/expected.js
index 7634481a2d..7f51c64550 100644
--- a/test/js/samples/instrumentation-script-if-no-block/expected.js
+++ b/test/js/samples/instrumentation-script-if-no-block/expected.js
@@ -20,6 +20,7 @@ function create_fragment(ctx) {
let p;
let t2;
let t3;
+ let mounted;
let dispose;
return {
@@ -37,7 +38,11 @@ function create_fragment(ctx) {
insert(target, p, anchor);
append(p, t2);
append(p, t3);
- dispose = listen(button, "click", /*foo*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(button, "click", /*foo*/ ctx[1]);
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*x*/ 1) set_data(t3, /*x*/ ctx[0]);
@@ -48,6 +53,7 @@ function create_fragment(ctx) {
if (detaching) detach(button);
if (detaching) detach(t1);
if (detaching) detach(p);
+ mounted = false;
dispose();
}
};
diff --git a/test/js/samples/instrumentation-script-x-equals-x/expected.js b/test/js/samples/instrumentation-script-x-equals-x/expected.js
index c154608cd5..ea0d65acb9 100644
--- a/test/js/samples/instrumentation-script-x-equals-x/expected.js
+++ b/test/js/samples/instrumentation-script-x-equals-x/expected.js
@@ -21,6 +21,7 @@ function create_fragment(ctx) {
let t2;
let t3_value = /*things*/ ctx[0].length + "";
let t3;
+ let mounted;
let dispose;
return {
@@ -38,7 +39,11 @@ function create_fragment(ctx) {
insert(target, p, anchor);
append(p, t2);
append(p, t3);
- dispose = listen(button, "click", /*foo*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(button, "click", /*foo*/ ctx[1]);
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*things*/ 1 && t3_value !== (t3_value = /*things*/ ctx[0].length + "")) set_data(t3, t3_value);
@@ -49,6 +54,7 @@ function create_fragment(ctx) {
if (detaching) detach(button);
if (detaching) detach(t1);
if (detaching) detach(p);
+ mounted = false;
dispose();
}
};
diff --git a/test/js/samples/instrumentation-template-if-no-block/expected.js b/test/js/samples/instrumentation-template-if-no-block/expected.js
index 77780baa99..0c2713a9cc 100644
--- a/test/js/samples/instrumentation-template-if-no-block/expected.js
+++ b/test/js/samples/instrumentation-template-if-no-block/expected.js
@@ -20,6 +20,7 @@ function create_fragment(ctx) {
let p;
let t2;
let t3;
+ let mounted;
let dispose;
return {
@@ -37,7 +38,11 @@ function create_fragment(ctx) {
insert(target, p, anchor);
append(p, t2);
append(p, t3);
- dispose = listen(button, "click", /*click_handler*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(button, "click", /*click_handler*/ ctx[1]);
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*x*/ 1) set_data(t3, /*x*/ ctx[0]);
@@ -48,6 +53,7 @@ function create_fragment(ctx) {
if (detaching) detach(button);
if (detaching) detach(t1);
if (detaching) detach(p);
+ mounted = false;
dispose();
}
};
diff --git a/test/js/samples/instrumentation-template-x-equals-x/expected.js b/test/js/samples/instrumentation-template-x-equals-x/expected.js
index 4fe45616c7..55cd310661 100644
--- a/test/js/samples/instrumentation-template-x-equals-x/expected.js
+++ b/test/js/samples/instrumentation-template-x-equals-x/expected.js
@@ -21,6 +21,7 @@ function create_fragment(ctx) {
let t2;
let t3_value = /*things*/ ctx[0].length + "";
let t3;
+ let mounted;
let dispose;
return {
@@ -38,7 +39,11 @@ function create_fragment(ctx) {
insert(target, p, anchor);
append(p, t2);
append(p, t3);
- dispose = listen(button, "click", /*click_handler*/ ctx[1]);
+
+ if (!mounted) {
+ dispose = listen(button, "click", /*click_handler*/ ctx[1]);
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*things*/ 1 && t3_value !== (t3_value = /*things*/ ctx[0].length + "")) set_data(t3, t3_value);
@@ -49,6 +54,7 @@ function create_fragment(ctx) {
if (detaching) detach(button);
if (detaching) detach(t1);
if (detaching) detach(p);
+ mounted = false;
dispose();
}
};
diff --git a/test/js/samples/legacy-input-type/_config.js b/test/js/samples/legacy-input-type/_config.js
index b5141be9ab..67924a4ffe 100644
--- a/test/js/samples/legacy-input-type/_config.js
+++ b/test/js/samples/legacy-input-type/_config.js
@@ -2,4 +2,4 @@ export default {
options: {
legacy: true
}
-};
\ No newline at end of file
+};
diff --git a/test/js/samples/loop-protect/_config.js b/test/js/samples/loop-protect/_config.js
index fcbf8be09b..1dc927b4da 100644
--- a/test/js/samples/loop-protect/_config.js
+++ b/test/js/samples/loop-protect/_config.js
@@ -1,6 +1,6 @@
export default {
options: {
dev: true,
- loopGuardTimeout: 100,
- },
+ loopGuardTimeout: 100
+ }
};
diff --git a/test/js/samples/loop-protect/expected.js b/test/js/samples/loop-protect/expected.js
index c52d9df437..1042b20823 100644
--- a/test/js/samples/loop-protect/expected.js
+++ b/test/js/samples/loop-protect/expected.js
@@ -67,6 +67,8 @@ function foo() {
}
function instance($$self, $$props, $$invalidate) {
+ let { $$slots: slots = {}, $$scope } = $$props;
+ validate_slots("Component", slots, []);
let node;
{
@@ -111,12 +113,10 @@ function instance($$self, $$props, $$invalidate) {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console_1.warn(`
was created with unknown prop '${key}'`);
});
- let { $$slots = {}, $$scope } = $$props;
- validate_slots("Component", $$slots, []);
-
function div_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
- $$invalidate(0, node = $$value);
+ node = $$value;
+ $$invalidate(0, node);
});
}
diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js
index 52fef36792..867d4a7dad 100644
--- a/test/js/samples/media-bindings/expected.js
+++ b/test/js/samples/media-bindings/expected.js
@@ -19,6 +19,7 @@ function create_fragment(ctx) {
let audio_updating = false;
let audio_animationframe;
let audio_is_paused = true;
+ let mounted;
let dispose;
function audio_timeupdate_handler() {
@@ -29,18 +30,18 @@ function create_fragment(ctx) {
audio_updating = true;
}
- /*audio_timeupdate_handler*/ ctx[12].call(audio);
+ /*audio_timeupdate_handler*/ ctx[13].call(audio);
}
return {
c() {
audio = element("audio");
- if (/*buffered*/ ctx[0] === void 0) add_render_callback(() => /*audio_progress_handler*/ ctx[10].call(audio));
- if (/*buffered*/ ctx[0] === void 0 || /*seekable*/ ctx[1] === void 0) add_render_callback(() => /*audio_loadedmetadata_handler*/ ctx[11].call(audio));
- if (/*played*/ ctx[2] === void 0 || /*currentTime*/ ctx[3] === void 0 || /*ended*/ ctx[9] === void 0) add_render_callback(audio_timeupdate_handler);
- if (/*duration*/ ctx[4] === void 0) add_render_callback(() => /*audio_durationchange_handler*/ ctx[13].call(audio));
- if (/*seeking*/ ctx[8] === void 0) add_render_callback(() => /*audio_seeking_seeked_handler*/ ctx[17].call(audio));
- if (/*ended*/ ctx[9] === void 0) add_render_callback(() => /*audio_ended_handler*/ ctx[18].call(audio));
+ if (/*buffered*/ ctx[0] === void 0) add_render_callback(() => /*audio_progress_handler*/ ctx[11].call(audio));
+ if (/*buffered*/ ctx[0] === void 0 || /*seekable*/ ctx[1] === void 0) add_render_callback(() => /*audio_loadedmetadata_handler*/ ctx[12].call(audio));
+ if (/*played*/ ctx[2] === void 0 || /*currentTime*/ ctx[3] === void 0 || /*ended*/ ctx[10] === void 0) add_render_callback(audio_timeupdate_handler);
+ if (/*duration*/ ctx[4] === void 0) add_render_callback(() => /*audio_durationchange_handler*/ ctx[14].call(audio));
+ if (/*seeking*/ ctx[9] === void 0) add_render_callback(() => /*audio_seeking_seeked_handler*/ ctx[18].call(audio));
+ if (/*ended*/ ctx[10] === void 0) add_render_callback(() => /*audio_ended_handler*/ ctx[19].call(audio));
},
m(target, anchor) {
insert(target, audio, anchor);
@@ -49,23 +50,29 @@ function create_fragment(ctx) {
audio.volume = /*volume*/ ctx[6];
}
- if (!isNaN(/*playbackRate*/ ctx[7])) {
- audio.playbackRate = /*playbackRate*/ ctx[7];
+ audio.muted = /*muted*/ ctx[7];
+
+ if (!isNaN(/*playbackRate*/ ctx[8])) {
+ audio.playbackRate = /*playbackRate*/ ctx[8];
}
- dispose = [
- listen(audio, "progress", /*audio_progress_handler*/ ctx[10]),
- listen(audio, "loadedmetadata", /*audio_loadedmetadata_handler*/ ctx[11]),
- listen(audio, "timeupdate", audio_timeupdate_handler),
- listen(audio, "durationchange", /*audio_durationchange_handler*/ ctx[13]),
- listen(audio, "play", /*audio_play_pause_handler*/ ctx[14]),
- listen(audio, "pause", /*audio_play_pause_handler*/ ctx[14]),
- listen(audio, "volumechange", /*audio_volumechange_handler*/ ctx[15]),
- listen(audio, "ratechange", /*audio_ratechange_handler*/ ctx[16]),
- listen(audio, "seeking", /*audio_seeking_seeked_handler*/ ctx[17]),
- listen(audio, "seeked", /*audio_seeking_seeked_handler*/ ctx[17]),
- listen(audio, "ended", /*audio_ended_handler*/ ctx[18])
- ];
+ if (!mounted) {
+ dispose = [
+ listen(audio, "progress", /*audio_progress_handler*/ ctx[11]),
+ listen(audio, "loadedmetadata", /*audio_loadedmetadata_handler*/ ctx[12]),
+ listen(audio, "timeupdate", audio_timeupdate_handler),
+ listen(audio, "durationchange", /*audio_durationchange_handler*/ ctx[14]),
+ listen(audio, "play", /*audio_play_pause_handler*/ ctx[15]),
+ listen(audio, "pause", /*audio_play_pause_handler*/ ctx[15]),
+ listen(audio, "volumechange", /*audio_volumechange_handler*/ ctx[16]),
+ listen(audio, "ratechange", /*audio_ratechange_handler*/ ctx[17]),
+ listen(audio, "seeking", /*audio_seeking_seeked_handler*/ ctx[18]),
+ listen(audio, "seeked", /*audio_seeking_seeked_handler*/ ctx[18]),
+ listen(audio, "ended", /*audio_ended_handler*/ ctx[19])
+ ];
+
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (!audio_updating && dirty & /*currentTime*/ 8 && !isNaN(/*currentTime*/ ctx[3])) {
@@ -82,14 +89,19 @@ function create_fragment(ctx) {
audio.volume = /*volume*/ ctx[6];
}
- if (dirty & /*playbackRate*/ 128 && !isNaN(/*playbackRate*/ ctx[7])) {
- audio.playbackRate = /*playbackRate*/ ctx[7];
+ if (dirty & /*muted*/ 128) {
+ audio.muted = /*muted*/ ctx[7];
+ }
+
+ if (dirty & /*playbackRate*/ 256 && !isNaN(/*playbackRate*/ ctx[8])) {
+ audio.playbackRate = /*playbackRate*/ ctx[8];
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(audio);
+ mounted = false;
run_all(dispose);
}
};
@@ -103,6 +115,7 @@ function instance($$self, $$props, $$invalidate) {
let { duration } = $$props;
let { paused } = $$props;
let { volume } = $$props;
+ let { muted } = $$props;
let { playbackRate } = $$props;
let { seeking } = $$props;
let { ended } = $$props;
@@ -125,7 +138,7 @@ function instance($$self, $$props, $$invalidate) {
ended = this.ended;
$$invalidate(2, played);
$$invalidate(3, currentTime);
- $$invalidate(9, ended);
+ $$invalidate(10, ended);
}
function audio_durationchange_handler() {
@@ -140,25 +153,27 @@ function instance($$self, $$props, $$invalidate) {
function audio_volumechange_handler() {
volume = this.volume;
+ muted = this.muted;
$$invalidate(6, volume);
+ $$invalidate(7, muted);
}
function audio_ratechange_handler() {
playbackRate = this.playbackRate;
- $$invalidate(7, playbackRate);
+ $$invalidate(8, playbackRate);
}
function audio_seeking_seeked_handler() {
seeking = this.seeking;
- $$invalidate(8, seeking);
+ $$invalidate(9, seeking);
}
function audio_ended_handler() {
ended = this.ended;
- $$invalidate(9, ended);
+ $$invalidate(10, ended);
}
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("buffered" in $$props) $$invalidate(0, buffered = $$props.buffered);
if ("seekable" in $$props) $$invalidate(1, seekable = $$props.seekable);
if ("played" in $$props) $$invalidate(2, played = $$props.played);
@@ -166,9 +181,10 @@ function instance($$self, $$props, $$invalidate) {
if ("duration" in $$props) $$invalidate(4, duration = $$props.duration);
if ("paused" in $$props) $$invalidate(5, paused = $$props.paused);
if ("volume" in $$props) $$invalidate(6, volume = $$props.volume);
- if ("playbackRate" in $$props) $$invalidate(7, playbackRate = $$props.playbackRate);
- if ("seeking" in $$props) $$invalidate(8, seeking = $$props.seeking);
- if ("ended" in $$props) $$invalidate(9, ended = $$props.ended);
+ if ("muted" in $$props) $$invalidate(7, muted = $$props.muted);
+ if ("playbackRate" in $$props) $$invalidate(8, playbackRate = $$props.playbackRate);
+ if ("seeking" in $$props) $$invalidate(9, seeking = $$props.seeking);
+ if ("ended" in $$props) $$invalidate(10, ended = $$props.ended);
};
return [
@@ -179,6 +195,7 @@ function instance($$self, $$props, $$invalidate) {
duration,
paused,
volume,
+ muted,
playbackRate,
seeking,
ended,
@@ -206,9 +223,10 @@ class Component extends SvelteComponent {
duration: 4,
paused: 5,
volume: 6,
- playbackRate: 7,
- seeking: 8,
- ended: 9
+ muted: 7,
+ playbackRate: 8,
+ seeking: 9,
+ ended: 10
});
}
}
diff --git a/test/js/samples/media-bindings/input.svelte b/test/js/samples/media-bindings/input.svelte
index a079a2e0e5..7c1afcf614 100644
--- a/test/js/samples/media-bindings/input.svelte
+++ b/test/js/samples/media-bindings/input.svelte
@@ -6,9 +6,10 @@
export let duration;
export let paused;
export let volume;
+ export let muted;
export let playbackRate;
export let seeking;
export let ended;
-
+
diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js
index 2784fd17ac..5a6b8e8bb7 100644
--- a/test/js/samples/non-imported-component/expected.js
+++ b/test/js/samples/non-imported-component/expected.js
@@ -17,10 +17,12 @@ import {
import Imported from "Imported.svelte";
function create_fragment(ctx) {
+ let imported;
let t;
+ let nonimported;
let current;
- const imported = new Imported({});
- const nonimported = new NonImported({});
+ imported = new Imported({});
+ nonimported = new NonImported({});
return {
c() {
diff --git a/test/js/samples/optional-chaining/expected.js b/test/js/samples/optional-chaining/expected.js
new file mode 100644
index 0000000000..8aa94796c1
--- /dev/null
+++ b/test/js/samples/optional-chaining/expected.js
@@ -0,0 +1,189 @@
+/* generated by Svelte vX.Y.Z */
+import {
+ SvelteComponent,
+ attr,
+ create_component,
+ destroy_component,
+ detach,
+ element,
+ init,
+ insert,
+ mount_component,
+ safe_not_equal,
+ set_data,
+ space,
+ text,
+ transition_in,
+ transition_out
+} from "svelte/internal";
+
+function create_fragment(ctx) {
+ let t0_value = /*a*/ ctx[0].normal + "";
+ let t0;
+ let t1_value = /*b*/ ctx[1]?.optional + "";
+ let t1;
+ let t2;
+ let t3_value = /*c*/ ctx[2]["computed"] + "";
+ let t3;
+ let t4_value = /*d*/ ctx[3]?.["computed_optional"] + "";
+ let t4;
+ let t5;
+ let t6_value = /*e*/ ctx[4]() + "";
+ let t6;
+ let t7_value = /*f*/ ctx[5]?.() + "";
+ let t7;
+ let t8;
+ let div;
+ let div_a_value;
+ let div_b_value;
+ let div_c_value;
+ let div_d_value;
+ let div_e_value;
+ let div_f_value;
+ let t9;
+ let component;
+ let current;
+
+ component = new /*Component*/ ctx[6]({
+ props: {
+ a: /*a*/ ctx[0].normal,
+ b: /*b*/ ctx[1]?.optional,
+ c: /*c*/ ctx[2]["computed"],
+ d: /*d*/ ctx[3]?.["computed_optional"],
+ e: /*e*/ ctx[4](),
+ f: /*f*/ ctx[5]?.()
+ }
+ });
+
+ return {
+ c() {
+ t0 = text(t0_value);
+ t1 = text(t1_value);
+ t2 = space();
+ t3 = text(t3_value);
+ t4 = text(t4_value);
+ t5 = space();
+ t6 = text(t6_value);
+ t7 = text(t7_value);
+ t8 = space();
+ div = element("div");
+ t9 = space();
+ create_component(component.$$.fragment);
+ attr(div, "a", div_a_value = /*a*/ ctx[0].normal);
+ attr(div, "b", div_b_value = /*b*/ ctx[1]?.optional);
+ attr(div, "c", div_c_value = /*c*/ ctx[2]["computed"]);
+ attr(div, "d", div_d_value = /*d*/ ctx[3]?.["computed_optional"]);
+ attr(div, "e", div_e_value = /*e*/ ctx[4]());
+ attr(div, "f", div_f_value = /*f*/ ctx[5]?.());
+ },
+ m(target, anchor) {
+ insert(target, t0, anchor);
+ insert(target, t1, anchor);
+ insert(target, t2, anchor);
+ insert(target, t3, anchor);
+ insert(target, t4, anchor);
+ insert(target, t5, anchor);
+ insert(target, t6, anchor);
+ insert(target, t7, anchor);
+ insert(target, t8, anchor);
+ insert(target, div, anchor);
+ insert(target, t9, anchor);
+ mount_component(component, target, anchor);
+ current = true;
+ },
+ p(ctx, [dirty]) {
+ if ((!current || dirty & /*a*/ 1) && t0_value !== (t0_value = /*a*/ ctx[0].normal + "")) set_data(t0, t0_value);
+ if ((!current || dirty & /*b*/ 2) && t1_value !== (t1_value = /*b*/ ctx[1]?.optional + "")) set_data(t1, t1_value);
+ if ((!current || dirty & /*c*/ 4) && t3_value !== (t3_value = /*c*/ ctx[2]["computed"] + "")) set_data(t3, t3_value);
+ if ((!current || dirty & /*d*/ 8) && t4_value !== (t4_value = /*d*/ ctx[3]?.["computed_optional"] + "")) set_data(t4, t4_value);
+ if ((!current || dirty & /*e*/ 16) && t6_value !== (t6_value = /*e*/ ctx[4]() + "")) set_data(t6, t6_value);
+ if ((!current || dirty & /*f*/ 32) && t7_value !== (t7_value = /*f*/ ctx[5]?.() + "")) set_data(t7, t7_value);
+
+ if (!current || dirty & /*a*/ 1 && div_a_value !== (div_a_value = /*a*/ ctx[0].normal)) {
+ attr(div, "a", div_a_value);
+ }
+
+ if (!current || dirty & /*b*/ 2 && div_b_value !== (div_b_value = /*b*/ ctx[1]?.optional)) {
+ attr(div, "b", div_b_value);
+ }
+
+ if (!current || dirty & /*c*/ 4 && div_c_value !== (div_c_value = /*c*/ ctx[2]["computed"])) {
+ attr(div, "c", div_c_value);
+ }
+
+ if (!current || dirty & /*d*/ 8 && div_d_value !== (div_d_value = /*d*/ ctx[3]?.["computed_optional"])) {
+ attr(div, "d", div_d_value);
+ }
+
+ if (!current || dirty & /*e*/ 16 && div_e_value !== (div_e_value = /*e*/ ctx[4]())) {
+ attr(div, "e", div_e_value);
+ }
+
+ if (!current || dirty & /*f*/ 32 && div_f_value !== (div_f_value = /*f*/ ctx[5]?.())) {
+ attr(div, "f", div_f_value);
+ }
+
+ const component_changes = {};
+ if (dirty & /*a*/ 1) component_changes.a = /*a*/ ctx[0].normal;
+ if (dirty & /*b*/ 2) component_changes.b = /*b*/ ctx[1]?.optional;
+ if (dirty & /*c*/ 4) component_changes.c = /*c*/ ctx[2]["computed"];
+ if (dirty & /*d*/ 8) component_changes.d = /*d*/ ctx[3]?.["computed_optional"];
+ if (dirty & /*e*/ 16) component_changes.e = /*e*/ ctx[4]();
+ if (dirty & /*f*/ 32) component_changes.f = /*f*/ ctx[5]?.();
+ component.$set(component_changes);
+ },
+ i(local) {
+ if (current) return;
+ transition_in(component.$$.fragment, local);
+ current = true;
+ },
+ o(local) {
+ transition_out(component.$$.fragment, local);
+ current = false;
+ },
+ d(detaching) {
+ if (detaching) detach(t0);
+ if (detaching) detach(t1);
+ if (detaching) detach(t2);
+ if (detaching) detach(t3);
+ if (detaching) detach(t4);
+ if (detaching) detach(t5);
+ if (detaching) detach(t6);
+ if (detaching) detach(t7);
+ if (detaching) detach(t8);
+ if (detaching) detach(div);
+ if (detaching) detach(t9);
+ destroy_component(component, detaching);
+ }
+ };
+}
+
+function instance($$self, $$props, $$invalidate) {
+ let { a } = $$props;
+ let { b } = $$props;
+ let { c } = $$props;
+ let { d } = $$props;
+ let { e } = $$props;
+ let { f } = $$props;
+ let Component;
+
+ $$self.$$set = $$props => {
+ if ("a" in $$props) $$invalidate(0, a = $$props.a);
+ if ("b" in $$props) $$invalidate(1, b = $$props.b);
+ if ("c" in $$props) $$invalidate(2, c = $$props.c);
+ if ("d" in $$props) $$invalidate(3, d = $$props.d);
+ if ("e" in $$props) $$invalidate(4, e = $$props.e);
+ if ("f" in $$props) $$invalidate(5, f = $$props.f);
+ };
+
+ return [a, b, c, d, e, f, Component];
+}
+
+class Component_1 extends SvelteComponent {
+ constructor(options) {
+ super();
+ init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5 });
+ }
+}
+
+export default Component_1;
\ No newline at end of file
diff --git a/test/js/samples/optional-chaining/input.svelte b/test/js/samples/optional-chaining/input.svelte
new file mode 100644
index 0000000000..78edf2ca85
--- /dev/null
+++ b/test/js/samples/optional-chaining/input.svelte
@@ -0,0 +1,31 @@
+
+
+{a.normal}{b?.optional}
+{c['computed']}{d?.['computed_optional']}
+{e()}{f?.()}
+
+
+
+
diff --git a/test/js/samples/reactive-values-non-topologically-ordered/expected.js b/test/js/samples/reactive-values-non-topologically-ordered/expected.js
index 3d266f10ac..15290496d5 100644
--- a/test/js/samples/reactive-values-non-topologically-ordered/expected.js
+++ b/test/js/samples/reactive-values-non-topologically-ordered/expected.js
@@ -6,7 +6,7 @@ function instance($$self, $$props, $$invalidate) {
let a;
let b;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("x" in $$props) $$invalidate(0, x = $$props.x);
};
diff --git a/test/js/samples/reactive-values-non-writable-dependencies/expected.js b/test/js/samples/reactive-values-non-writable-dependencies/expected.js
index 38bd356d85..5196a770d9 100644
--- a/test/js/samples/reactive-values-non-writable-dependencies/expected.js
+++ b/test/js/samples/reactive-values-non-writable-dependencies/expected.js
@@ -5,7 +5,7 @@ function instance($$self, $$props, $$invalidate) {
let { a = 1 } = $$props;
let { b = 2 } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("a" in $$props) $$invalidate(0, a = $$props.a);
if ("b" in $$props) $$invalidate(1, b = $$props.b);
};
diff --git a/test/js/samples/select-dynamic-value/expected.js b/test/js/samples/select-dynamic-value/expected.js
index a93a47bd3a..8777cd2600 100644
--- a/test/js/samples/select-dynamic-value/expected.js
+++ b/test/js/samples/select-dynamic-value/expected.js
@@ -7,14 +7,14 @@ import {
init,
insert,
noop,
- safe_not_equal
+ safe_not_equal,
+ select_option
} from "svelte/internal";
function create_fragment(ctx) {
let select;
let option0;
let option1;
- let select_value_value;
return {
c() {
@@ -32,27 +32,11 @@ function create_fragment(ctx) {
insert(target, select, anchor);
append(select, option0);
append(select, option1);
- select_value_value = /*current*/ ctx[0];
-
- for (var i = 0; i < select.options.length; i += 1) {
- var option = select.options[i];
-
- if (option.__value === select_value_value) {
- option.selected = true;
- break;
- }
- }
+ select_option(select, /*current*/ ctx[0]);
},
p(ctx, [dirty]) {
- if (dirty & /*current*/ 1 && select_value_value !== (select_value_value = /*current*/ ctx[0])) {
- for (var i = 0; i < select.options.length; i += 1) {
- var option = select.options[i];
-
- if (option.__value === select_value_value) {
- option.selected = true;
- break;
- }
- }
+ if (dirty & /*current*/ 1) {
+ select_option(select, /*current*/ ctx[0]);
}
},
i: noop,
@@ -66,7 +50,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { current } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("current" in $$props) $$invalidate(0, current = $$props.current);
};
diff --git a/test/js/samples/src-attribute-check/_config.js b/test/js/samples/src-attribute-check/_config.js
index 84c0d733ef..af1bf11a52 100644
--- a/test/js/samples/src-attribute-check/_config.js
+++ b/test/js/samples/src-attribute-check/_config.js
@@ -2,4 +2,4 @@ export default {
options: {
hydratable: true
}
-};
\ No newline at end of file
+};
diff --git a/test/js/samples/src-attribute-check/expected.js b/test/js/samples/src-attribute-check/expected.js
index e03b3a6ba7..93638edfb4 100644
--- a/test/js/samples/src-attribute-check/expected.js
+++ b/test/js/samples/src-attribute-check/expected.js
@@ -67,7 +67,7 @@ function instance($$self, $$props, $$invalidate) {
let { url } = $$props;
let { slug } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("url" in $$props) $$invalidate(0, url = $$props.url);
if ("slug" in $$props) $$invalidate(1, slug = $$props.slug);
};
diff --git a/test/js/samples/ssr-no-oncreate-etc/_config.js b/test/js/samples/ssr-no-oncreate-etc/_config.js
index 803712adec..bee4ab630c 100644
--- a/test/js/samples/ssr-no-oncreate-etc/_config.js
+++ b/test/js/samples/ssr-no-oncreate-etc/_config.js
@@ -2,4 +2,4 @@ export default {
options: {
generate: 'ssr'
}
-};
\ No newline at end of file
+};
diff --git a/test/js/samples/ssr-no-oncreate-etc/expected.js b/test/js/samples/ssr-no-oncreate-etc/expected.js
index 803f06a882..b91deb3e97 100644
--- a/test/js/samples/ssr-no-oncreate-etc/expected.js
+++ b/test/js/samples/ssr-no-oncreate-etc/expected.js
@@ -15,7 +15,7 @@ function swipe(node, callback) {
} // TODO implement
-const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
+const Component = create_ssr_component(($$result, $$props, $$bindings, slots) => {
onMount(() => {
console.log("onMount");
});
diff --git a/test/js/samples/ssr-preserve-comments/expected.js b/test/js/samples/ssr-preserve-comments/expected.js
index 1dc12710c0..de9fa7582e 100644
--- a/test/js/samples/ssr-preserve-comments/expected.js
+++ b/test/js/samples/ssr-preserve-comments/expected.js
@@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */
import { create_ssr_component } from "svelte/internal";
-const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
+const Component = create_ssr_component(($$result, $$props, $$bindings, slots) => {
return `content
more content
`;
diff --git a/test/js/samples/title/expected.js b/test/js/samples/title/expected.js
index d4e7e1a584..b10f569759 100644
--- a/test/js/samples/title/expected.js
+++ b/test/js/samples/title/expected.js
@@ -22,7 +22,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { custom } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("custom" in $$props) $$invalidate(0, custom = $$props.custom);
};
diff --git a/test/js/samples/transition-local/expected.js b/test/js/samples/transition-local/expected.js
index a5d3b6318f..ea3d9db3d7 100644
--- a/test/js/samples/transition-local/expected.js
+++ b/test/js/samples/transition-local/expected.js
@@ -28,13 +28,15 @@ function create_if_block(ctx) {
},
p(ctx, dirty) {
if (/*y*/ ctx[1]) {
- if (!if_block) {
+ if (if_block) {
+ if (dirty & /*y*/ 2) {
+ transition_in(if_block, 1);
+ }
+ } else {
if_block = create_if_block_1(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
- } else {
- transition_in(if_block, 1);
}
} else if (if_block) {
if_block.d(1);
@@ -122,7 +124,7 @@ function instance($$self, $$props, $$invalidate) {
let { x } = $$props;
let { y } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("x" in $$props) $$invalidate(0, x = $$props.x);
if ("y" in $$props) $$invalidate(1, y = $$props.y);
};
diff --git a/test/js/samples/transition-repeated-outro/expected.js b/test/js/samples/transition-repeated-outro/expected.js
index 6f071328a4..12483ab91a 100644
--- a/test/js/samples/transition-repeated-outro/expected.js
+++ b/test/js/samples/transition-repeated-outro/expected.js
@@ -63,13 +63,15 @@ function create_fragment(ctx) {
},
p(ctx, [dirty]) {
if (/*num*/ ctx[0] < 5) {
- if (!if_block) {
+ if (if_block) {
+ if (dirty & /*num*/ 1) {
+ transition_in(if_block, 1);
+ }
+ } else {
if_block = create_if_block(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
- } else {
- transition_in(if_block, 1);
}
} else if (if_block) {
group_outros();
@@ -100,7 +102,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { num = 1 } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("num" in $$props) $$invalidate(0, num = $$props.num);
};
diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js
index 52635e9b78..d07411518e 100644
--- a/test/js/samples/use-elements-as-anchors/expected.js
+++ b/test/js/samples/use-elements-as-anchors/expected.js
@@ -157,12 +157,12 @@ function create_fragment(ctx) {
},
p(ctx, [dirty]) {
if (/*a*/ ctx[0]) {
- if (!if_block0) {
+ if (if_block0) {
+
+ } else {
if_block0 = create_if_block_4(ctx);
if_block0.c();
if_block0.m(div, t0);
- } else {
-
}
} else if (if_block0) {
if_block0.d(1);
@@ -170,12 +170,12 @@ function create_fragment(ctx) {
}
if (/*b*/ ctx[1]) {
- if (!if_block1) {
+ if (if_block1) {
+
+ } else {
if_block1 = create_if_block_3(ctx);
if_block1.c();
if_block1.m(div, t3);
- } else {
-
}
} else if (if_block1) {
if_block1.d(1);
@@ -183,12 +183,12 @@ function create_fragment(ctx) {
}
if (/*c*/ ctx[2]) {
- if (!if_block2) {
+ if (if_block2) {
+
+ } else {
if_block2 = create_if_block_2(ctx);
if_block2.c();
if_block2.m(div, t4);
- } else {
-
}
} else if (if_block2) {
if_block2.d(1);
@@ -196,12 +196,12 @@ function create_fragment(ctx) {
}
if (/*d*/ ctx[3]) {
- if (!if_block3) {
+ if (if_block3) {
+
+ } else {
if_block3 = create_if_block_1(ctx);
if_block3.c();
if_block3.m(div, null);
- } else {
-
}
} else if (if_block3) {
if_block3.d(1);
@@ -209,12 +209,12 @@ function create_fragment(ctx) {
}
if (/*e*/ ctx[4]) {
- if (!if_block4) {
+ if (if_block4) {
+
+ } else {
if_block4 = create_if_block(ctx);
if_block4.c();
if_block4.m(if_block4_anchor.parentNode, if_block4_anchor);
- } else {
-
}
} else if (if_block4) {
if_block4.d(1);
@@ -243,7 +243,7 @@ function instance($$self, $$props, $$invalidate) {
let { d } = $$props;
let { e } = $$props;
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("a" in $$props) $$invalidate(0, a = $$props.a);
if ("b" in $$props) $$invalidate(1, b = $$props.b);
if ("c" in $$props) $$invalidate(2, c = $$props.c);
diff --git a/test/js/samples/valid-inner-html-for-static-element/expected.js b/test/js/samples/valid-inner-html-for-static-element/expected.js
new file mode 100644
index 0000000000..f1ced27ba4
--- /dev/null
+++ b/test/js/samples/valid-inner-html-for-static-element/expected.js
@@ -0,0 +1,39 @@
+/* generated by Svelte vX.Y.Z */
+import {
+ SvelteComponent,
+ detach,
+ element,
+ init,
+ insert,
+ noop,
+ safe_not_equal
+} from "svelte/internal";
+
+function create_fragment(ctx) {
+ let div;
+
+ return {
+ c() {
+ div = element("div");
+ div.innerHTML = ` `;
+ },
+ m(target, anchor) {
+ insert(target, div, anchor);
+ },
+ p: noop,
+ i: noop,
+ o: noop,
+ d(detaching) {
+ if (detaching) detach(div);
+ }
+ };
+}
+
+class Component extends SvelteComponent {
+ constructor(options) {
+ super();
+ init(this, options, null, create_fragment, safe_not_equal, {});
+ }
+}
+
+export default Component;
\ No newline at end of file
diff --git a/test/js/samples/valid-inner-html-for-static-element/input.svelte b/test/js/samples/valid-inner-html-for-static-element/input.svelte
new file mode 100644
index 0000000000..3990b2a0c2
--- /dev/null
+++ b/test/js/samples/valid-inner-html-for-static-element/input.svelte
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/test/js/samples/video-bindings/expected.js b/test/js/samples/video-bindings/expected.js
index c8cd1d84ce..8afa670bbb 100644
--- a/test/js/samples/video-bindings/expected.js
+++ b/test/js/samples/video-bindings/expected.js
@@ -19,6 +19,7 @@ function create_fragment(ctx) {
let video_updating = false;
let video_animationframe;
let video_resize_listener;
+ let mounted;
let dispose;
function video_timeupdate_handler() {
@@ -42,10 +43,14 @@ function create_fragment(ctx) {
insert(target, video, anchor);
video_resize_listener = add_resize_listener(video, /*video_elementresize_handler*/ ctx[6].bind(video));
- dispose = [
- listen(video, "timeupdate", video_timeupdate_handler),
- listen(video, "resize", /*video_resize_handler*/ ctx[5])
- ];
+ if (!mounted) {
+ dispose = [
+ listen(video, "timeupdate", video_timeupdate_handler),
+ listen(video, "resize", /*video_resize_handler*/ ctx[5])
+ ];
+
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (!video_updating && dirty & /*currentTime*/ 1 && !isNaN(/*currentTime*/ ctx[0])) {
@@ -58,7 +63,8 @@ function create_fragment(ctx) {
o: noop,
d(detaching) {
if (detaching) detach(video);
- video_resize_listener.cancel();
+ video_resize_listener();
+ mounted = false;
run_all(dispose);
}
};
@@ -87,7 +93,7 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(3, offsetWidth);
}
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("currentTime" in $$props) $$invalidate(0, currentTime = $$props.currentTime);
if ("videoHeight" in $$props) $$invalidate(1, videoHeight = $$props.videoHeight);
if ("videoWidth" in $$props) $$invalidate(2, videoWidth = $$props.videoWidth);
diff --git a/test/js/samples/window-binding-online/expected.js b/test/js/samples/window-binding-online/expected.js
index e129e66d71..887195bce1 100644
--- a/test/js/samples/window-binding-online/expected.js
+++ b/test/js/samples/window-binding-online/expected.js
@@ -10,21 +10,27 @@ import {
} from "svelte/internal";
function create_fragment(ctx) {
+ let mounted;
let dispose;
add_render_callback(/*onlinestatuschanged*/ ctx[1]);
return {
c: noop,
m(target, anchor) {
- dispose = [
- listen(window, "online", /*onlinestatuschanged*/ ctx[1]),
- listen(window, "offline", /*onlinestatuschanged*/ ctx[1])
- ];
+ if (!mounted) {
+ dispose = [
+ listen(window, "online", /*onlinestatuschanged*/ ctx[1]),
+ listen(window, "offline", /*onlinestatuschanged*/ ctx[1])
+ ];
+
+ mounted = true;
+ }
},
p: noop,
i: noop,
o: noop,
d(detaching) {
+ mounted = false;
run_all(dispose);
}
};
diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js
index 70c39eedd2..09a4d3737d 100644
--- a/test/js/samples/window-binding-scroll/expected.js
+++ b/test/js/samples/window-binding-scroll/expected.js
@@ -25,6 +25,7 @@ function create_fragment(ctx) {
let p;
let t0;
let t1;
+ let mounted;
let dispose;
add_render_callback(/*onwindowscroll*/ ctx[1]);
@@ -39,12 +40,16 @@ function create_fragment(ctx) {
append(p, t0);
append(p, t1);
- dispose = listen(window, "scroll", () => {
- scrolling = true;
- clearTimeout(scrolling_timeout);
- scrolling_timeout = setTimeout(clear_scrolling, 100);
- /*onwindowscroll*/ ctx[1]();
- });
+ if (!mounted) {
+ dispose = listen(window, "scroll", () => {
+ scrolling = true;
+ clearTimeout(scrolling_timeout);
+ scrolling_timeout = setTimeout(clear_scrolling, 100);
+ /*onwindowscroll*/ ctx[1]();
+ });
+
+ mounted = true;
+ }
},
p(ctx, [dirty]) {
if (dirty & /*y*/ 1 && !scrolling) {
@@ -60,6 +65,7 @@ function create_fragment(ctx) {
o: noop,
d(detaching) {
if (detaching) detach(p);
+ mounted = false;
dispose();
}
};
@@ -72,7 +78,7 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(0, y = window.pageYOffset)
}
- $$self.$set = $$props => {
+ $$self.$$set = $$props => {
if ("y" in $$props) $$invalidate(0, y = $$props.y);
};
diff --git a/test/js/update.js b/test/js/update.js
index fa9c834182..3e968f0e4c 100644
--- a/test/js/update.js
+++ b/test/js/update.js
@@ -1,13 +1,13 @@
// this file will replace all the expected.js files with their _actual
// equivalents. Only use it when you're sure that you haven't
// broken anything!
-const fs = require("fs");
-const glob = require("tiny-glob/sync.js");
+const fs = require('fs');
+const glob = require('tiny-glob/sync.js');
-glob("samples/*/_actual.js", { cwd: __dirname }).forEach(file => {
- const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8");
+glob('samples/*/_actual.js', { cwd: __dirname }).forEach(file => {
+ const actual = fs.readFileSync(`${__dirname}/${file}`, 'utf-8');
fs.writeFileSync(
- `${__dirname}/${file.replace("_actual.js", "expected.js")}`,
+ `${__dirname}/${file.replace('_actual.js', 'expected.js')}`,
actual
);
});
diff --git a/test/motion/index.js b/test/motion/index.ts
similarity index 75%
rename from test/motion/index.js
rename to test/motion/index.ts
index 33489b18e1..ec58c6df36 100644
--- a/test/motion/index.js
+++ b/test/motion/index.ts
@@ -19,5 +19,12 @@ describe('motion', () => {
size.set(100);
assert.equal(get(size), 100);
});
+
+ it('sets immediately when duration is 0', () => {
+ const size = tweened(0);
+
+ size.set(100, { duration : 0 });
+ assert.equal(get(size), 100);
+ });
});
});
diff --git a/test/parser/index.js b/test/parser/index.ts
similarity index 76%
rename from test/parser/index.js
rename to test/parser/index.ts
index 27c5ec1563..fe48737c96 100644
--- a/test/parser/index.js
+++ b/test/parser/index.ts
@@ -1,6 +1,6 @@
import * as assert from 'assert';
import * as fs from 'fs';
-import { svelte, tryToLoadJson, shouldUpdateExpected } from '../helpers.js';
+import { svelte, tryToLoadJson } from '../helpers';
describe('parse', () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
@@ -20,7 +20,7 @@ describe('parse', () => {
(skip ? it.skip : solo ? it.only : it)(dir, () => {
const options = tryToLoadJson(`${__dirname}/samples/${dir}/options.json`) || {};
- const input = fs.readFileSync(`${__dirname}/samples/${dir}/input.svelte`, 'utf-8').replace(/\s+$/, '');
+ const input = fs.readFileSync(`${__dirname}/samples/${dir}/input.svelte`, 'utf-8').replace(/\s+$/, '').replace(/\r/g, '');
const expectedOutput = tryToLoadJson(`${__dirname}/samples/${dir}/output.json`);
const expectedError = tryToLoadJson(`${__dirname}/samples/${dir}/error.json`);
@@ -38,13 +38,9 @@ describe('parse', () => {
} catch (err) {
if (err.name !== 'ParseError') throw err;
if (!expectedError) throw err;
-
+ const { code, message, pos, start } = err;
try {
- assert.equal(err.code, expectedError.code);
- assert.equal(err.message, expectedError.message);
- assert.deepEqual(err.start, expectedError.start);
- assert.equal(err.pos, expectedError.pos);
- assert.equal(err.toString().split('\n')[0], `${expectedError.message} (${expectedError.start.line}:${expectedError.start.column})`);
+ assert.deepEqual({ code, message, pos, start }, expectedError);
} catch (err2) {
const e = err2.code === 'MODULE_NOT_FOUND' ? err : err2;
throw e;
diff --git a/test/parser/samples/action-with-call/output.json b/test/parser/samples/action-with-call/output.json
index ccb4011c67..66c569dc5a 100644
--- a/test/parser/samples/action-with-call/output.json
+++ b/test/parser/samples/action-with-call/output.json
@@ -64,7 +64,8 @@
"value": "tooltip msg",
"raw": "'tooltip msg'"
}
- ]
+ ],
+ "optional": false
}
}
],
diff --git a/test/parser/samples/animation/output.json b/test/parser/samples/animation/output.json
index 1958ba2817..11195009c8 100644
--- a/test/parser/samples/animation/output.json
+++ b/test/parser/samples/animation/output.json
@@ -52,10 +52,10 @@
}
],
"context": {
- "start": 17,
- "end": 22,
"type": "Identifier",
- "name": "thing"
+ "name": "thing",
+ "start": 17,
+ "end": 22
},
"key": {
"type": "Identifier",
diff --git a/test/parser/samples/await-catch/output.json b/test/parser/samples/await-catch/output.json
index 2461f467f2..91862b5366 100644
--- a/test/parser/samples/await-catch/output.json
+++ b/test/parser/samples/await-catch/output.json
@@ -25,7 +25,12 @@
"name": "thePromise"
},
"value": null,
- "error": "theError",
+ "error": {
+ "type": "Identifier",
+ "name": "theError",
+ "start": 47,
+ "end": 55
+ },
"pending": {
"start": 19,
"end": 39,
@@ -147,7 +152,8 @@
},
"name": "message"
},
- "computed": false
+ "computed": false,
+ "optional": false
}
}
]
diff --git a/test/parser/samples/await-then-catch/output.json b/test/parser/samples/await-then-catch/output.json
index d9defb6932..e377d3fa3e 100644
--- a/test/parser/samples/await-then-catch/output.json
+++ b/test/parser/samples/await-then-catch/output.json
@@ -24,8 +24,18 @@
},
"name": "thePromise"
},
- "value": "theValue",
- "error": "theError",
+ "value": {
+ "type": "Identifier",
+ "name": "theValue",
+ "start": 46,
+ "end": 54
+ },
+ "error": {
+ "type": "Identifier",
+ "name": "theError",
+ "start": 96,
+ "end": 104
+ },
"pending": {
"start": 19,
"end": 39,
@@ -199,7 +209,8 @@
},
"name": "message"
},
- "computed": false
+ "computed": false,
+ "optional": false
}
}
]
diff --git a/test/parser/samples/dynamic-import/output.json b/test/parser/samples/dynamic-import/output.json
index 1e41252afa..ed3d58782d 100644
--- a/test/parser/samples/dynamic-import/output.json
+++ b/test/parser/samples/dynamic-import/output.json
@@ -275,7 +275,8 @@
},
"name": "then"
},
- "computed": false
+ "computed": false,
+ "optional": false
},
"arguments": [
{
@@ -403,7 +404,8 @@
},
"name": "log"
},
- "computed": false
+ "computed": false,
+ "optional": false
},
"arguments": [
{
@@ -452,21 +454,25 @@
},
"name": "default"
},
- "computed": false
+ "computed": false,
+ "optional": false
}
- ]
+ ],
+ "optional": false
}
}
]
}
}
- ]
+ ],
+ "optional": false
}
}
]
}
}
- ]
+ ],
+ "optional": false
}
}
],
diff --git a/test/parser/samples/each-block-destructured/input.svelte b/test/parser/samples/each-block-destructured/input.svelte
index 09e9885be0..5313050fa0 100644
--- a/test/parser/samples/each-block-destructured/input.svelte
+++ b/test/parser/samples/each-block-destructured/input.svelte
@@ -1,3 +1,7 @@
+
+
{#each animals as [key, value, ...rest]}
{key}: {value}
{/each}
diff --git a/test/parser/samples/each-block-destructured/output.json b/test/parser/samples/each-block-destructured/output.json
index 425c609a2c..69e165c0a4 100644
--- a/test/parser/samples/each-block-destructured/output.json
+++ b/test/parser/samples/each-block-destructured/output.json
@@ -1,24 +1,31 @@
{
"html": {
- "start": 0,
- "end": 71,
+ "start": 41,
+ "end": 112,
"type": "Fragment",
"children": [
{
- "start": 0,
- "end": 71,
+ "start": 39,
+ "end": 41,
+ "type": "Text",
+ "raw": "\n\n",
+ "data": "\n\n"
+ },
+ {
+ "start": 41,
+ "end": 112,
"type": "EachBlock",
"expression": {
"type": "Identifier",
- "start": 7,
- "end": 14,
+ "start": 48,
+ "end": 55,
"loc": {
"start": {
- "line": 1,
+ "line": 5,
"column": 7
},
"end": {
- "line": 1,
+ "line": 5,
"column": 14
}
},
@@ -26,27 +33,27 @@
},
"children": [
{
- "start": 42,
- "end": 63,
+ "start": 83,
+ "end": 104,
"type": "Element",
"name": "p",
"attributes": [],
"children": [
{
- "start": 45,
- "end": 50,
+ "start": 86,
+ "end": 91,
"type": "MustacheTag",
"expression": {
"type": "Identifier",
- "start": 46,
- "end": 49,
+ "start": 87,
+ "end": 90,
"loc": {
"start": {
- "line": 2,
+ "line": 6,
"column": 5
},
"end": {
- "line": 2,
+ "line": 6,
"column": 8
}
},
@@ -54,27 +61,27 @@
}
},
{
- "start": 50,
- "end": 52,
+ "start": 91,
+ "end": 93,
"type": "Text",
"raw": ": ",
"data": ": "
},
{
- "start": 52,
- "end": 59,
+ "start": 93,
+ "end": 100,
"type": "MustacheTag",
"expression": {
"type": "Identifier",
- "start": 53,
- "end": 58,
+ "start": 94,
+ "end": 99,
"loc": {
"start": {
- "line": 2,
+ "line": 6,
"column": 12
},
"end": {
- "line": 2,
+ "line": 6,
"column": 17
}
},
@@ -85,31 +92,177 @@
}
],
"context": {
- "start": 18,
- "end": 39,
"type": "ArrayPattern",
+ "start": 59,
+ "end": 80,
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 19
+ },
+ "end": {
+ "line": 5,
+ "column": 40
+ }
+ },
"elements": [
{
- "start": 19,
- "end": 22,
"type": "Identifier",
+ "start": 60,
+ "end": 63,
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 20
+ },
+ "end": {
+ "line": 5,
+ "column": 23
+ }
+ },
"name": "key"
},
{
- "start": 24,
- "end": 29,
"type": "Identifier",
+ "start": 65,
+ "end": 70,
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 25
+ },
+ "end": {
+ "line": 5,
+ "column": 30
+ }
+ },
"name": "value"
},
{
- "start": 31,
- "end": 38,
- "type": "RestIdentifier",
- "name": "rest"
+ "type": "RestElement",
+ "start": 72,
+ "end": 79,
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 32
+ },
+ "end": {
+ "line": 5,
+ "column": 39
+ }
+ },
+ "argument": {
+ "type": "Identifier",
+ "start": 75,
+ "end": 79,
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 35
+ },
+ "end": {
+ "line": 5,
+ "column": 39
+ }
+ },
+ "name": "rest"
+ }
}
]
}
}
]
+ },
+ "instance": {
+ "type": "Script",
+ "start": 0,
+ "end": 39,
+ "context": "default",
+ "content": {
+ "type": "Program",
+ "start": 8,
+ "end": 30,
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 3,
+ "column": 0
+ }
+ },
+ "body": [
+ {
+ "type": "ExportNamedDeclaration",
+ "start": 10,
+ "end": 29,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 1
+ },
+ "end": {
+ "line": 2,
+ "column": 20
+ }
+ },
+ "declaration": {
+ "type": "VariableDeclaration",
+ "start": 17,
+ "end": 29,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 8
+ },
+ "end": {
+ "line": 2,
+ "column": 20
+ }
+ },
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "start": 21,
+ "end": 28,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ },
+ "id": {
+ "type": "Identifier",
+ "start": 21,
+ "end": 28,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ },
+ "name": "animals"
+ },
+ "init": null
+ }
+ ],
+ "kind": "let"
+ },
+ "specifiers": [],
+ "source": null
+ }
+ ],
+ "sourceType": "module"
+ }
}
}
\ No newline at end of file
diff --git a/test/parser/samples/each-block-else/output.json b/test/parser/samples/each-block-else/output.json
index 2720ce5292..622789d177 100644
--- a/test/parser/samples/each-block-else/output.json
+++ b/test/parser/samples/each-block-else/output.json
@@ -57,10 +57,10 @@
}
],
"context": {
- "start": 18,
- "end": 24,
"type": "Identifier",
- "name": "animal"
+ "name": "animal",
+ "start": 18,
+ "end": 24
},
"else": {
"start": 50,
diff --git a/test/parser/samples/each-block-indexed/output.json b/test/parser/samples/each-block-indexed/output.json
index 50f2000a36..01b97ffcb4 100644
--- a/test/parser/samples/each-block-indexed/output.json
+++ b/test/parser/samples/each-block-indexed/output.json
@@ -85,10 +85,10 @@
}
],
"context": {
- "start": 18,
- "end": 24,
"type": "Identifier",
- "name": "animal"
+ "name": "animal",
+ "start": 18,
+ "end": 24
},
"index": "i"
}
diff --git a/test/parser/samples/each-block-keyed/output.json b/test/parser/samples/each-block-keyed/output.json
index 7dc8681453..6eaf19a82d 100644
--- a/test/parser/samples/each-block-keyed/output.json
+++ b/test/parser/samples/each-block-keyed/output.json
@@ -57,10 +57,10 @@
}
],
"context": {
- "start": 16,
- "end": 20,
"type": "Identifier",
- "name": "todo"
+ "name": "todo",
+ "start": 16,
+ "end": 20
},
"key": {
"type": "MemberExpression",
@@ -108,7 +108,8 @@
},
"name": "id"
},
- "computed": false
+ "computed": false,
+ "optional": false
}
}
]
diff --git a/test/parser/samples/each-block/output.json b/test/parser/samples/each-block/output.json
index 6594fb50a6..82d4455d19 100644
--- a/test/parser/samples/each-block/output.json
+++ b/test/parser/samples/each-block/output.json
@@ -57,10 +57,10 @@
}
],
"context": {
- "start": 18,
- "end": 24,
"type": "Identifier",
- "name": "animal"
+ "name": "animal",
+ "start": 18,
+ "end": 24
}
}
]
diff --git a/test/parser/samples/error-css-global-without-selector/error.json b/test/parser/samples/error-css-global-without-selector/error.json
new file mode 100644
index 0000000000..f4237c65d3
--- /dev/null
+++ b/test/parser/samples/error-css-global-without-selector/error.json
@@ -0,0 +1,10 @@
+{
+ "code": "css-syntax-error",
+ "message": ":global() must contain a selector",
+ "start": {
+ "line": 2,
+ "column": 1,
+ "character": 9
+ },
+ "pos": 9
+}
diff --git a/test/parser/samples/error-css-global-without-selector/input.svelte b/test/parser/samples/error-css-global-without-selector/input.svelte
new file mode 100644
index 0000000000..a626136cfc
--- /dev/null
+++ b/test/parser/samples/error-css-global-without-selector/input.svelte
@@ -0,0 +1,3 @@
+
diff --git a/test/parser/samples/error-unmatched-closing-tag-autoclose-2/error.json b/test/parser/samples/error-unmatched-closing-tag-autoclose-2/error.json
new file mode 100644
index 0000000000..d24296bd96
--- /dev/null
+++ b/test/parser/samples/error-unmatched-closing-tag-autoclose-2/error.json
@@ -0,0 +1,10 @@
+{
+ "code": "invalid-closing-tag",
+ "message": " attempted to close an element that was not open",
+ "pos": 38,
+ "start": {
+ "character": 38,
+ "column": 0,
+ "line": 5
+ }
+}
diff --git a/test/parser/samples/error-unmatched-closing-tag-autoclose-2/input.svelte b/test/parser/samples/error-unmatched-closing-tag-autoclose-2/input.svelte
new file mode 100644
index 0000000000..5182577921
--- /dev/null
+++ b/test/parser/samples/error-unmatched-closing-tag-autoclose-2/input.svelte
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/test/parser/samples/error-unmatched-closing-tag-autoclose/error.json b/test/parser/samples/error-unmatched-closing-tag-autoclose/error.json
new file mode 100644
index 0000000000..e6532d747e
--- /dev/null
+++ b/test/parser/samples/error-unmatched-closing-tag-autoclose/error.json
@@ -0,0 +1,10 @@
+{
+ "code": "invalid-closing-tag",
+ "message": " attempted to close that was already automatically closed by
",
+ "pos": 24,
+ "start": {
+ "character": 24,
+ "column": 0,
+ "line": 3
+ }
+}
diff --git a/test/parser/samples/error-unmatched-closing-tag-autoclose/input.svelte b/test/parser/samples/error-unmatched-closing-tag-autoclose/input.svelte
new file mode 100644
index 0000000000..0bfd609736
--- /dev/null
+++ b/test/parser/samples/error-unmatched-closing-tag-autoclose/input.svelte
@@ -0,0 +1,3 @@
+
+
pre tag
+
\ No newline at end of file
diff --git a/test/parser/samples/no-error-if-before-closing/output.json b/test/parser/samples/no-error-if-before-closing/output.json
index 251cefc0ca..f22586b267 100644
--- a/test/parser/samples/no-error-if-before-closing/output.json
+++ b/test/parser/samples/no-error-if-before-closing/output.json
@@ -115,7 +115,12 @@
"value": true,
"raw": "true"
},
- "value": "f",
+ "value": {
+ "type": "Identifier",
+ "name": "f",
+ "start": 97,
+ "end": 98
+ },
"error": null,
"pending": {
"start": 80,
@@ -198,7 +203,12 @@
"value": true,
"raw": "true"
},
- "value": "f",
+ "value": {
+ "type": "Identifier",
+ "name": "f",
+ "start": 137,
+ "end": 138
+ },
"error": null,
"pending": {
"start": 123,
diff --git a/test/parser/samples/style-inside-head/input.svelte b/test/parser/samples/style-inside-head/input.svelte
new file mode 100644
index 0000000000..512e5b2fb4
--- /dev/null
+++ b/test/parser/samples/style-inside-head/input.svelte
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/test/parser/samples/style-inside-head/output.json b/test/parser/samples/style-inside-head/output.json
new file mode 100644
index 0000000000..ae972c5fa8
--- /dev/null
+++ b/test/parser/samples/style-inside-head/output.json
@@ -0,0 +1,33 @@
+{
+ "html": {
+ "start": 0,
+ "end": 42,
+ "type": "Fragment",
+ "children": [
+ {
+ "start": 0,
+ "end": 42,
+ "type": "Head",
+ "name": "svelte:head",
+ "attributes": [],
+ "children": [
+ {
+ "start": 13,
+ "end": 28,
+ "type": "Element",
+ "name": "style",
+ "attributes": [],
+ "children": [
+ {
+ "start": 20,
+ "end": 20,
+ "type": "Text",
+ "data": ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/test/parser/samples/unusual-identifier/output.json b/test/parser/samples/unusual-identifier/output.json
index 76cc82cfd6..3d209d35fe 100644
--- a/test/parser/samples/unusual-identifier/output.json
+++ b/test/parser/samples/unusual-identifier/output.json
@@ -57,10 +57,10 @@
}
],
"context": {
- "start": 17,
- "end": 19,
"type": "Identifier",
- "name": "𐊧"
+ "name": "𐊧",
+ "start": 17,
+ "end": 19
}
}
]
diff --git a/test/parser/update.js b/test/parser/update.js
deleted file mode 100644
index 0edac895b5..0000000000
--- a/test/parser/update.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// this file will replace all the output.json files with their _actual.json
-// equivalents. Only use it when you're sure that you haven't
-// broken anything!
-const fs = require("fs");
-const glob = require("tiny-glob/sync.js");
-
-glob("samples/*/_actual.json", { cwd: __dirname }).forEach(file => {
- const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8");
- fs.writeFileSync(
- `${__dirname}/${file.replace("_actual.json", "output.json")}`,
- actual
- );
-});
diff --git a/test/parser/update.ts b/test/parser/update.ts
new file mode 100644
index 0000000000..83b8cbc865
--- /dev/null
+++ b/test/parser/update.ts
@@ -0,0 +1,13 @@
+// this file will replace all the output.json files with their _actual.json
+// equivalents. Only use it when you're sure that you haven't
+// broken anything!
+const fs = require('fs');
+const glob = require('tiny-glob/sync.js');
+
+glob('samples/*/_actual.json', { cwd: __dirname }).forEach(file => {
+ const actual = fs.readFileSync(`${__dirname}/${file}`, 'utf-8');
+ fs.writeFileSync(
+ `${__dirname}/${file.replace('_actual.json', 'output.json')}`,
+ actual
+ );
+});
diff --git a/test/preprocess/index.js b/test/preprocess/index.ts
similarity index 72%
rename from test/preprocess/index.js
rename to test/preprocess/index.ts
index 5d83bb6059..60d3acbabb 100644
--- a/test/preprocess/index.js
+++ b/test/preprocess/index.ts
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as assert from 'assert';
-import { loadConfig, svelte } from '../helpers.js';
+import { loadConfig, svelte } from '../helpers';
describe('preprocess', () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
@@ -8,16 +8,21 @@ describe('preprocess', () => {
const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
const solo = config.solo || /\.solo/.test(dir);
+ const skip = config.skip || /\.skip/.test(dir);
if (solo && process.env.CI) {
throw new Error('Forgot to remove `solo: true` from test');
}
- (config.skip ? it.skip : solo ? it.only : it)(dir, async () => {
+ (skip ? it.skip : solo ? it.only : it)(dir, async () => {
const input = fs.readFileSync(`${__dirname}/samples/${dir}/input.svelte`, 'utf-8');
const expected = fs.readFileSync(`${__dirname}/samples/${dir}/output.svelte`, 'utf-8');
- const result = await svelte.preprocess(input, config.preprocess);
+ const result = await svelte.preprocess(
+ input,
+ config.preprocess || {},
+ config.options || { filename: 'input.svelte' }
+ );
fs.writeFileSync(`${__dirname}/samples/${dir}/_actual.html`, result.code);
assert.equal(result.code, expected);
diff --git a/test/preprocess/samples/comments/_config.js b/test/preprocess/samples/comments/_config.js
index 4416d121d0..fdec377567 100644
--- a/test/preprocess/samples/comments/_config.js
+++ b/test/preprocess/samples/comments/_config.js
@@ -2,7 +2,7 @@ export default {
preprocess: [
{
script: ({ content }) => ({ code: content.replace(/one/g, 'two') }),
- style: ({ content }) => ({ code: content.replace(/one/g, 'three') }),
- },
- ],
+ style: ({ content }) => ({ code: content.replace(/one/g, 'three') })
+ }
+ ]
};
diff --git a/test/preprocess/samples/dependencies/_config.js b/test/preprocess/samples/dependencies/_config.js
index fa2d8b40c9..4656cd98f9 100644
--- a/test/preprocess/samples/dependencies/_config.js
+++ b/test/preprocess/samples/dependencies/_config.js
@@ -12,4 +12,4 @@ export default {
},
dependencies: ['./foo.css']
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/filename/_config.js b/test/preprocess/samples/filename/_config.js
index c71cdafcac..161f084730 100644
--- a/test/preprocess/samples/filename/_config.js
+++ b/test/preprocess/samples/filename/_config.js
@@ -1,6 +1,5 @@
export default {
preprocess: {
- filename: 'file.svelte',
markup: ({ content, filename }) => {
return {
code: content.replace('__MARKUP_FILENAME__', filename)
@@ -16,5 +15,8 @@ export default {
code: content.replace('__SCRIPT_FILENAME__', filename)
};
}
+ },
+ options: {
+ filename: 'file.svelte'
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/ignores-null/_config.js b/test/preprocess/samples/ignores-null/_config.js
index 042ee89aed..08ba71c748 100644
--- a/test/preprocess/samples/ignores-null/_config.js
+++ b/test/preprocess/samples/ignores-null/_config.js
@@ -2,4 +2,4 @@ export default {
preprocess: {
script: () => null
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/markup/_config.js b/test/preprocess/samples/markup/_config.js
index 857da608af..13044d4132 100644
--- a/test/preprocess/samples/markup/_config.js
+++ b/test/preprocess/samples/markup/_config.js
@@ -6,4 +6,4 @@ export default {
};
}
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/multiple-preprocessors/_config.js b/test/preprocess/samples/multiple-preprocessors/_config.js
index 8a57567f6b..d6226203cc 100644
--- a/test/preprocess/samples/multiple-preprocessors/_config.js
+++ b/test/preprocess/samples/multiple-preprocessors/_config.js
@@ -11,4 +11,4 @@ export default {
style: ({ content }) => ({ code: content.replace(/three/g, 'four') })
}
]
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/script-multiple/_config.js b/test/preprocess/samples/script-multiple/_config.js
index d6656ff48e..a523efe9bc 100644
--- a/test/preprocess/samples/script-multiple/_config.js
+++ b/test/preprocess/samples/script-multiple/_config.js
@@ -6,4 +6,4 @@ export default {
};
}
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/script-self-closing/_config.js b/test/preprocess/samples/script-self-closing/_config.js
new file mode 100644
index 0000000000..ab87c7be1e
--- /dev/null
+++ b/test/preprocess/samples/script-self-closing/_config.js
@@ -0,0 +1,12 @@
+import * as assert from 'assert';
+
+export default {
+ preprocess: {
+ script: ({ content, attributes }) => {
+ assert.equal(content, '');
+ return {
+ code: `console.log("${attributes['the-answer']}");`
+ };
+ }
+ }
+};
diff --git a/test/preprocess/samples/script-self-closing/input.svelte b/test/preprocess/samples/script-self-closing/input.svelte
new file mode 100644
index 0000000000..c5816cb3ba
--- /dev/null
+++ b/test/preprocess/samples/script-self-closing/input.svelte
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/test/preprocess/samples/script-self-closing/output.svelte b/test/preprocess/samples/script-self-closing/output.svelte
new file mode 100644
index 0000000000..2912876880
--- /dev/null
+++ b/test/preprocess/samples/script-self-closing/output.svelte
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/test/preprocess/samples/script/_config.js b/test/preprocess/samples/script/_config.js
index 8e8ac1d2f9..1a21045465 100644
--- a/test/preprocess/samples/script/_config.js
+++ b/test/preprocess/samples/script/_config.js
@@ -6,4 +6,4 @@ export default {
};
}
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/style-async/_config.js b/test/preprocess/samples/style-async/_config.js
index a91f8f4307..00298a0bfb 100644
--- a/test/preprocess/samples/style-async/_config.js
+++ b/test/preprocess/samples/style-async/_config.js
@@ -6,4 +6,4 @@ export default {
});
}
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/style-attributes/_config.js b/test/preprocess/samples/style-attributes/_config.js
index 7a619054bd..ac2955397b 100644
--- a/test/preprocess/samples/style-attributes/_config.js
+++ b/test/preprocess/samples/style-attributes/_config.js
@@ -11,4 +11,4 @@ export default {
return { code: 'PROCESSED' };
}
}
-};
\ No newline at end of file
+};
diff --git a/test/preprocess/samples/style-self-closing/_config.js b/test/preprocess/samples/style-self-closing/_config.js
new file mode 100644
index 0000000000..af762e8da8
--- /dev/null
+++ b/test/preprocess/samples/style-self-closing/_config.js
@@ -0,0 +1,12 @@
+import * as assert from 'assert';
+
+export default {
+ preprocess: {
+ style: ({ content, attributes: { color } }) => {
+ assert.equal(content, '');
+ return {
+ code: `div { color: ${color}; }`
+ };
+ }
+ }
+};
diff --git a/test/preprocess/samples/style-self-closing/input.svelte b/test/preprocess/samples/style-self-closing/input.svelte
new file mode 100644
index 0000000000..07176c87e5
--- /dev/null
+++ b/test/preprocess/samples/style-self-closing/input.svelte
@@ -0,0 +1,3 @@
+$brand
+
+
\ No newline at end of file
diff --git a/test/preprocess/samples/style-self-closing/output.svelte b/test/preprocess/samples/style-self-closing/output.svelte
new file mode 100644
index 0000000000..c376cd00cb
--- /dev/null
+++ b/test/preprocess/samples/style-self-closing/output.svelte
@@ -0,0 +1,3 @@
+$brand
+
+
\ No newline at end of file
diff --git a/test/preprocess/samples/style/_config.js b/test/preprocess/samples/style/_config.js
index 59040eccdd..19da7ea384 100644
--- a/test/preprocess/samples/style/_config.js
+++ b/test/preprocess/samples/style/_config.js
@@ -6,4 +6,4 @@ export default {
};
}
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/index.js b/test/runtime/index.ts
similarity index 85%
rename from test/runtime/index.js
rename to test/runtime/index.ts
index f070eb8185..153ac9dbb8 100644
--- a/test/runtime/index.js
+++ b/test/runtime/index.ts
@@ -1,12 +1,12 @@
-import * as assert from "assert";
-import * as path from "path";
-import * as fs from "fs";
+import * as path from 'path';
+import * as fs from 'fs';
import { rollup } from 'rollup';
-import * as virtual from '@rollup/plugin-virtual';
-import * as glob from 'tiny-glob/sync.js';
-import { clear_loops, flush, set_now, set_raf } from "../../internal";
+import virtual from '@rollup/plugin-virtual';
+import glob from 'tiny-glob/sync.js';
+import { clear_loops, flush, set_now, set_raf } from '../../internal';
import {
+ assert,
showOutput,
loadConfig,
loadSvelte,
@@ -14,7 +14,7 @@ import {
env,
setupHtmlEqual,
mkdirp
-} from "../helpers.js";
+} from '../helpers';
let svelte$;
let svelte;
@@ -29,17 +29,17 @@ process.on('unhandledRejection', err => {
unhandled_rejection = err;
});
-describe("runtime", () => {
+describe('runtime', () => {
before(() => {
svelte = loadSvelte(false);
svelte$ = loadSvelte(true);
- require.extensions[".svelte"] = function(module, filename) {
+ require.extensions['.svelte'] = function(module, filename) {
const options = Object.assign({
filename
}, compileOptions);
- const { js: { code } } = compile(fs.readFileSync(filename, "utf-8"), options);
+ const { js: { code } } = compile(fs.readFileSync(filename, 'utf-8').replace(/\r/g, ''), options);
return module._compile(code, filename);
};
@@ -50,7 +50,7 @@ describe("runtime", () => {
const failed = new Set();
function runTest(dir, hydrate) {
- if (dir[0] === ".") return;
+ if (dir[0] === '.') return;
const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
const solo = config.solo || /\.solo/.test(dir);
@@ -58,7 +58,7 @@ describe("runtime", () => {
if (hydrate && config.skip_if_hydrate) return;
if (solo && process.env.CI) {
- throw new Error("Forgot to remove `solo: true` from test");
+ throw new Error('Forgot to remove `solo: true` from test');
}
(config.skip ? it.skip : solo ? it.only : it)(`${dir} ${hydrate ? '(with hydration)' : ''}`, () => {
@@ -103,7 +103,7 @@ describe("runtime", () => {
try {
const { js } = compile(
- fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
+ fs.readFileSync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, ''),
{
...compileOptions,
filename: file
@@ -151,7 +151,7 @@ describe("runtime", () => {
// Put things we need on window for testing
window.SvelteComponent = SvelteComponent;
- const target = window.document.querySelector("main");
+ const target = window.document.querySelector('main');
const warnings = [];
const warn = console.warn;
@@ -172,14 +172,14 @@ describe("runtime", () => {
if (config.error) {
unintendedError = true;
- throw new Error("Expected a runtime error");
+ throw new Error('Expected a runtime error');
}
if (config.warnings) {
assert.deepEqual(warnings, config.warnings);
} else if (warnings.length) {
unintendedError = true;
- throw new Error("Received unexpected warnings");
+ throw new Error('Received unexpected warnings');
}
if (config.html) {
@@ -204,7 +204,7 @@ describe("runtime", () => {
});
} else {
component.$destroy();
- assert.htmlEqual(target.innerHTML, "");
+ assert.htmlEqual(target.innerHTML, '');
if (unhandled_rejection) {
throw unhandled_rejection;
@@ -250,8 +250,8 @@ describe("runtime", () => {
async function create_component(src = '
') {
const { js } = svelte$.compile(src, {
- format: "esm",
- name: "SvelteComponent",
+ format: 'esm',
+ name: 'SvelteComponent',
dev: true
});
@@ -282,7 +282,7 @@ describe("runtime", () => {
);
}
- it("fails if options.target is missing in dev mode", async () => {
+ it('fails if options.target is missing in dev mode', async () => {
const App = await create_component();
assert.throws(() => {
@@ -290,7 +290,7 @@ describe("runtime", () => {
}, /'target' is a required option/);
});
- it("fails if options.hydrate is true but the component is non-hydratable", async () => {
+ it('fails if options.hydrate is true but the component is non-hydratable', async () => {
const App = await create_component();
assert.throws(() => {
diff --git a/test/runtime/samples/$$rest-without-props/_config.js b/test/runtime/samples/$$rest-without-props/_config.js
index 017f9df561..1fb8e85a6a 100644
--- a/test/runtime/samples/$$rest-without-props/_config.js
+++ b/test/runtime/samples/$$rest-without-props/_config.js
@@ -11,7 +11,7 @@ export default {
`,
- async test({ assert, target, window, }) {
+ async test({ assert, target, window }) {
const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click');
diff --git a/test/runtime/samples/$$rest/_config.js b/test/runtime/samples/$$rest/_config.js
index 255927f354..f00c26d712 100644
--- a/test/runtime/samples/$$rest/_config.js
+++ b/test/runtime/samples/$$rest/_config.js
@@ -13,7 +13,7 @@ export default {
`,
- async test({ assert, target, window, }) {
+ async test({ assert, target, window }) {
const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click');
diff --git a/test/runtime/samples/$$slot/A.svelte b/test/runtime/samples/$$slot/A.svelte
new file mode 100644
index 0000000000..ffa166166c
--- /dev/null
+++ b/test/runtime/samples/$$slot/A.svelte
@@ -0,0 +1,31 @@
+
+
+
+
+
+$$slots: {toString($$slots)}
+
+{#if $$slots.b}
+
+
+
+{:else}
+ Slot b is not available
+{/if}
\ No newline at end of file
diff --git a/test/runtime/samples/$$slot/_config.js b/test/runtime/samples/$$slot/_config.js
new file mode 100644
index 0000000000..13b2137cdb
--- /dev/null
+++ b/test/runtime/samples/$$slot/_config.js
@@ -0,0 +1,18 @@
+export default {
+ html: `
+ bye world
+ hello world
+ $$slots: {"a":true,"default":true}
+ Slot b is not available
+
+ bye world
+ hello world
+ $$slots: {"a":true,"b":true,"default":true}
+ hello world
+ `,
+
+ async test({ assert, target, component }) {
+ assert.equal(component.getA(), '');
+ assert.equal(component.getB(), 'foo');
+ }
+};
diff --git a/test/runtime/samples/$$slot/main.svelte b/test/runtime/samples/$$slot/main.svelte
new file mode 100644
index 0000000000..8b7efae573
--- /dev/null
+++ b/test/runtime/samples/$$slot/main.svelte
@@ -0,0 +1,23 @@
+
+
+
+ hello world
+ bye
+ world
+
+
+
+ hello world
+ hello world
+ bye world
+
diff --git a/test/runtime/samples/action-custom-event-handler-this/_config.js b/test/runtime/samples/action-custom-event-handler-this/_config.js
index 194fa08c31..ec3fa373eb 100644
--- a/test/runtime/samples/action-custom-event-handler-this/_config.js
+++ b/test/runtime/samples/action-custom-event-handler-this/_config.js
@@ -1,10 +1,10 @@
export default {
- html: ` `,
+ html: ' ',
test({ assert, component, target, window }) {
const input = target.querySelector('input');
const event = new window.KeyboardEvent('keydown', {
- which: 13
+ key: 'Enter'
});
let blurred = false;
@@ -18,5 +18,5 @@ export default {
input.dispatchEvent(event);
assert.ok(blurred);
- },
+ }
};
diff --git a/test/runtime/samples/action-custom-event-handler-this/main.svelte b/test/runtime/samples/action-custom-event-handler-this/main.svelte
index a7347cdc99..c3ace108a5 100644
--- a/test/runtime/samples/action-custom-event-handler-this/main.svelte
+++ b/test/runtime/samples/action-custom-event-handler-this/main.svelte
@@ -1,7 +1,7 @@
-
\ No newline at end of file
+
diff --git a/test/runtime/samples/action-object/_config.js b/test/runtime/samples/action-object/_config.js
new file mode 100644
index 0000000000..7fdc11af2b
--- /dev/null
+++ b/test/runtime/samples/action-object/_config.js
@@ -0,0 +1,8 @@
+export default {
+ html: `
+ action
+ `,
+ async test({ assert, target, window }) {
+ assert.equal(target.querySelector('button').foo, 'bar1337');
+ }
+};
diff --git a/test/runtime/samples/action-object/main.svelte b/test/runtime/samples/action-object/main.svelte
new file mode 100644
index 0000000000..f15e319e6f
--- /dev/null
+++ b/test/runtime/samples/action-object/main.svelte
@@ -0,0 +1,10 @@
+
+
+action
\ No newline at end of file
diff --git a/test/runtime/samples/action-ternary-template/_config.js b/test/runtime/samples/action-ternary-template/_config.js
index adf23a9f68..ecb18dceec 100644
--- a/test/runtime/samples/action-ternary-template/_config.js
+++ b/test/runtime/samples/action-ternary-template/_config.js
@@ -1,7 +1,7 @@
export default {
props: {
target: 'World!',
- display: true,
+ display: true
},
html: `
@@ -16,5 +16,5 @@ export default {
assert.htmlEqual(target.innerHTML, `
Hello World!
`);
- },
+ }
};
diff --git a/test/runtime/samples/action-this/_config.js b/test/runtime/samples/action-this/_config.js
index de7f834cdc..933ce993b9 100644
--- a/test/runtime/samples/action-this/_config.js
+++ b/test/runtime/samples/action-this/_config.js
@@ -3,9 +3,9 @@ export default {
const button = target.querySelector('button');
const click = new window.MouseEvent('click');
- assert.htmlEqual(target.innerHTML, `1 `);
+ assert.htmlEqual(target.innerHTML, '1 ');
await button.dispatchEvent(click);
await Promise.resolve();
- assert.htmlEqual(target.innerHTML, `2 `);
- },
+ assert.htmlEqual(target.innerHTML, '2 ');
+ }
};
diff --git a/test/runtime/samples/animation-css/_config.js b/test/runtime/samples/animation-css/_config.js
index 9410fb91e7..b80545de3a 100644
--- a/test/runtime/samples/animation-css/_config.js
+++ b/test/runtime/samples/animation-css/_config.js
@@ -54,4 +54,4 @@ export default {
divs[4].style.animation
], ['', '']);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/animation-js-delay/_config.js b/test/runtime/samples/animation-js-delay/_config.js
index 6bd02d17e6..931d37817b 100644
--- a/test/runtime/samples/animation-js-delay/_config.js
+++ b/test/runtime/samples/animation-js-delay/_config.js
@@ -57,4 +57,4 @@ export default {
assert.equal(divs[0].dy, 0);
assert.equal(divs[4].dy, 0);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/animation-js-easing/_config.js b/test/runtime/samples/animation-js-easing/_config.js
index 415af042a9..e466309f57 100644
--- a/test/runtime/samples/animation-js-easing/_config.js
+++ b/test/runtime/samples/animation-js-easing/_config.js
@@ -53,4 +53,4 @@ export default {
assert.equal(divs[0].dy, 0);
assert.equal(divs[4].dy, 0);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/animation-js-easing/easing.js b/test/runtime/samples/animation-js-easing/easing.js
index fecc4d96f6..6399b8858c 100644
--- a/test/runtime/samples/animation-js-easing/easing.js
+++ b/test/runtime/samples/animation-js-easing/easing.js
@@ -1,3 +1,3 @@
export function linear(t) {
return t;
-}
\ No newline at end of file
+}
diff --git a/test/runtime/samples/animation-js/_config.js b/test/runtime/samples/animation-js/_config.js
index 521753633d..5c5e874b3e 100644
--- a/test/runtime/samples/animation-js/_config.js
+++ b/test/runtime/samples/animation-js/_config.js
@@ -74,4 +74,4 @@ export default {
assert.equal(divs[0].dy, 0);
assert.equal(divs[4].dy, 0);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/apply-directives-in-order-2/_config.js b/test/runtime/samples/apply-directives-in-order-2/_config.js
index a74ce41cb6..caff97a5b9 100644
--- a/test/runtime/samples/apply-directives-in-order-2/_config.js
+++ b/test/runtime/samples/apply-directives-in-order-2/_config.js
@@ -1,7 +1,7 @@
const value = [];
export default {
props: {
- value,
+ value
},
async test({ assert, component, target, window }) {
@@ -32,7 +32,7 @@ export default {
'15',
'16',
'17',
- '18',
+ '18'
]);
- },
+ }
};
diff --git a/test/runtime/samples/apply-directives-in-order/_config.js b/test/runtime/samples/apply-directives-in-order/_config.js
index 03cdc24645..0c85c97f8b 100644
--- a/test/runtime/samples/apply-directives-in-order/_config.js
+++ b/test/runtime/samples/apply-directives-in-order/_config.js
@@ -33,5 +33,5 @@ export default {
HE
`);
- },
+ }
};
diff --git a/test/runtime/samples/array-literal-spread-deopt/_config.js b/test/runtime/samples/array-literal-spread-deopt/_config.js
index d4fdcfad85..926f462b55 100644
--- a/test/runtime/samples/array-literal-spread-deopt/_config.js
+++ b/test/runtime/samples/array-literal-spread-deopt/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `a
b
c
`
+ html: 'a
b
c
'
};
diff --git a/test/runtime/samples/assignment-in-init/_config.js b/test/runtime/samples/assignment-in-init/_config.js
index bcf227f8e6..52428c607d 100644
--- a/test/runtime/samples/assignment-in-init/_config.js
+++ b/test/runtime/samples/assignment-in-init/_config.js
@@ -3,4 +3,4 @@ export default {
assert.equal(component.get_foo(), 1);
assert.equal(component.get_bar(), 2);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/assignment-to-computed-property/_config.js b/test/runtime/samples/assignment-to-computed-property/_config.js
index 7ba090abe9..25f94c844e 100644
--- a/test/runtime/samples/assignment-to-computed-property/_config.js
+++ b/test/runtime/samples/assignment-to-computed-property/_config.js
@@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.deepEqual(component.foo, { baz: 1 });
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/attribute-boolean-case-insensitive/_config.js b/test/runtime/samples/attribute-boolean-case-insensitive/_config.js
index 16e5ade6d2..99ccedb8c9 100644
--- a/test/runtime/samples/attribute-boolean-case-insensitive/_config.js
+++ b/test/runtime/samples/attribute-boolean-case-insensitive/_config.js
@@ -1,3 +1,3 @@
export default {
- html: ` `
+ html: ' '
};
diff --git a/test/runtime/samples/attribute-boolean-false/_config.js b/test/runtime/samples/attribute-boolean-false/_config.js
index 14fdeb9fdc..935b709fab 100644
--- a/test/runtime/samples/attribute-boolean-false/_config.js
+++ b/test/runtime/samples/attribute-boolean-false/_config.js
@@ -1,7 +1,7 @@
export default {
- html: ``,
+ html: '',
test({ assert, component, target }) {
const textarea = target.querySelector('textarea');
assert.ok(textarea.readOnly === false);
- },
+ }
};
diff --git a/test/runtime/samples/attribute-boolean-indeterminate/_config.js b/test/runtime/samples/attribute-boolean-indeterminate/_config.js
index 0e24f92c51..d16cb5f96b 100644
--- a/test/runtime/samples/attribute-boolean-indeterminate/_config.js
+++ b/test/runtime/samples/attribute-boolean-indeterminate/_config.js
@@ -18,4 +18,4 @@ export default {
component.indeterminate = false;
assert.ok(!input.indeterminate);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/attribute-boolean-true/_config.js b/test/runtime/samples/attribute-boolean-true/_config.js
index 0e402ed1e3..ccc0814296 100644
--- a/test/runtime/samples/attribute-boolean-true/_config.js
+++ b/test/runtime/samples/attribute-boolean-true/_config.js
@@ -1,7 +1,7 @@
export default {
- html: ``,
+ html: '',
test({ assert, component, target }) {
const textarea = target.querySelector('textarea');
assert.ok(textarea.readOnly);
- },
+ }
};
diff --git a/test/runtime/samples/attribute-boolean-with-spread/_config.js b/test/runtime/samples/attribute-boolean-with-spread/_config.js
index 270804170d..1fd2443369 100644
--- a/test/runtime/samples/attribute-boolean-with-spread/_config.js
+++ b/test/runtime/samples/attribute-boolean-with-spread/_config.js
@@ -1,3 +1,3 @@
export default {
- html: ` `
+ html: ' '
};
diff --git a/test/runtime/samples/attribute-dataset-without-value/_config.js b/test/runtime/samples/attribute-dataset-without-value/_config.js
index 934f44eb06..21e60b92aa 100644
--- a/test/runtime/samples/attribute-dataset-without-value/_config.js
+++ b/test/runtime/samples/attribute-dataset-without-value/_config.js
@@ -1,3 +1,3 @@
export default {
- html: '
',
+ html: '
'
};
diff --git a/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js b/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js
index acf3c64bdd..f1088830af 100644
--- a/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js
+++ b/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js
@@ -1,5 +1,5 @@
export default {
html: `
- `,
+ `
};
diff --git a/test/runtime/samples/attribute-dynamic-quotemarks/_config.js b/test/runtime/samples/attribute-dynamic-quotemarks/_config.js
index b9f4364624..d74a0445d2 100644
--- a/test/runtime/samples/attribute-dynamic-quotemarks/_config.js
+++ b/test/runtime/samples/attribute-dynamic-quotemarks/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `foo `
+ html: 'foo '
};
diff --git a/test/runtime/samples/attribute-dynamic-shorthand/_config.js b/test/runtime/samples/attribute-dynamic-shorthand/_config.js
index 53f474db23..ebf4dd3881 100644
--- a/test/runtime/samples/attribute-dynamic-shorthand/_config.js
+++ b/test/runtime/samples/attribute-dynamic-shorthand/_config.js
@@ -1,8 +1,8 @@
export default {
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
component.id = 'bar';
- assert.equal( target.innerHTML, `
` );
+ assert.equal( target.innerHTML, '
' );
}
};
diff --git a/test/runtime/samples/attribute-dynamic-type/_config.js b/test/runtime/samples/attribute-dynamic-type/_config.js
index 92f6ce196d..19aa33d65e 100644
--- a/test/runtime/samples/attribute-dynamic-type/_config.js
+++ b/test/runtime/samples/attribute-dynamic-type/_config.js
@@ -6,7 +6,7 @@ export default {
inputValue: 42
},
- html: ` `,
+ html: ' ',
test({ assert, component, target }) {
const input = target.querySelector('input');
diff --git a/test/runtime/samples/attribute-dynamic/_config.js b/test/runtime/samples/attribute-dynamic/_config.js
index 04f419145d..34323a997e 100644
--- a/test/runtime/samples/attribute-dynamic/_config.js
+++ b/test/runtime/samples/attribute-dynamic/_config.js
@@ -1,5 +1,5 @@
export default {
- html: `red
`,
+ html: 'red
',
test({ assert, component, target }) {
const div = target.querySelector( 'div' );
@@ -7,7 +7,7 @@ export default {
assert.equal( div.style.color, 'red' );
component.color = 'blue';
- assert.equal( target.innerHTML, `blue
` );
+ assert.equal( target.innerHTML, 'blue
' );
assert.equal( div.style.color, 'blue' );
}
};
diff --git a/test/runtime/samples/attribute-empty/_config.js b/test/runtime/samples/attribute-empty/_config.js
index b9ce14cce1..f9aaeb39a6 100644
--- a/test/runtime/samples/attribute-empty/_config.js
+++ b/test/runtime/samples/attribute-empty/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `
`
+ html: '
'
};
diff --git a/test/runtime/samples/attribute-false/_config.js b/test/runtime/samples/attribute-false/_config.js
index 9fd08a2a48..c05d83cb3d 100644
--- a/test/runtime/samples/attribute-false/_config.js
+++ b/test/runtime/samples/attribute-false/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `
`,
+ html: '
'
};
diff --git a/test/runtime/samples/attribute-namespaced/_config.js b/test/runtime/samples/attribute-namespaced/_config.js
index f8c0cb03fb..275a198219 100644
--- a/test/runtime/samples/attribute-namespaced/_config.js
+++ b/test/runtime/samples/attribute-namespaced/_config.js
@@ -11,4 +11,4 @@ export default {
const use = target.querySelector( 'use' );
assert.equal( use.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ), '#bar' );
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/attribute-null-classname-no-style/_config.js b/test/runtime/samples/attribute-null-classname-no-style/_config.js
index 4a78b680ef..6cfefc8834 100644
--- a/test/runtime/samples/attribute-null-classname-no-style/_config.js
+++ b/test/runtime/samples/attribute-null-classname-no-style/_config.js
@@ -1,9 +1,9 @@
export default {
props: {
- testName: "testClassName"
+ testName: 'testClassName'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
diff --git a/test/runtime/samples/attribute-null-classname-with-style/_config.js b/test/runtime/samples/attribute-null-classname-with-style/_config.js
index 3ebc593b5d..d81543295e 100644
--- a/test/runtime/samples/attribute-null-classname-with-style/_config.js
+++ b/test/runtime/samples/attribute-null-classname-with-style/_config.js
@@ -1,5 +1,5 @@
export default {
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
diff --git a/test/runtime/samples/attribute-null-classnames-no-style/_config.js b/test/runtime/samples/attribute-null-classnames-no-style/_config.js
index 917cf565c0..7281f5b637 100644
--- a/test/runtime/samples/attribute-null-classnames-no-style/_config.js
+++ b/test/runtime/samples/attribute-null-classnames-no-style/_config.js
@@ -1,10 +1,10 @@
export default {
props: {
- testName1: "test1",
- testName2: "test2",
+ testName1: 'test1',
+ testName2: 'test2'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
@@ -15,11 +15,11 @@ export default {
assert.equal(div.className, '0');
component.testName1 = null;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'nulltest');
component.testName1 = undefined;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'undefinedtest');
component.testName1 = undefined;
diff --git a/test/runtime/samples/attribute-null-classnames-with-style/_config.js b/test/runtime/samples/attribute-null-classnames-with-style/_config.js
index 5762f628fb..547e62427f 100644
--- a/test/runtime/samples/attribute-null-classnames-with-style/_config.js
+++ b/test/runtime/samples/attribute-null-classnames-with-style/_config.js
@@ -1,10 +1,10 @@
export default {
props: {
- testName1: "test1",
- testName2: "test2",
+ testName1: 'test1',
+ testName2: 'test2'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
@@ -15,11 +15,11 @@ export default {
assert.equal(div.className, '0 svelte-x1o6ra');
component.testName1 = null;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'nulltest svelte-x1o6ra');
component.testName1 = undefined;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'undefinedtest svelte-x1o6ra');
component.testName1 = undefined;
diff --git a/test/runtime/samples/attribute-null-func-classname-no-style/_config.js b/test/runtime/samples/attribute-null-func-classname-no-style/_config.js
index 4a78b680ef..6cfefc8834 100644
--- a/test/runtime/samples/attribute-null-func-classname-no-style/_config.js
+++ b/test/runtime/samples/attribute-null-func-classname-no-style/_config.js
@@ -1,9 +1,9 @@
export default {
props: {
- testName: "testClassName"
+ testName: 'testClassName'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
diff --git a/test/runtime/samples/attribute-null-func-classname-with-style/_config.js b/test/runtime/samples/attribute-null-func-classname-with-style/_config.js
index 1ed43d05b9..435a679da7 100644
--- a/test/runtime/samples/attribute-null-func-classname-with-style/_config.js
+++ b/test/runtime/samples/attribute-null-func-classname-with-style/_config.js
@@ -1,9 +1,9 @@
export default {
props: {
- testName: "testClassName"
+ testName: 'testClassName'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
diff --git a/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js b/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js
index 917cf565c0..7281f5b637 100644
--- a/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js
+++ b/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js
@@ -1,10 +1,10 @@
export default {
props: {
- testName1: "test1",
- testName2: "test2",
+ testName1: 'test1',
+ testName2: 'test2'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
@@ -15,11 +15,11 @@ export default {
assert.equal(div.className, '0');
component.testName1 = null;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'nulltest');
component.testName1 = undefined;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'undefinedtest');
component.testName1 = undefined;
diff --git a/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js b/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js
index 5762f628fb..547e62427f 100644
--- a/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js
+++ b/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js
@@ -1,10 +1,10 @@
export default {
props: {
- testName1: "test1",
- testName2: "test2",
+ testName1: 'test1',
+ testName2: 'test2'
},
- html: `
`,
+ html: '
',
test({ assert, component, target }) {
const div = target.querySelector('div');
@@ -15,11 +15,11 @@ export default {
assert.equal(div.className, '0 svelte-x1o6ra');
component.testName1 = null;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'nulltest svelte-x1o6ra');
component.testName1 = undefined;
- component.testName2 = "test";
+ component.testName2 = 'test';
assert.equal(div.className, 'undefinedtest svelte-x1o6ra');
component.testName1 = undefined;
diff --git a/test/runtime/samples/attribute-null/_config.js b/test/runtime/samples/attribute-null/_config.js
index ae2f0a8af6..ded19eef79 100644
--- a/test/runtime/samples/attribute-null/_config.js
+++ b/test/runtime/samples/attribute-null/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `
`,
+ html: '
'
};
diff --git a/test/runtime/samples/attribute-prefer-expression/_config.js b/test/runtime/samples/attribute-prefer-expression/_config.js
index 29fcbc7f13..2388ff35df 100644
--- a/test/runtime/samples/attribute-prefer-expression/_config.js
+++ b/test/runtime/samples/attribute-prefer-expression/_config.js
@@ -2,7 +2,7 @@ export default {
skip_if_ssr: true,
props: {
- foo: false,
+ foo: false
},
test({ assert, component, target }) {
@@ -15,5 +15,5 @@ export default {
assert.ok(!inputs[0].checked);
assert.ok(inputs[1].checked);
- },
+ }
};
diff --git a/test/runtime/samples/attribute-static-at-symbol/_config.js b/test/runtime/samples/attribute-static-at-symbol/_config.js
index 40a45579a3..0be19f091f 100644
--- a/test/runtime/samples/attribute-static-at-symbol/_config.js
+++ b/test/runtime/samples/attribute-static-at-symbol/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `email `
-};
\ No newline at end of file
+ html: "email "
+};
diff --git a/test/runtime/samples/attribute-static-boolean/_config.js b/test/runtime/samples/attribute-static-boolean/_config.js
index c8b4332386..3dba036319 100644
--- a/test/runtime/samples/attribute-static-boolean/_config.js
+++ b/test/runtime/samples/attribute-static-boolean/_config.js
@@ -1,5 +1,5 @@
export default {
- html: ``,
+ html: '',
test({ assert, component, target }) {
const textarea = target.querySelector( 'textarea' );
assert.ok( textarea.readOnly );
diff --git a/test/runtime/samples/attribute-static-quotemarks/_config.js b/test/runtime/samples/attribute-static-quotemarks/_config.js
index 3d389c2273..e908052b4f 100644
--- a/test/runtime/samples/attribute-static-quotemarks/_config.js
+++ b/test/runtime/samples/attribute-static-quotemarks/_config.js
@@ -5,4 +5,4 @@ export default {
bar
`
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/attribute-static/_config.js b/test/runtime/samples/attribute-static/_config.js
index 5d3b9c81a8..60c3cb2fc0 100644
--- a/test/runtime/samples/attribute-static/_config.js
+++ b/test/runtime/samples/attribute-static/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `
`
+ html: '
'
};
diff --git a/test/runtime/samples/attribute-undefined/_config.js b/test/runtime/samples/attribute-undefined/_config.js
index ae2f0a8af6..ded19eef79 100644
--- a/test/runtime/samples/attribute-undefined/_config.js
+++ b/test/runtime/samples/attribute-undefined/_config.js
@@ -1,3 +1,3 @@
export default {
- html: `
`,
+ html: '
'
};
diff --git a/test/runtime/samples/attribute-unknown-without-value/_config.js b/test/runtime/samples/attribute-unknown-without-value/_config.js
index 4f7cf1cbbf..9645e86ef4 100644
--- a/test/runtime/samples/attribute-unknown-without-value/_config.js
+++ b/test/runtime/samples/attribute-unknown-without-value/_config.js
@@ -1,3 +1,3 @@
export default {
html: '
'
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-catch-shorthand/_config.js b/test/runtime/samples/await-catch-shorthand/_config.js
new file mode 100644
index 0000000000..fc65773107
--- /dev/null
+++ b/test/runtime/samples/await-catch-shorthand/_config.js
@@ -0,0 +1,41 @@
+let fulfil;
+
+let thePromise = new Promise(f => {
+ fulfil = f;
+});
+
+export default {
+ props: {
+ thePromise
+ },
+
+ html: '',
+
+ test({ assert, component, target }) {
+ fulfil(42);
+
+ return thePromise
+ .then(() => {
+ assert.htmlEqual(target.innerHTML, '');
+
+ let reject;
+
+ thePromise = new Promise((f, r) => {
+ reject = r;
+ });
+
+ component.thePromise = thePromise;
+
+ assert.htmlEqual(target.innerHTML, '');
+
+ reject(new Error('something broke'));
+
+ return thePromise.catch(() => {});
+ })
+ .then(() => {
+ assert.htmlEqual(target.innerHTML, `
+ oh no! something broke
+ `);
+ });
+ }
+};
diff --git a/test/runtime/samples/await-catch-shorthand/main.svelte b/test/runtime/samples/await-catch-shorthand/main.svelte
new file mode 100644
index 0000000000..844e7da08c
--- /dev/null
+++ b/test/runtime/samples/await-catch-shorthand/main.svelte
@@ -0,0 +1,7 @@
+
+
+{#await thePromise catch theError}
+ oh no! {theError.message}
+{/await}
\ No newline at end of file
diff --git a/test/runtime/samples/await-component-oncreate/_config.js b/test/runtime/samples/await-component-oncreate/_config.js
index 3cb8fa0864..1de86c9f44 100644
--- a/test/runtime/samples/await-component-oncreate/_config.js
+++ b/test/runtime/samples/await-component-oncreate/_config.js
@@ -13,4 +13,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-conservative-update/_config.js b/test/runtime/samples/await-conservative-update/_config.js
index 4e81ff8e37..20a9448ebd 100644
--- a/test/runtime/samples/await-conservative-update/_config.js
+++ b/test/runtime/samples/await-conservative-update/_config.js
@@ -13,4 +13,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-conservative-update/sleep.js b/test/runtime/samples/await-conservative-update/sleep.js
index 994f85f38a..be592a4ea4 100644
--- a/test/runtime/samples/await-conservative-update/sleep.js
+++ b/test/runtime/samples/await-conservative-update/sleep.js
@@ -8,4 +8,4 @@ export const sleep = ms => new Promise(f => {
if (stopped) return;
f();
}, ms);
-});
\ No newline at end of file
+});
diff --git a/test/runtime/samples/await-containing-if/_config.js b/test/runtime/samples/await-containing-if/_config.js
index cd83585cc1..a81b040a12 100644
--- a/test/runtime/samples/await-containing-if/_config.js
+++ b/test/runtime/samples/await-containing-if/_config.js
@@ -24,7 +24,7 @@ export default {
`);
component.show = false;
- assert.htmlEqual(target.innerHTML, `
`);
+ assert.htmlEqual(target.innerHTML, '
');
component.show = true;
assert.htmlEqual(target.innerHTML, `
@@ -32,4 +32,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-in-dynamic-component/_config.js b/test/runtime/samples/await-in-dynamic-component/_config.js
index 797298c554..d92757b68b 100644
--- a/test/runtime/samples/await-in-dynamic-component/_config.js
+++ b/test/runtime/samples/await-in-dynamic-component/_config.js
@@ -2,4 +2,4 @@ export default {
test({ component }) {
component.flag = false;
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-in-each/_config.js b/test/runtime/samples/await-in-each/_config.js
index 6c7da69ee3..a648bbe38a 100644
--- a/test/runtime/samples/await-in-each/_config.js
+++ b/test/runtime/samples/await-in-each/_config.js
@@ -28,4 +28,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-in-removed-if/_config.js b/test/runtime/samples/await-in-removed-if/_config.js
index 2f96f08e24..18b2ac7b74 100644
--- a/test/runtime/samples/await-in-removed-if/_config.js
+++ b/test/runtime/samples/await-in-removed-if/_config.js
@@ -9,7 +9,7 @@ export default {
promise
},
- html: ``,
+ html: '',
async test({ assert, component, target }) {
component.condition = false;
@@ -17,6 +17,6 @@ export default {
fulfil();
await new Promise(f => setTimeout(f, 0));
- assert.htmlEqual(target.innerHTML, ``);
+ assert.htmlEqual(target.innerHTML, '');
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-set-simultaneous-reactive/_config.js b/test/runtime/samples/await-set-simultaneous-reactive/_config.js
index a591bf424f..0b5c0b8c74 100644
--- a/test/runtime/samples/await-set-simultaneous-reactive/_config.js
+++ b/test/runtime/samples/await-set-simultaneous-reactive/_config.js
@@ -1,5 +1,5 @@
export default {
- html: `wait for it...
`,
+ html: 'wait for it...
',
test({ assert, component, target }) {
return component.promise
@@ -10,4 +10,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-set-simultaneous/_config.js b/test/runtime/samples/await-set-simultaneous/_config.js
index f9ed64e556..fb75a9f6f0 100644
--- a/test/runtime/samples/await-set-simultaneous/_config.js
+++ b/test/runtime/samples/await-set-simultaneous/_config.js
@@ -6,7 +6,7 @@ export default {
component.promise = promise;
- assert.htmlEqual(target.innerHTML, `wait for it...
`);
+ assert.htmlEqual(target.innerHTML, 'wait for it...
');
return promise
.then(() => {
@@ -15,4 +15,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-catch-event/_config.js b/test/runtime/samples/await-then-catch-event/_config.js
index e42d16c4d8..0f4ce27628 100644
--- a/test/runtime/samples/await-then-catch-event/_config.js
+++ b/test/runtime/samples/await-then-catch-event/_config.js
@@ -42,4 +42,4 @@ export default {
assert.equal(component.clicked, 43);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-catch-in-slot/_config.js b/test/runtime/samples/await-then-catch-in-slot/_config.js
index b0600a0f27..14f3e7fdf5 100644
--- a/test/runtime/samples/await-then-catch-in-slot/_config.js
+++ b/test/runtime/samples/await-then-catch-in-slot/_config.js
@@ -44,4 +44,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-catch-multiple/_config.js b/test/runtime/samples/await-then-catch-multiple/_config.js
index 2daac524a2..8d2de596df 100644
--- a/test/runtime/samples/await-then-catch-multiple/_config.js
+++ b/test/runtime/samples/await-then-catch-multiple/_config.js
@@ -48,4 +48,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-catch-no-values/_config.js b/test/runtime/samples/await-then-catch-no-values/_config.js
index 2c3ce45dc1..51a79a50d0 100644
--- a/test/runtime/samples/await-then-catch-no-values/_config.js
+++ b/test/runtime/samples/await-then-catch-no-values/_config.js
@@ -9,14 +9,14 @@ export default {
thePromise
},
- html: `waiting`,
+ html: 'waiting',
test({ assert, component, target }) {
fulfil(9000);
return thePromise
.then(() => {
- assert.htmlEqual(target.innerHTML, `resolved`);
+ assert.htmlEqual(target.innerHTML, 'resolved');
let reject;
@@ -26,14 +26,14 @@ export default {
component.thePromise = thePromise;
- assert.htmlEqual(target.innerHTML, `waiting`);
+ assert.htmlEqual(target.innerHTML, 'waiting');
reject(new Error('something broke'));
return thePromise.catch(() => {});
})
.then(() => {
- assert.htmlEqual(target.innerHTML, `rejected`);
+ assert.htmlEqual(target.innerHTML, 'rejected');
});
}
};
diff --git a/test/runtime/samples/await-then-catch-non-promise/_config.js b/test/runtime/samples/await-then-catch-non-promise/_config.js
index dbc2f5eddc..c05236cc5f 100644
--- a/test/runtime/samples/await-then-catch-non-promise/_config.js
+++ b/test/runtime/samples/await-then-catch-non-promise/_config.js
@@ -14,4 +14,4 @@ export default {
the value is still not a promise
`);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-catch-static/_config.js b/test/runtime/samples/await-then-catch-static/_config.js
index ada0dcc75b..35fc865d44 100644
--- a/test/runtime/samples/await-then-catch-static/_config.js
+++ b/test/runtime/samples/await-then-catch-static/_config.js
@@ -42,4 +42,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-catch/_config.js b/test/runtime/samples/await-then-catch/_config.js
index b0600a0f27..14f3e7fdf5 100644
--- a/test/runtime/samples/await-then-catch/_config.js
+++ b/test/runtime/samples/await-then-catch/_config.js
@@ -44,4 +44,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-destruct-array/_config.js b/test/runtime/samples/await-then-destruct-array/_config.js
new file mode 100644
index 0000000000..55c48481e0
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-array/_config.js
@@ -0,0 +1,61 @@
+export default {
+ props: {
+ thePromise: new Promise(resolve => {})
+ },
+
+ html: `
+ loading...
+ `,
+
+ async test({ assert, component, target }) {
+ await (component.thePromise = Promise.resolve([1, 2]));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ a: 1
+ b: 2
+ `
+ );
+
+ await (component.thePromise = Promise.resolve([4, 5]));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ a: 4
+ b: 5
+ `
+ );
+
+ try {
+ await (component.thePromise = Promise.reject(['a', [6, 7]]));
+ } catch (e) {
+ // do nothing
+ }
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ c: a
+ d: 6
+ e: 7
+ `
+ );
+
+ try {
+ await (component.thePromise = Promise.reject(['b', [8, 9]]));
+ } catch (e) {
+ // do nothing
+ }
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ c: b
+ d: 8
+ e: 9
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-then-destruct-array/main.svelte b/test/runtime/samples/await-then-destruct-array/main.svelte
new file mode 100644
index 0000000000..cc0d217f79
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-array/main.svelte
@@ -0,0 +1,14 @@
+
+
+{#await thePromise}
+ loading...
+{:then [ a, b ]}
+ a: {a}
+ b: {b}
+{:catch [c, [d, e]]}
+ c: {c}
+ d: {d}
+ e: {e}
+{/await}
\ No newline at end of file
diff --git a/test/runtime/samples/await-then-destruct-default/_config.js b/test/runtime/samples/await-then-destruct-default/_config.js
new file mode 100644
index 0000000000..d0e5a49f28
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-default/_config.js
@@ -0,0 +1,23 @@
+export default {
+ async test({ assert, component, target }) {
+ await Promise.resolve();
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ a: 3
+ b: 2
+ c: 3
+ a: 1
+ b: 2
+ c: 3
+ a: 3
+ b: 2
+ c: 3
+ a: 1
+ b: 2
+ c: 3
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-then-destruct-default/main.svelte b/test/runtime/samples/await-then-destruct-default/main.svelte
new file mode 100644
index 0000000000..d559aadab1
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-default/main.svelte
@@ -0,0 +1,34 @@
+
+
+{#await object then { a = 3, b = 4, c }}
+ a: {a}
+ b: {b}
+ c: {c}
+{/await}
+
+{#await array then [a, b, c = 3]}
+ a: {a}
+ b: {b}
+ c: {c}
+{/await}
+
+{#await objectReject then value}
+ resolved
+{:catch { a = 3, b = 4, c }}
+ a: {a}
+ b: {b}
+ c: {c}
+{/await}
+
+{#await arrayReject then value}
+ resolved
+{:catch [a, b, c = 3]}
+ a: {a}
+ b: {b}
+ c: {c}
+{/await}
\ No newline at end of file
diff --git a/test/runtime/samples/await-then-destruct-object-if/_config.js b/test/runtime/samples/await-then-destruct-object-if/_config.js
new file mode 100644
index 0000000000..6a29b2db37
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-object-if/_config.js
@@ -0,0 +1,29 @@
+export default {
+ props: {
+ thePromise: Promise.resolve({ result: 1 })
+ },
+
+ html: '',
+
+ async test({ assert, component, target }) {
+ await (component.thePromise = Promise.resolve({ result: 1 }));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ result: 1
+ count: 0
+ `
+ );
+
+ await new Promise(resolve => setTimeout(resolve, 1));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ result: 1
+ count: 1
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-then-destruct-object-if/main.svelte b/test/runtime/samples/await-then-destruct-object-if/main.svelte
new file mode 100644
index 0000000000..3425979e2c
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-object-if/main.svelte
@@ -0,0 +1,19 @@
+
+
+{#await thePromise then { result }}
+ {#if result}
+ result: {result}
+ count: {count}
+ {:else}
+ result: {result}
+ count: {count}
+ {/if}
+{/await}
diff --git a/test/runtime/samples/await-then-destruct-object/_config.js b/test/runtime/samples/await-then-destruct-object/_config.js
new file mode 100644
index 0000000000..7d08ad3711
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-object/_config.js
@@ -0,0 +1,63 @@
+export default {
+ props: {
+ thePromise: new Promise(resolve => {})
+ },
+
+ html: `
+ loading...
+ `,
+
+ async test({ assert, component, target }) {
+ await (component.thePromise = Promise.resolve({ error: 'error message' }));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ error: error message
+ result: undefined
+ `
+ );
+
+ await (component.thePromise = Promise.resolve({ result: '42' }));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ error: undefined
+ result: 42
+ `
+ );
+
+ try {
+ await (component.thePromise = Promise.reject({
+ error: { message: 'oops', code: '123' }
+ }));
+ } catch (e) {
+ // do nothing
+ }
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ message: oops
+ code: 123
+ `
+ );
+
+ try {
+ await (component.thePromise = Promise.reject({
+ error: { message: 'timeout', code: '456' }
+ }));
+ } catch (e) {
+ // do nothing
+ }
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ message: timeout
+ code: 456
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-then-destruct-object/main.svelte b/test/runtime/samples/await-then-destruct-object/main.svelte
new file mode 100644
index 0000000000..ff574b7be8
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-object/main.svelte
@@ -0,0 +1,13 @@
+
+
+{#await thePromise}
+ loading...
+{:then { result, error }}
+ error: {error}
+ result: {result}
+{:catch { error: { message, code } }}
+ message: {message}
+ code: {code}
+{/await}
\ No newline at end of file
diff --git a/test/runtime/samples/await-then-destruct-rest/_config.js b/test/runtime/samples/await-then-destruct-rest/_config.js
new file mode 100644
index 0000000000..528568e569
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-rest/_config.js
@@ -0,0 +1,21 @@
+export default {
+ async test({ assert, component, target }) {
+ await Promise.resolve();
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ a: 1
+ rest: {"b":2,"c":3}
+ a: 1
+ b: 2
+ rest: [3,4,5,6]
+ a: 1
+ rest: {"b":2,"c":3}
+ a: 1
+ b: 2
+ rest: [3,4,5,6]
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-then-destruct-rest/main.svelte b/test/runtime/samples/await-then-destruct-rest/main.svelte
new file mode 100644
index 0000000000..a2d57dabf3
--- /dev/null
+++ b/test/runtime/samples/await-then-destruct-rest/main.svelte
@@ -0,0 +1,32 @@
+
+
+{#await object then { a, ...rest }}
+ a: {a}
+ rest: {JSON.stringify(rest)}
+{/await}
+
+{#await array then [a, b, ...rest]}
+ a: {a}
+ b: {b}
+ rest: {JSON.stringify(rest)}
+{/await}
+
+{#await objectReject then value}
+ resolved
+{:catch { a, ...rest }}
+ a: {a}
+ rest: {JSON.stringify(rest)}
+{/await}
+
+{#await arrayReject then value}
+ resolved
+{:catch [a, b, ...rest]}
+ a: {a}
+ b: {b}
+ rest: {JSON.stringify(rest)}
+{/await}
\ No newline at end of file
diff --git a/test/runtime/samples/await-then-if/_config.js b/test/runtime/samples/await-then-if/_config.js
index b26688d9f3..f9e81dd2cc 100644
--- a/test/runtime/samples/await-then-if/_config.js
+++ b/test/runtime/samples/await-then-if/_config.js
@@ -22,4 +22,4 @@ export default {
promise array is empty
`);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-then-shorthand/_config.js b/test/runtime/samples/await-then-shorthand/_config.js
index 4635cf5127..ca07dd19e0 100644
--- a/test/runtime/samples/await-then-shorthand/_config.js
+++ b/test/runtime/samples/await-then-shorthand/_config.js
@@ -9,7 +9,7 @@ export default {
thePromise
},
- html: ``,
+ html: '',
test({ assert, component, target }) {
fulfil(42);
@@ -28,7 +28,7 @@ export default {
component.thePromise = thePromise;
- assert.htmlEqual(target.innerHTML, ``);
+ assert.htmlEqual(target.innerHTML, '');
reject(new Error('something broke'));
@@ -40,4 +40,4 @@ export default {
`);
});
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/await-with-update-2/Component.svelte b/test/runtime/samples/await-with-update-2/Component.svelte
new file mode 100644
index 0000000000..1301db3f99
--- /dev/null
+++ b/test/runtime/samples/await-with-update-2/Component.svelte
@@ -0,0 +1,7 @@
+
+
+count: {count}
+value: {value}
\ No newline at end of file
diff --git a/test/runtime/samples/await-with-update-2/_config.js b/test/runtime/samples/await-with-update-2/_config.js
new file mode 100644
index 0000000000..68f884c127
--- /dev/null
+++ b/test/runtime/samples/await-with-update-2/_config.js
@@ -0,0 +1,64 @@
+export default {
+ props: {
+ thePromise: new Promise((_) => {}),
+ count: 0
+ },
+
+ html: `
+
+ `,
+
+ async test({ assert, component, target }) {
+ await (component.thePromise = Promise.resolve({ value: 'success', Component: component.Component }));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ Resolved:
+
count: 0
+
value: success
+
+ `
+ );
+
+ component.count = 5;
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ Resolved:
+
count: 5
+
value: success
+
+ `
+ );
+
+ try {
+ await (component.thePromise = Promise.reject({ value: 'failure', Component: component.Component }));
+ } catch (error) {
+ // ignore
+ }
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ Rejected:
+
count: 5
+
value: failure
+
+ `
+ );
+
+ component.count = 10;
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+ Rejected:
+
count: 10
+
value: failure
+
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-with-update-2/main.svelte b/test/runtime/samples/await-with-update-2/main.svelte
new file mode 100644
index 0000000000..b29c875f92
--- /dev/null
+++ b/test/runtime/samples/await-with-update-2/main.svelte
@@ -0,0 +1,16 @@
+
+
+
+ {#await thePromise}
+
loading...
+ {:then { value: theValue, Component }}
+ Resolved:
+ {:catch { value: theError, Component } }
+ Rejected:
+ {/await}
+
\ No newline at end of file
diff --git a/test/runtime/samples/await-with-update/Component.svelte b/test/runtime/samples/await-with-update/Component.svelte
new file mode 100644
index 0000000000..5f13c80e65
--- /dev/null
+++ b/test/runtime/samples/await-with-update/Component.svelte
@@ -0,0 +1,5 @@
+
+
+count: {count}
\ No newline at end of file
diff --git a/test/runtime/samples/await-with-update/_config.js b/test/runtime/samples/await-with-update/_config.js
new file mode 100644
index 0000000000..08bf12b89e
--- /dev/null
+++ b/test/runtime/samples/await-with-update/_config.js
@@ -0,0 +1,60 @@
+export default {
+ props: {
+ thePromise: new Promise((_) => {}),
+ count: 0
+ },
+
+ html: `
+
+ `,
+
+ async test({ assert, component, target }) {
+ await (component.thePromise = Promise.resolve(component.Component));
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+
+ `
+ );
+
+ component.count = 5;
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+
+ `
+ );
+
+ try {
+ await (component.thePromise = Promise.reject(component.Component));
+ } catch (error) {
+ // ignore
+ }
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+
+ `
+ );
+
+ component.count = 10;
+
+ assert.htmlEqual(
+ target.innerHTML,
+ `
+
+ `
+ );
+ }
+};
diff --git a/test/runtime/samples/await-with-update/main.svelte b/test/runtime/samples/await-with-update/main.svelte
new file mode 100644
index 0000000000..51c5b76a21
--- /dev/null
+++ b/test/runtime/samples/await-with-update/main.svelte
@@ -0,0 +1,16 @@
+
+
+
+ {#await thePromise}
+
loading...
+ {:then theValue}
+ Resolved:
+ {:catch theError}
+ Rejected:
+ {/await}
+
\ No newline at end of file
diff --git a/test/runtime/samples/await-without-catch/_config.js b/test/runtime/samples/await-without-catch/_config.js
new file mode 100644
index 0000000000..5bc291bf1f
--- /dev/null
+++ b/test/runtime/samples/await-without-catch/_config.js
@@ -0,0 +1,45 @@
+let fulfil;
+
+let promise = new Promise(f => {
+ fulfil = f;
+});
+
+export default {
+ props: {
+ promise
+ },
+
+ html: `
+ loading...
+ `,
+
+ test({ assert, component, target }) {
+ fulfil(42);
+
+ return promise
+ .then(() => {
+ assert.htmlEqual(target.innerHTML, `
+ loaded
+ `);
+
+ let reject;
+
+ promise = new Promise((f, r) => {
+ reject = r;
+ });
+
+ component.promise = promise;
+
+ assert.htmlEqual(target.innerHTML, `
+ loading...
+ `);
+
+ reject(new Error('this error should be thrown'));
+ return promise;
+ })
+ .catch((err) => {
+ assert.equal(err.message, 'this error should be thrown');
+ assert.htmlEqual(target.innerHTML, '');
+ });
+ }
+};
diff --git a/test/runtime/samples/await-without-catch/main.svelte b/test/runtime/samples/await-without-catch/main.svelte
new file mode 100644
index 0000000000..f528a8bf69
--- /dev/null
+++ b/test/runtime/samples/await-without-catch/main.svelte
@@ -0,0 +1,9 @@
+
+
+{#await promise}
+ loading...
+{:then value}
+ loaded
+{/await}
\ No newline at end of file
diff --git a/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js b/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js
index d4c2b7cd0f..158536b5fb 100644
--- a/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js
+++ b/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js
@@ -8,6 +8,7 @@ export default {
assert.equal(component.t, 0);
assert.equal(component.d, 0);
assert.equal(component.v, 0.5);
+ assert.equal(component.m, true);
assert.equal(component.r, 1);
assert.equal(component.paused, true);
@@ -20,6 +21,7 @@ export default {
audio.currentTime = 10;
audio.duration = 20;
audio.volume = 0.75;
+ audio.muted = false;
audio.playbackRate = 2;
audio.dispatchEvent(timeupdate);
audio.dispatchEvent(durationchange);
@@ -30,6 +32,7 @@ export default {
assert.equal(component.t, 10);
assert.equal(component.d, 0); // not 20, because read-only. Not sure how to test this!
assert.equal(component.v, 0.75);
+ assert.equal(component.m, false);
assert.equal(component.r, 2);
assert.equal(component.paused, true); // ditto...
}
diff --git a/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte b/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte
index 69335182e8..e232c920bf 100644
--- a/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte
+++ b/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte
@@ -4,7 +4,8 @@
export let paused;
export let v;
export let r;
+ export let m;
-
\ No newline at end of file
diff --git a/test/runtime/samples/binding-contenteditable-html-initial/_config.js b/test/runtime/samples/binding-contenteditable-html-initial/_config.js
index 9eac2c9b17..4c30a3231a 100644
--- a/test/runtime/samples/binding-contenteditable-html-initial/_config.js
+++ b/test/runtime/samples/binding-contenteditable-html-initial/_config.js
@@ -36,5 +36,5 @@ export default {
goodbye
hello goodbye
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-contenteditable-html/_config.js b/test/runtime/samples/binding-contenteditable-html/_config.js
index ceb6a75c70..639572faea 100644
--- a/test/runtime/samples/binding-contenteditable-html/_config.js
+++ b/test/runtime/samples/binding-contenteditable-html/_config.js
@@ -1,6 +1,6 @@
export default {
props: {
- name: 'world ',
+ name: 'world '
},
html: `
@@ -34,5 +34,5 @@ export default {
goodbye
hello goodbye
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-contenteditable-text-initial/_config.js b/test/runtime/samples/binding-contenteditable-text-initial/_config.js
index 4899f30f12..d5f331bb7a 100644
--- a/test/runtime/samples/binding-contenteditable-text-initial/_config.js
+++ b/test/runtime/samples/binding-contenteditable-text-initial/_config.js
@@ -30,5 +30,5 @@ export default {
goodbye
hello goodbye
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-contenteditable-text/_config.js b/test/runtime/samples/binding-contenteditable-text/_config.js
index 9f8645724d..89f3968258 100644
--- a/test/runtime/samples/binding-contenteditable-text/_config.js
+++ b/test/runtime/samples/binding-contenteditable-text/_config.js
@@ -1,6 +1,6 @@
export default {
props: {
- name: 'world',
+ name: 'world'
},
html: `
@@ -28,5 +28,5 @@ export default {
goodbye
hello goodbye
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-indirect-computed/_config.js b/test/runtime/samples/binding-indirect-computed/_config.js
index 9834d0a228..860adf80f0 100644
--- a/test/runtime/samples/binding-indirect-computed/_config.js
+++ b/test/runtime/samples/binding-indirect-computed/_config.js
@@ -39,4 +39,4 @@ export default {
B
`);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/binding-indirect/_config.js b/test/runtime/samples/binding-indirect/_config.js
index a0a610f43f..e0f10b94bd 100644
--- a/test/runtime/samples/binding-indirect/_config.js
+++ b/test/runtime/samples/binding-indirect/_config.js
@@ -87,4 +87,4 @@ export default {
shake it all about
`);
}
-};
\ No newline at end of file
+};
diff --git a/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js b/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js
index 2e3a1c296f..9d099feb0a 100644
--- a/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js
+++ b/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js
@@ -2,7 +2,7 @@ export default {
skip_if_ssr: true,
props: {
- indeterminate: true,
+ indeterminate: true
},
html: `
@@ -38,5 +38,5 @@ export default {
checked? true
indeterminate? true
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js b/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js
index b502ed40af..1247414c1c 100644
--- a/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js
+++ b/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js
@@ -2,14 +2,14 @@ export default {
props: {
cats: [
{
- name: "cat 0",
- checked: false,
+ name: 'cat 0',
+ checked: false
},
{
- name: "cat 1",
- checked: false,
- },
- ],
+ name: 'cat 1',
+ checked: false
+ }
+ ]
},
html: `
@@ -21,8 +21,8 @@ export default {
const { cats } = component;
const newCats = cats.slice();
newCats.push({
- name: "cat " + cats.length,
- checked: false,
+ name: 'cat ' + cats.length,
+ checked: false
});
component.cats = newCats;
diff --git a/test/runtime/samples/binding-input-group-duplicate-value/_config.js b/test/runtime/samples/binding-input-group-duplicate-value/_config.js
new file mode 100644
index 0000000000..b5f3ae0115
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-duplicate-value/_config.js
@@ -0,0 +1,81 @@
+export default {
+ html: `
+ Checked:
+
+
+
+ a
+ b
+ c
+ d
+
+
+
+ a
+ b
+ c
+ d
+ `,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ const p = target.querySelector('p');
+
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+ assert.equal(inputs[3].checked, false);
+
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, false);
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+
+ const event = new window.Event('change');
+
+ inputs[0].checked = true;
+ await inputs[0].dispatchEvent(event);
+
+ assert.htmlEqual(p.innerHTML, 'Checked: a');
+
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+ assert.equal(inputs[3].checked, false);
+
+ assert.equal(inputs[4].checked, true);
+ assert.equal(inputs[5].checked, false);
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+
+ inputs[3].checked = true;
+ await inputs[3].dispatchEvent(event);
+
+ assert.htmlEqual(p.innerHTML, 'Checked: a,d');
+
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+ assert.equal(inputs[3].checked, true);
+
+ assert.equal(inputs[4].checked, true);
+ assert.equal(inputs[5].checked, false);
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, true);
+
+ inputs[4].checked = false;
+ await inputs[4].dispatchEvent(event);
+
+ assert.htmlEqual(p.innerHTML, 'Checked: d');
+
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+ assert.equal(inputs[3].checked, true);
+
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, false);
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, true);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-duplicate-value/main.svelte b/test/runtime/samples/binding-input-group-duplicate-value/main.svelte
new file mode 100644
index 0000000000..153e559d23
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-duplicate-value/main.svelte
@@ -0,0 +1,19 @@
+
+
+Checked: {foo}
+
+
+
+ a
+ b
+ c
+ d
+
+
+
+ a
+ b
+ c
+ d
\ No newline at end of file
diff --git a/test/runtime/samples/binding-input-group-each-1/_config.js b/test/runtime/samples/binding-input-group-each-1/_config.js
new file mode 100644
index 0000000000..92010296dc
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-1/_config.js
@@ -0,0 +1,275 @@
+const values = [
+ { name: 'Alpha' },
+ { name: 'Beta' },
+ { name: 'Gamma' }
+];
+
+const selected_array = [
+ [values[1]],
+ [],
+ [values[2]]
+];
+
+export default {
+ props: {
+ values,
+ selected_array
+ },
+
+ html: `
+
+
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, false);
+ assert.equal(inputs[3].checked, false);
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, false);
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, true);
+
+ const event = new window.Event('change');
+
+ inputs[0].checked = true;
+ await inputs[0].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+
+ `);
+ inputs[3].checked = true;
+ await inputs[3].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+
+ `);
+
+ inputs[8].checked = false;
+ await inputs[8].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+
+ `);
+
+ component.selected_array = [[values[1], values[2]], [values[2]]];
+
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, true);
+ assert.equal(inputs[3].checked, false);
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, true);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+ `);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-each-1/main.svelte b/test/runtime/samples/binding-input-group-each-1/main.svelte
new file mode 100644
index 0000000000..5ed255c83a
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-1/main.svelte
@@ -0,0 +1,15 @@
+
+
+{#each selected_array as selected}
+
+ {#each values as value}
+
+ {value.name}
+
+ {/each}
+
{selected.map(v => v.name).join(', ')}
+
+{/each}
diff --git a/test/runtime/samples/binding-input-group-each-2/_config.js b/test/runtime/samples/binding-input-group-each-2/_config.js
new file mode 100644
index 0000000000..78d692d979
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-2/_config.js
@@ -0,0 +1,59 @@
+export default {
+ html: `
+
+ 1
+
+
+ 2
+
+
+ 3
+
+
+ 1, 2, 3
`,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, true);
+
+ const event = new window.Event('change');
+
+ inputs[0].checked = false;
+ await inputs[0].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ 1
+
+
+ 2
+
+
+ 3
+
+
+ 2, 3
+ `);
+
+ component.selected = [[1, 3]];
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, true);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ 1
+
+
+ 2
+
+
+ 3
+
+
+ 1, 3
+ `);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-each-2/main.svelte b/test/runtime/samples/binding-input-group-each-2/main.svelte
new file mode 100644
index 0000000000..46f7e9e698
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-2/main.svelte
@@ -0,0 +1,17 @@
+
+
+{#each options as value}
+
+
+ {value}
+
+{/each}
+
+{selected[0].join(', ')}
\ No newline at end of file
diff --git a/test/runtime/samples/binding-input-group-each-3/_config.js b/test/runtime/samples/binding-input-group-each-3/_config.js
new file mode 100644
index 0000000000..92010296dc
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-3/_config.js
@@ -0,0 +1,275 @@
+const values = [
+ { name: 'Alpha' },
+ { name: 'Beta' },
+ { name: 'Gamma' }
+];
+
+const selected_array = [
+ [values[1]],
+ [],
+ [values[2]]
+];
+
+export default {
+ props: {
+ values,
+ selected_array
+ },
+
+ html: `
+
+
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, false);
+ assert.equal(inputs[3].checked, false);
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, false);
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, true);
+
+ const event = new window.Event('change');
+
+ inputs[0].checked = true;
+ await inputs[0].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+
+ `);
+ inputs[3].checked = true;
+ await inputs[3].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+
+ `);
+
+ inputs[8].checked = false;
+ await inputs[8].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+
+ `);
+
+ component.selected_array = [[values[1], values[2]], [values[2]]];
+
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, true);
+ assert.equal(inputs[3].checked, false);
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, true);
+
+ assert.htmlEqual(target.innerHTML, `
+
+
+ `);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-each-3/main.svelte b/test/runtime/samples/binding-input-group-each-3/main.svelte
new file mode 100644
index 0000000000..42a7a1c4e9
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-3/main.svelte
@@ -0,0 +1,15 @@
+
+
+{#each selected_array as _, index}
+
+ {#each values as value}
+
+ {value.name}
+
+ {/each}
+
{selected_array[index].map(v => v.name).join(', ')}
+
+{/each}
diff --git a/test/runtime/samples/binding-input-group-each-4/_config.js b/test/runtime/samples/binding-input-group-each-4/_config.js
new file mode 100644
index 0000000000..f1168858b0
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-4/_config.js
@@ -0,0 +1,153 @@
+export default {
+ html: `
+ 1
+ 2
+ 3
+ 1
+ 1
+ 2
+ 3
+ 2
+ 1
+ 2
+ 3
+
+ 1
+ 2
+ 3
+ 3
+ `,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+
+ assert.equal(inputs[3].checked, false);
+ assert.equal(inputs[4].checked, true);
+ assert.equal(inputs[5].checked, false);
+
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, false);
+
+ assert.equal(inputs[9].checked, false);
+ assert.equal(inputs[10].checked, false);
+ assert.equal(inputs[11].checked, true);
+
+ const event = new window.Event('change');
+
+ inputs[2].checked = true;
+ await inputs[2].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 3
+ 1
+ 2
+ 3
+ 2
+ 1
+ 2
+ 3
+
+ 1
+ 2
+ 3
+ 3
+ `);
+
+ inputs[9].checked = true;
+ await inputs[9].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 3
+ 1
+ 2
+ 3
+ 2
+ 1
+ 2
+ 3
+
+ 1
+ 2
+ 3
+ 1, 3
+ `);
+
+ inputs[4].checked = false;
+ await inputs[4].dispatchEvent(event);
+ inputs[5].checked = true;
+ await inputs[5].dispatchEvent(event);
+ inputs[6].checked = true;
+ await inputs[6].dispatchEvent(event);
+ inputs[7].checked = true;
+ await inputs[7].dispatchEvent(event);
+ inputs[11].checked = false;
+ await inputs[11].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 3
+ 1
+ 2
+ 3
+ 3
+ 1
+ 2
+ 3
+ 1, 2
+ 1
+ 2
+ 3
+ 1
+ `);
+
+ component.selected_array_1 = [[3], [1]];
+ component.selected_array_2 = [[], [2]];
+
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, true);
+
+ assert.equal(inputs[3].checked, true);
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, false);
+
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, false);
+
+ assert.equal(inputs[9].checked, false);
+ assert.equal(inputs[10].checked, true);
+ assert.equal(inputs[11].checked, false);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 3
+ 1
+ 2
+ 3
+ 1
+ 1
+ 2
+ 3
+
+ 1
+ 2
+ 3
+ 2
+ `);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-each-4/main.svelte b/test/runtime/samples/binding-input-group-each-4/main.svelte
new file mode 100644
index 0000000000..0bbf5ea763
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-4/main.svelte
@@ -0,0 +1,33 @@
+
+
+{#each selected_array_1 as selected}
+ {#each options as value}
+
+
+ {value}
+
+ {/each}
+ {selected.join(', ')}
+{/each}
+
+{#each selected_array_2 as selected}
+ {#each options as value}
+
+
+ {value}
+
+ {/each}
+ {selected.join(', ')}
+{/each}
\ No newline at end of file
diff --git a/test/runtime/samples/binding-input-group-each-5/_config.js b/test/runtime/samples/binding-input-group-each-5/_config.js
new file mode 100644
index 0000000000..579225c627
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-5/_config.js
@@ -0,0 +1,160 @@
+export default {
+ html: `
+ 1
+ 2
+ 3
+ 1
+ 1
+ 2
+ 3
+ 1, 2, 3
+ 1
+ 2
+ 3
+ 2
+ 1
+ 2
+ 3
+ 1
+ `,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+
+ assert.equal(inputs[3].checked, true);
+ assert.equal(inputs[4].checked, true);
+ assert.equal(inputs[5].checked, true);
+
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, true);
+ assert.equal(inputs[8].checked, false);
+
+ assert.equal(inputs[9].checked, true);
+ assert.equal(inputs[10].checked, false);
+ assert.equal(inputs[11].checked, false);
+
+ const event = new window.Event('change');
+
+ inputs[2].checked = true;
+ await inputs[2].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 3
+ 1
+ 2
+ 3
+ 1, 2, 3
+ 1
+ 2
+ 3
+ 2
+ 1
+ 2
+ 3
+ 1
+ `);
+
+ inputs[8].checked = true;
+ await inputs[8].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 3
+ 1
+ 2
+ 3
+ 1, 2, 3
+ 1
+ 2
+ 3
+ 2, 3
+ 1
+ 2
+ 3
+ 1
+ `);
+
+ component.selected_index = [1, 1];
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 2, 3
+ 1
+ 2
+ 3
+ 1, 2, 3
+ 1
+ 2
+ 3
+ 1
+ 1
+ 2
+ 3
+ 1
+ `);
+
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, true);
+
+ assert.equal(inputs[3].checked, true);
+ assert.equal(inputs[4].checked, true);
+ assert.equal(inputs[5].checked, true);
+
+ assert.equal(inputs[6].checked, true);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, false);
+
+ assert.equal(inputs[9].checked, true);
+ assert.equal(inputs[10].checked, false);
+ assert.equal(inputs[11].checked, false);
+
+ inputs[5].checked = false;
+ await inputs[5].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ 1
+ 2
+ 3
+ 1, 2
+ 1
+ 2
+ 3
+ 1, 2
+ 1
+ 2
+ 3
+ 1
+ 1
+ 2
+ 3
+ 1
+ `);
+
+ assert.equal(inputs[0].checked, true);
+ assert.equal(inputs[1].checked, true);
+ assert.equal(inputs[2].checked, false);
+
+ assert.equal(inputs[3].checked, true);
+ assert.equal(inputs[4].checked, true);
+ assert.equal(inputs[5].checked, false);
+
+ assert.equal(inputs[6].checked, true);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, false);
+
+ assert.equal(inputs[9].checked, true);
+ assert.equal(inputs[10].checked, false);
+ assert.equal(inputs[11].checked, false);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-each-5/main.svelte b/test/runtime/samples/binding-input-group-each-5/main.svelte
new file mode 100644
index 0000000000..93bdce6510
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-5/main.svelte
@@ -0,0 +1,24 @@
+
+
+{#each selected_array as selected}
+ {#each selected_index as index}
+ {#each options as value}
+
+
+ {value}
+
+ {/each}
+ {selected[index].join(', ')}
+ {/each}
+{/each}
diff --git a/test/runtime/samples/binding-input-group-each-6/_config.js b/test/runtime/samples/binding-input-group-each-6/_config.js
new file mode 100644
index 0000000000..9eb251bf5d
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-6/_config.js
@@ -0,0 +1,87 @@
+export default {
+ html: `
+ x
+ y
+ z
+
+ x
+ y
+ z
+
+ x
+ y
+ z
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const inputs = target.querySelectorAll('input');
+ assert.equal(inputs[0].checked, false);
+ assert.equal(inputs[1].checked, false);
+ assert.equal(inputs[2].checked, false);
+
+ assert.equal(inputs[3].checked, false);
+ assert.equal(inputs[4].checked, false);
+ assert.equal(inputs[5].checked, false);
+
+ assert.equal(inputs[6].checked, false);
+ assert.equal(inputs[7].checked, false);
+ assert.equal(inputs[8].checked, false);
+
+ const event = new window.Event('change');
+
+ inputs[2].checked = true;
+ await inputs[2].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ x
+ y
+ z
+ z
+ x
+ y
+ z
+
+ x
+ y
+ z
+
+ `);
+
+ inputs[4].checked = true;
+ await inputs[4].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ x
+ y
+ z
+ z
+ x
+ y
+ z
+ y
+ x
+ y
+ z
+
+ `);
+
+ inputs[5].checked = true;
+ await inputs[5].dispatchEvent(event);
+
+ assert.htmlEqual(target.innerHTML, `
+ x
+ y
+ z
+ z
+ x
+ y
+ z
+ y, z
+ x
+ y
+ z
+
+ `);
+ }
+};
diff --git a/test/runtime/samples/binding-input-group-each-6/main.svelte b/test/runtime/samples/binding-input-group-each-6/main.svelte
new file mode 100644
index 0000000000..85be939e8a
--- /dev/null
+++ b/test/runtime/samples/binding-input-group-each-6/main.svelte
@@ -0,0 +1,22 @@
+
+
+{#each Object.keys(list) as key}
+ {#each values as value}
+
+
+ {value}
+
+ {/each}
+ {list[key].join(', ')}
+{/each}
diff --git a/test/runtime/samples/binding-input-number-2/_config.js b/test/runtime/samples/binding-input-number-2/_config.js
new file mode 100644
index 0000000000..4411eac0b2
--- /dev/null
+++ b/test/runtime/samples/binding-input-number-2/_config.js
@@ -0,0 +1,31 @@
+export default {
+ test({ assert, target, window, component }) {
+ const input = target.querySelector('input');
+ const inputEvent = new window.InputEvent('input');
+ assert.equal(component.value, 5);
+ assert.equal(input.value, '5');
+
+ input.value = '5.';
+ input.dispatchEvent(inputEvent);
+
+ // input type number has value === "" if ends with dot/comma
+ assert.equal(component.value, undefined);
+ assert.equal(input.value, '');
+
+ input.value = '5.5';
+ input.dispatchEvent(inputEvent);
+
+ assert.equal(component.value, 5.5);
+ assert.equal(input.value, '5.5');
+
+ input.value = '5.50';
+ input.dispatchEvent(inputEvent);
+
+ assert.equal(component.value, 5.5);
+ assert.equal(input.value, '5.50');
+
+ component.value = 1;
+ assert.equal(component.value, 1);
+ assert.equal(input.value, '1');
+ }
+};
diff --git a/test/runtime/samples/binding-input-number-2/main.svelte b/test/runtime/samples/binding-input-number-2/main.svelte
new file mode 100644
index 0000000000..62119547a0
--- /dev/null
+++ b/test/runtime/samples/binding-input-number-2/main.svelte
@@ -0,0 +1,5 @@
+
+
+
diff --git a/test/runtime/samples/binding-input-number/_config.js b/test/runtime/samples/binding-input-number/_config.js
index 869b9f9896..1a56a75c0c 100644
--- a/test/runtime/samples/binding-input-number/_config.js
+++ b/test/runtime/samples/binding-input-number/_config.js
@@ -1,6 +1,6 @@
export default {
props: {
- count: 42,
+ count: 42
},
html: `
@@ -35,14 +35,14 @@ export default {
number 44
`);
- // empty string should be treated as undefined
+ // empty string should be treated as null
input.value = '';
await input.dispatchEvent(event);
- assert.equal(component.count, undefined);
+ assert.equal(component.count, null);
assert.htmlEqual(target.innerHTML, `
- undefined undefined
+ object null
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-range-change-with-max/_config.js b/test/runtime/samples/binding-input-range-change-with-max/_config.js
index 1fda90d83c..dc3cf4ce28 100644
--- a/test/runtime/samples/binding-input-range-change-with-max/_config.js
+++ b/test/runtime/samples/binding-input-range-change-with-max/_config.js
@@ -29,5 +29,5 @@ export default {
20 of 20
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-range-change/_config.js b/test/runtime/samples/binding-input-range-change/_config.js
index 62e9562770..f6ec2d9c53 100644
--- a/test/runtime/samples/binding-input-range-change/_config.js
+++ b/test/runtime/samples/binding-input-range-change/_config.js
@@ -1,6 +1,6 @@
export default {
props: {
- count: 42,
+ count: 42
},
html: `
@@ -34,5 +34,5 @@ export default {
number 44
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-range/_config.js b/test/runtime/samples/binding-input-range/_config.js
index 4c3d37a667..dc6178e088 100644
--- a/test/runtime/samples/binding-input-range/_config.js
+++ b/test/runtime/samples/binding-input-range/_config.js
@@ -1,6 +1,6 @@
export default {
props: {
- count: 42,
+ count: 42
},
html: `
@@ -34,5 +34,5 @@ export default {
number 44
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js b/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js
index 28cffdfa57..de4d6325b0 100644
--- a/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js
+++ b/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js
@@ -1,7 +1,7 @@
export default {
props: {
foo: 'a',
- items: ['x'],
+ items: ['x']
},
html: `
@@ -32,5 +32,5 @@ export default {
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-text-contextual-reactive/_config.js b/test/runtime/samples/binding-input-text-contextual-reactive/_config.js
index 6fdfc4be52..a1584c18b8 100644
--- a/test/runtime/samples/binding-input-text-contextual-reactive/_config.js
+++ b/test/runtime/samples/binding-input-text-contextual-reactive/_config.js
@@ -121,5 +121,5 @@ export default {
done:one / done:two / remaining:four
`);
- },
+ }
};
diff --git a/test/runtime/samples/binding-input-text-contextual/_config.js b/test/runtime/samples/binding-input-text-contextual/_config.js
index bb7f16c8bb..1c66ea7ff5 100644
--- a/test/runtime/samples/binding-input-text-contextual/_config.js
+++ b/test/runtime/samples/binding-input-text-contextual/_config.js
@@ -1,6 +1,6 @@
export default {
props: {
- items: ['one', 'two', 'three'],
+ items: ['one', 'two', 'three']
},
html: `
@@ -65,5 +65,5 @@ export default {
five