simplify handling of noop $capture_state/$inject_state

pull/3822/head
Conduitry 6 years ago
parent dde2b21dbc
commit 1a38d043b1

@ -169,9 +169,9 @@ export default function dom(
const capturable_vars = component.vars.filter(v => !v.internal && !v.name.startsWith('$$'));
capture_state = capturable_vars.length > 0
? x`() => ({ ${capturable_vars.map(prop => p`${prop.name}`)} })`
: x`@noop`;
if (capturable_vars.length > 0) {
capture_state = x`() => ({ ${capturable_vars.map(prop => p`${prop.name}`)} })`;
}
const injectable_vars = capturable_vars.filter(v => !v.module && v.writable && v.name[0] !== '$');
@ -190,8 +190,6 @@ export default function dom(
$$self.$inject_state($$props.$$inject);
}
`;
} else {
inject_state = x`@noop`;
}
}

@ -120,6 +120,10 @@ export class SvelteComponentDev extends SvelteComponent {
console.warn(`Component was already destroyed`); // eslint-disable-line no-console
};
}
$capture_state() {}
$inject_state() {}
}
export function loop_guard(timeout) {

@ -134,16 +134,10 @@ function create_fragment(ctx) {
return block;
}
function instance($$self, $$props, $$invalidate) {
$$self.$capture_state = noop;
$$self.$inject_state = noop;
return [];
}
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, {});
init(this, options, null, create_fragment, safe_not_equal, {});
dispatch_dev("SvelteRegisterComponent", {
component: this,

Loading…
Cancel
Save