fix: handle member expressions in directives (#10576)

pull/10571/head
Ahmad 10 months ago committed by GitHub
parent 802bfcabec
commit d6e0fbd8ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: handle member expressions in directives

@ -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);

@ -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>

Loading…
Cancel
Save