Skip to content

Commit e372742

Browse files
committed
fix
1 parent a87006e commit e372742

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,10 @@ const common_visitors = {
11621162
});
11631163

11641164
if (is_event_attribute(node)) {
1165-
context.state.analysis.uses_event_attributes = true;
1165+
const parent = context.path.at(-1);
1166+
if (parent?.type === 'RegularElement' || parent?.type === 'SvelteElement') {
1167+
context.state.analysis.uses_event_attributes = true;
1168+
}
11661169

11671170
const expression = node.value[0].expression;
11681171

packages/svelte/src/compiler/phases/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface ComponentAnalysis extends Analysis {
6262
needs_props: boolean;
6363
/** Set to the first event directive (on:x) found on a DOM element in the code */
6464
event_directive_node: OnDirective | null;
65-
/** true if uses event attributes (onclick) */
65+
/** true if uses event attributes (onclick) on a DOM element */
6666
uses_event_attributes: boolean;
6767
custom_element: boolean | SvelteOptions['customElement'];
6868
/** If `true`, should append styles through JavaScript */

0 commit comments

Comments
 (0)