Skip to content

Commit 8118efd

Browse files
authored
fix: handle undefined bubble events (#9614)
Fixes #9610
1 parent 0283e50 commit 8118efd

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

.changeset/forty-comics-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: handle undefined bubble events

packages/svelte/src/internal/client/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ export function bubble_event($$props, event) {
15301530
const events = /** @type {Record<string, Function[] | Function>} */ (unwrap($$props).$$events)?.[
15311531
event.type
15321532
];
1533-
const callbacks = is_array(events) ? events.slice() : [events];
1533+
const callbacks = is_array(events) ? events.slice() : events == null ? [] : [events];
15341534
let fn;
15351535
for (fn of callbacks) {
15361536
// Preserve "this" context
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
async test({ assert, target }) {
6+
const input = target.querySelector('input');
7+
8+
flushSync(() => {
9+
input?.click();
10+
});
11+
12+
assert.htmlEqual(target.innerHTML, `<input>`);
13+
}
14+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<input on:click />

0 commit comments

Comments
 (0)