You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/js/samples/dev-warning-missing-data-co.../expected.js

132 lines
3.0 KiB

5 years ago
/* generated by Svelte vX.Y.Z */
6 years ago
import {
SvelteComponentDev,
add_location,
5 years ago
append_dev,
detach_dev,
dispatch_dev,
6 years ago
element,
init,
5 years ago
insert_dev,
6 years ago
noop,
safe_not_equal,
5 years ago
set_data_dev,
space,
text,
validate_slots
6 years ago
} from "svelte/internal";
const file = undefined;
function create_fragment(ctx) {
let p;
let t0_value = Math.max(0, /*foo*/ ctx[0]) + "";
let t0;
let t1;
let t2;
5 years ago
const block = {
c: function create() {
6 years ago
p = element("p");
t0 = text(t0_value);
t1 = space();
t2 = text(/*bar*/ ctx[1]);
6 years ago
add_location(p, file, 7, 0, 67);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
},
m: function mount(target, anchor) {
5 years ago
insert_dev(target, p, anchor);
append_dev(p, t0);
append_dev(p, t1);
append_dev(p, t2);
},
p: function update(ctx, [dirty]) {
if (dirty & /*foo*/ 1 && t0_value !== (t0_value = Math.max(0, /*foo*/ ctx[0]) + "")) set_data_dev(t0, t0_value);
if (dirty & /*bar*/ 2) set_data_dev(t2, /*bar*/ ctx[1]);
},
i: noop,
o: noop,
6 years ago
d: function destroy(detaching) {
if (detaching) detach_dev(p);
6 years ago
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_fragment.name,
type: "component",
source: "",
ctx
});
5 years ago
return block;
}
function instance($$self, $$props, $$invalidate) {
let { foo } = $$props;
let bar;
const writable_props = ["foo"];
Object.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(`<Component> was created with unknown prop '${key}'`);
});
let { $$slots = {}, $$scope } = $$props;
validate_slots("Component", $$slots, []);
6 years ago
$$self.$set = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
};
$$self.$capture_state = () => ({ foo, bar });
5 years ago
$$self.$inject_state = $$props => {
if ("foo" in $$props) $$invalidate(0, foo = $$props.foo);
if ("bar" in $$props) $$invalidate(1, bar = $$props.bar);
5 years ago
};
if ($$props && "$$inject" in $$props) {
$$self.$inject_state($$props.$$inject);
}
$$self.$$.update = () => {
if ($$self.$$.dirty & /*foo*/ 1) {
$: $$invalidate(1, bar = foo * 2);
}
};
return [foo, bar];
}
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Component",
options,
id: create_fragment.name
});
const { ctx } = this.$$;
const props = options.props || {};
if (/*foo*/ ctx[0] === undefined && !("foo" in props)) {
console.warn("<Component> was created without expected prop 'foo'");
}
}
6 years ago
get foo() {
throw new Error("<Component>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
6 years ago
}
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/>'");
6 years ago
}
}
5 years ago
export default Component;