Skip to content

Commit 9fb9881

Browse files
committed
use existing helpers
1 parent d1d99d2 commit 9fb9881

File tree

1 file changed

+2
-14
lines changed
  • packages/svelte/src/compiler/phases/2-analyze/visitors/shared

1 file changed

+2
-14
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/** @import { AST } from '#compiler' */
2-
/** @import { Expression } from 'estree' */
32
/** @import { AnalysisState, Context } from '../../types' */
43
import * as e from '../../../../errors.js';
54
import { get_attribute_expression, is_expression_attribute } from '../../../../utils/ast.js';
@@ -24,27 +23,16 @@ export function visit_component(node, context) {
2423
let resolved = true;
2524

2625
for (const attribute of node.attributes) {
27-
/** @type {Expression | undefined} */
28-
let expression;
29-
3026
if (attribute.type === 'SpreadAttribute' || attribute.type === 'BindDirective') {
3127
resolved = false;
3228
continue;
3329
}
3430

35-
if (attribute.type !== 'Attribute' || attribute.value === true) {
31+
if (attribute.type !== 'Attribute' || !is_expression_attribute(attribute)) {
3632
continue;
3733
}
3834

39-
if (Array.isArray(attribute.value)) {
40-
if (attribute.value.length === 1 && attribute.value[0].type === 'ExpressionTag') {
41-
expression = attribute.value[0].expression;
42-
}
43-
} else {
44-
expression = attribute.value.expression;
45-
}
46-
47-
if (!expression) continue;
35+
const expression = get_attribute_expression(attribute);
4836

4937
if (expression.type === 'Identifier') {
5038
const binding = context.state.scope.get(expression.name);

0 commit comments

Comments
 (0)