Make sure this works when first var is reassigned store in destructure context

pull/8846/head
Nguyen Tran 3 years ago
parent 8e70bf79f4
commit 342ce159f7

@ -438,7 +438,7 @@ export default function dom(component, options) {
const unsubscribe = `$$unsubscribe_${name}`; const unsubscribe = `$$unsubscribe_${name}`;
const subscribe = `$$subscribe_${name}`; const subscribe = `$$subscribe_${name}`;
const i = renderer.context_lookup.get($name).index; const i = renderer.context_lookup.get($name).index;
return b`let ${$name}, ${unsubscribe} = @noop, ${subscribe} = () => (${unsubscribe}(), ${unsubscribe} = @subscribe(${name}, $$value => $$invalidate(${i}, ${$name} = $$value)), ${name})`; return b`let ${$name}, ${unsubscribe} = @noop, ${subscribe} = (#node) => (${unsubscribe}(), ${unsubscribe} = @subscribe(${name}, $$value => $$invalidate(${i}, ${$name} = $$value)), #node)`;
} }
return b`let ${$name};`; return b`let ${$name};`;
}); });

@ -65,7 +65,7 @@ export default function ssr(component, options) {
if (store && store.reassigned) { if (store && store.reassigned) {
const unsubscribe = `$$unsubscribe_${store_name}`; const unsubscribe = `$$unsubscribe_${store_name}`;
const subscribe = `$$subscribe_${store_name}`; const subscribe = `$$subscribe_${store_name}`;
return b`let ${name}, ${unsubscribe} = @noop, ${subscribe} = () => (${unsubscribe}(), ${unsubscribe} = @subscribe(${store_name}, $$value => ${name} = $$value), ${store_name})`; return b`let ${name}, ${unsubscribe} = @noop, ${subscribe} = (#node) => (${unsubscribe}(), ${unsubscribe} = @subscribe(${store_name}, $$value => ${name} = $$value), #node)`;
} }
return b`let ${name}, ${`$$unsubscribe_${store_name}`};`; return b`let ${name}, ${`$$unsubscribe_${store_name}`};`;
}); });

@ -104,7 +104,7 @@ function instance($$self, $$props, $$invalidate) {
let $prop, let $prop,
$$unsubscribe_prop = noop, $$unsubscribe_prop = noop,
$$subscribe_prop = () => ($$unsubscribe_prop(), $$unsubscribe_prop = subscribe(prop, $$value => $$invalidate(2, $prop = $$value)), prop); $$subscribe_prop = node => ($$unsubscribe_prop(), $$unsubscribe_prop = subscribe(prop, $$value => $$invalidate(2, $prop = $$value)), node);
$$self.$$.on_destroy.push(() => $$unsubscribe_prop()); $$self.$$.on_destroy.push(() => $$unsubscribe_prop());
let { $$slots: slots = {}, $$scope } = $$props; let { $$slots: slots = {}, $$scope } = $$props;

@ -65,7 +65,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {
let $foo, let $foo,
$$unsubscribe_foo = noop, $$unsubscribe_foo = noop,
$$subscribe_foo = () => ($$unsubscribe_foo(), $$unsubscribe_foo = subscribe(foo, $$value => $$invalidate(1, $foo = $$value)), foo); $$subscribe_foo = node => ($$unsubscribe_foo(), $$unsubscribe_foo = subscribe(foo, $$value => $$invalidate(1, $foo = $$value)), node);
$$self.$$.on_destroy.push(() => $$unsubscribe_foo()); $$self.$$.on_destroy.push(() => $$unsubscribe_foo());
let foo = writable(0); let foo = writable(0);

@ -138,7 +138,7 @@ function instance($$self, $$props, $$invalidate) {
let $reactiveDeclaration, let $reactiveDeclaration,
$$unsubscribe_reactiveDeclaration = noop, $$unsubscribe_reactiveDeclaration = noop,
$$subscribe_reactiveDeclaration = () => ($$unsubscribe_reactiveDeclaration(), $$unsubscribe_reactiveDeclaration = subscribe(reactiveDeclaration, $$value => $$invalidate(3, $reactiveDeclaration = $$value)), reactiveDeclaration); $$subscribe_reactiveDeclaration = node => ($$unsubscribe_reactiveDeclaration(), $$unsubscribe_reactiveDeclaration = subscribe(reactiveDeclaration, $$value => $$invalidate(3, $reactiveDeclaration = $$value)), node);
component_subscribe($$self, reactiveStoreVal, $$value => $$invalidate(2, $reactiveStoreVal = $$value)); component_subscribe($$self, reactiveStoreVal, $$value => $$invalidate(2, $reactiveStoreVal = $$value));
$$self.$$.on_destroy.push(() => $$unsubscribe_reactiveDeclaration()); $$self.$$.on_destroy.push(() => $$unsubscribe_reactiveDeclaration());

@ -10,12 +10,12 @@
secondStore: writable(6) secondStore: writable(6)
}; };
({ firstNonStore, secondNonStore, thirdNonStore, fourthNonStore, $firstStore, $secondStore } = { ({ firstNonStore, secondNonStore, thirdNonStore, fourthNonStore, firstStore, $secondStore } = {
firstNonStore: 7, firstNonStore: 7,
secondNonStore: 8, secondNonStore: 8,
thirdNonStore: 9, thirdNonStore: 9,
fourthNonStore: 11, fourthNonStore: 11,
$firstStore: 10, firstStore: writable(10),
$secondStore: 12 $secondStore: 12
}); });
</script> </script>

@ -14,12 +14,12 @@
function changeStores() { function changeStores() {
$bagOlStores = ({ $bagOlStores = ({
thirdStore,
$secondStore,
$firstStore,
firstNonStore, firstNonStore,
secondNonStore, secondNonStore,
thirdNonStore, thirdNonStore,
$firstStore,
$secondStore,
thirdStore
} = { } = {
firstNonStore: 7, firstNonStore: 7,
secondNonStore: 8, secondNonStore: 8,

@ -11,14 +11,14 @@
firstNonStore, firstNonStore,
secondNonStore, secondNonStore,
thirdNonStore, thirdNonStore,
$firstStore, firstStore,
$secondStore, $secondStore,
thirdStore thirdStore
] = [ ] = [
7, 7,
8, 8,
9, 9,
10, writable(10),
11, 11,
writable(12), writable(12),
writable(14), writable(14),

Loading…
Cancel
Save