Skip to content

Commit f00a403

Browse files
committed
simplify
1 parent e5a500a commit f00a403

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import { CallExpression, Expression, MemberExpression, Pattern, SequenceExpression } from 'estree' */
1+
/** @import { CallExpression, Expression, MemberExpression, Pattern } from 'estree' */
22
/** @import { AST, SvelteNode } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
44
import { dev, is_ignored } from '../../../../state.js';

packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,16 @@ export function build_element_attributes(node, context) {
109109
const binding = binding_properties[attribute.name];
110110
if (binding?.omit_in_ssr) continue;
111111

112-
const get =
113-
attribute.expression.type === 'SequenceExpression'
114-
? b.call(/** @type {Expression} */ (context.visit(attribute.expression.expressions[0])))
115-
: /** @type {Expression} */ (context.visit(attribute.expression));
112+
let expression = /** @type {Expression} */ (context.visit(attribute.expression));
113+
114+
if (expression.type === 'SequenceExpression') {
115+
expression = b.call(expression.expressions[0]);
116+
}
116117

117118
if (is_content_editable_binding(attribute.name)) {
118-
content = get;
119+
content = expression;
119120
} else if (attribute.name === 'value' && node.name === 'textarea') {
120-
content = b.call('$.escape', get);
121+
content = b.call('$.escape', expression);
121122
} else if (attribute.name === 'group' && attribute.expression.type !== 'SequenceExpression') {
122123
const value_attribute = /** @type {AST.Attribute | undefined} */ (
123124
node.attributes.find((attr) => attr.type === 'Attribute' && attr.name === 'value')
@@ -163,7 +164,7 @@ export function build_element_attributes(node, context) {
163164
start: -1,
164165
end: -1,
165166
parent: attribute,
166-
expression: get,
167+
expression,
167168
metadata: {
168169
expression: create_expression_metadata()
169170
}

0 commit comments

Comments
 (0)