Skip to content

Commit 59e26bf

Browse files
committed
don't delegate when bindings/actions on the same element in order to preserve backwards compatibility of ordering
1 parent 6e6e6ca commit 59e26bf

File tree

1 file changed

+12
-1
lines changed
  • packages/svelte/src/compiler/phases/2-analyze

1 file changed

+12
-1
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ function determine_element_spread_and_delegatable(node) {
10281028
let events = new Map();
10291029
let has_spread = false;
10301030
let has_on = false;
1031+
let has_action_or_bind = false;
10311032
for (const attribute of node.attributes) {
10321033
if (
10331034
attribute.type === 'OnDirective' ||
@@ -1046,10 +1047,20 @@ function determine_element_spread_and_delegatable(node) {
10461047
}
10471048
} else if (!has_spread && attribute.type === 'SpreadAttribute') {
10481049
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;
10491055
}
10501056
}
10511057
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);
10531064
node.metadata.has_spread = has_spread;
10541065

10551066
return node;

0 commit comments

Comments
 (0)