File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/svelte/src/compiler/phases/2-analyze Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1028,6 +1028,7 @@ function determine_element_spread_and_delegatable(node) {
1028
1028
let events = new Map ( ) ;
1029
1029
let has_spread = false ;
1030
1030
let has_on = false ;
1031
+ let has_action_or_bind = false ;
1031
1032
for ( const attribute of node . attributes ) {
1032
1033
if (
1033
1034
attribute . type === 'OnDirective' ||
@@ -1046,10 +1047,20 @@ function determine_element_spread_and_delegatable(node) {
1046
1047
}
1047
1048
} else if ( ! has_spread && attribute . type === 'SpreadAttribute' ) {
1048
1049
has_spread = true ;
1050
+ } else if (
1051
+ ! has_action_or_bind &&
1052
+ ( attribute . type === 'BindDirective' || attribute . type === 'UseDirective' )
1053
+ ) {
1054
+ has_action_or_bind = true ;
1049
1055
}
1050
1056
}
1051
1057
node . metadata . can_delegate_events =
1052
- ! ( has_spread && has_on ) && ! [ ...events . values ( ) ] . some ( ( count ) => count > 1 ) ;
1058
+ // Actions/bindings need the old on:-events to fire in order
1059
+ ! has_action_or_bind &&
1060
+ // spreading events means we don't know if there's an event attribute with the same name as an on:-event
1061
+ ! ( has_spread && has_on ) &&
1062
+ // multiple on:-events/event attributes with the same name
1063
+ ! [ ...events . values ( ) ] . some ( ( count ) => count > 1 ) ;
1053
1064
node . metadata . has_spread = has_spread ;
1054
1065
1055
1066
return node ;
You can’t perform that action at this time.
0 commit comments