Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] destructuring store assignment #6529

Merged
merged 3 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/runtime/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ export function null_to_empty(value) {
return value == null ? '' : value;
}

export function set_store_value(store, ret, value = ret) {
export function set_store_value(store, ret, value) {
if (arguments.length === 2) value = ret;
store.set(value);
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
html: `
<div>$userName1: user1</div>
<div>$userName2: undefined</div>
<div>$userName3: undefined</div>
<div>$userName4: user4</div>
<div>$userName5: undefined</div>
<div>$userName6: user6</div>
<div>$userName7: undefined</div>
`
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script>
import { writable } from 'svelte/store';

let userName1 = writable('init1')
let userName2 = writable('init2')
let userName3 = writable('init3')
let userName4 = writable('init4')
let userName5 = writable('init5')
let userName6 = writable('init6')
let userName7 = writable('init7')

let obj = {
userName1: 'user1',
userName2: 'user2',
userName3: 'user3',
$userName4: 'user4',
userName5: 'user5',
$userName6: 'user6',
userName7: 'user7',
}

;({userName1: $userName1, $userName2 } = obj)
dummdidumm marked this conversation as resolved.
Show resolved Hide resolved
;({$userName3} = obj)
;({$userName4} = obj)
;({$userName5, $userName6, $userName7} = obj)
</script>

<div>$userName1: {$userName1}</div>
<div>$userName2: {$userName2}</div>
<div>$userName3: {$userName3}</div>
<div>$userName4: {$userName4}</div>
<div>$userName5: {$userName5}</div>
<div>$userName6: {$userName6}</div>
<div>$userName7: {$userName7}</div>