Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Prev Previous commit
Revert "one down"
This reverts commit 9f6c4cf.
  • Loading branch information
Rich-Harris committed May 20, 2025
commit 2b13874dae14585b38051f849904d56a81448c2e
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ export function build_component(node, component_name, context, anchor = context.
let expression = /** @type {Expression} */ (context.visit(attribute.expression));

if (attribute.metadata.expression.has_state) {
push_prop(b.get(b.call('$.attachment'), [b.return(expression)], true));
} else {
push_prop(b.prop('init', b.call('$.attachment'), expression, true));
expression = b.arrow([b.id('$$node')], b.call(expression, b.id('$$node')));
}

push_prop(b.prop('get', b.call('$.attachment'), expression, true));
}
}

Expand Down
12 changes: 3 additions & 9 deletions packages/svelte/src/compiler/utils/builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,12 @@ export function function_declaration(id, params, body) {
}

/**
* @param {ESTree.Expression | string} name
* @param {string} name
* @param {ESTree.Statement[]} body
* @param {boolean} computed
* @returns {ESTree.Property & { value: ESTree.FunctionExpression}}}
*/
export function get(name, body, computed = false) {
return prop(
'get',
typeof name === 'string' ? key(name) : name,
function_builder(null, [], block(body)),
computed
);
export function get(name, body) {
return prop('get', key(name), function_builder(null, [], block(body)));
}

/**
Expand Down