Skip to content

Commit

Permalink
fix fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
swyxio committed Feb 15, 2020
1 parent a93242a commit 054453b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 27 deletions.
4 changes: 3 additions & 1 deletion src/runtime/internal/dev.ts
Expand Up @@ -81,7 +81,9 @@ export function set_data_dev(text, data) {

export function validate_each_argument(arg) {
if (arg instanceof Set || arg instanceof Map) {
throw new Error(`Svelte does not allow Sets or Maps in an {#each} block. Use [...arg.values()] instead.`);
throw new Error(
`Svelte does not allow Sets or Maps in an {#each} block. Use [...arg.values()] or [...arg.entries()] instead.`
);
}
if (arg.length === undefined) {
throw new Error(
Expand Down
74 changes: 52 additions & 22 deletions test/js/samples/debug-foo-bar-baz-things/expected.js
Expand Up @@ -13,7 +13,8 @@ import {
safe_not_equal,
set_data_dev,
space,
text
text,
validate_each_argument
} from "svelte/internal";

const file = undefined;
Expand Down Expand Up @@ -54,7 +55,11 @@ function create_each_block(ctx) {
insert_dev(target, t1, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[4].name + "")) set_data_dev(t0, t0_value);
if (
dirty & /*things*/ 1 &&
t0_value !== (t0_value = /*thing*/ ctx[4].name + "")
)
set_data_dev(t0, t0_value);

if (dirty & /*foo, bar, baz, things*/ 15) {
const foo = /*foo*/ ctx[1];
Expand Down Expand Up @@ -88,6 +93,7 @@ function create_fragment(ctx) {
let t1;
let t2;
let each_value = /*things*/ ctx[0];
validate_each_argument(each_value);
let each_blocks = [];

for (let i = 0; i < each_value.length; i += 1) {
Expand All @@ -107,7 +113,9 @@ function create_fragment(ctx) {
add_location(p, file, 12, 0, 182);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
throw new Error(
"options.hydrate only works if the component was compiled with the `hydratable: true` option"
);
},
m: function mount(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
Expand Down Expand Up @@ -173,25 +181,26 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ["things", "foo", "bar", "baz"];

Object.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(`<Component> was created with unknown prop '${key}'`);
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$")
console.warn(`<Component> was created with unknown prop '${key}'`);
});

$$self.$set = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
if ("bar" in $$props) $$invalidate(2, bar = $$props.bar);
if ("baz" in $$props) $$invalidate(3, baz = $$props.baz);
if ("things" in $$props) $$invalidate(0, (things = $$props.things));
if ("foo" in $$props) $$invalidate(1, (foo = $$props.foo));
if ("bar" in $$props) $$invalidate(2, (bar = $$props.bar));
if ("baz" in $$props) $$invalidate(3, (baz = $$props.baz));
};

$$self.$capture_state = () => {
return { things, foo, bar, baz };
};

$$self.$inject_state = $$props => {
if ("things" in $$props) $$invalidate(0, things = $$props.things);
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
if ("bar" in $$props) $$invalidate(2, bar = $$props.bar);
if ("baz" in $$props) $$invalidate(3, baz = $$props.baz);
if ("things" in $$props) $$invalidate(0, (things = $$props.things));
if ("foo" in $$props) $$invalidate(1, (foo = $$props.foo));
if ("bar" in $$props) $$invalidate(2, (bar = $$props.bar));
if ("baz" in $$props) $$invalidate(3, (baz = $$props.baz));
};

return [things, foo, bar, baz];
Expand All @@ -200,7 +209,12 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 1, bar: 2, baz: 3 });
init(this, options, instance, create_fragment, safe_not_equal, {
things: 0,
foo: 1,
bar: 2,
baz: 3
});

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down Expand Up @@ -230,36 +244,52 @@ class Component extends SvelteComponentDev {
}

get things() {
throw new Error("<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

set things(value) {
throw new Error("<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

get foo() {
throw new Error("<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

set foo(value) {
throw new Error("<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

get bar() {
throw new Error("<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

set bar(value) {
throw new Error("<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

get baz() {
throw new Error("<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}

set baz(value) {
throw new Error("<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
throw new Error(
"<Component>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'"
);
}
}

export default Component;
export default Component;
10 changes: 7 additions & 3 deletions test/js/samples/debug-no-dependencies/expected.js
Expand Up @@ -10,7 +10,8 @@ import {
noop,
safe_not_equal,
space,
text
text,
validate_each_argument
} from "svelte/internal";

const file = undefined;
Expand Down Expand Up @@ -64,6 +65,7 @@ function create_each_block(ctx) {
function create_fragment(ctx) {
let each_1_anchor;
let each_value = things;
validate_each_argument(each_value);
let each_blocks = [];

for (let i = 0; i < each_value.length; i += 1) {
Expand All @@ -79,7 +81,9 @@ function create_fragment(ctx) {
each_1_anchor = empty();
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
throw new Error(
"options.hydrate only works if the component was compiled with the `hydratable: true` option"
);
},
m: function mount(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
Expand Down Expand Up @@ -145,4 +149,4 @@ class Component extends SvelteComponentDev {
}
}

export default Component;
export default Component;
Expand Up @@ -2,5 +2,5 @@ export default {
compileOptions: {
dev: true
},
error: `Svelte does not allow Sets or Maps in an {#each} block. Use [...arg.values()] instead.`
error: `Svelte does not allow Sets or Maps in an {#each} block. Use [...arg.values()] or [...arg.entries()] instead.`
};

0 comments on commit 054453b

Please sign in to comment.