Skip to content

fix: handle member expressions in directives #10576

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

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/good-rivers-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: handle member expressions in directives
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/phases/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
* @type {import('zimmerframe').Visitor<import('#compiler').AnimateDirective | import('#compiler').TransitionDirective | import('#compiler').UseDirective, State, import('#compiler').SvelteNode>}
*/
const SvelteDirective = (node, { state, path, visit }) => {
state.scope.reference(b.id(node.name), path);
state.scope.reference(b.id(node.name.split('.')[0]), path);

if (node.expression) {
visit(node.expression);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<script>
import { writable } from 'svelte/store';

let action = writable((node, text) => {
let store = writable({action: (node, text) => {
node.textContent = text;
});
return {
destroy() {}
}
}});

let text = writable('mounted')
let text = writable('mounted');
</script>

<div use:$action={$text}>hello</div>
<div use:$store.action={$text}>hello</div>