File tree Expand file tree Collapse file tree 1 file changed +2
-14
lines changed
packages/svelte/src/compiler/phases/2-analyze/visitors/shared Expand file tree Collapse file tree 1 file changed +2
-14
lines changed Original file line number Diff line number Diff line change 11/** @import { AST } from '#compiler' */
2- /** @import { Expression } from 'estree' */
32/** @import { AnalysisState, Context } from '../../types' */
43import * as e from '../../../../errors.js' ;
54import { 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 ) ;
You can’t perform that action at this time.
0 commit comments