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 subscribe = `$$subscribe_${name}`;
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};`;
});

@ -65,7 +65,7 @@ export default function ssr(component, options) {
if (store && store.reassigned) {
const unsubscribe = `$$unsubscribe_${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}`};`;
});

@ -104,7 +104,7 @@ function instance($$self, $$props, $$invalidate) {
let $prop,
$$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());
let { $$slots: slots = {}, $$scope } = $$props;

@ -65,7 +65,7 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let $foo,
$$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());
let foo = writable(0);

@ -138,7 +138,7 @@ function instance($$self, $$props, $$invalidate) {
let $reactiveDeclaration,
$$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));
$$self.$$.on_destroy.push(() => $$unsubscribe_reactiveDeclaration());

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

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

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

Loading…
Cancel
Save