fix: handle undefined bubble events (#9614)

Fixes #9610
pull/9626/head
Dominic Gannaway 2 years ago committed by GitHub
parent 0283e50070
commit 8118efd115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: handle undefined bubble events

@ -1530,7 +1530,7 @@ export function bubble_event($$props, event) {
const events = /** @type {Record<string, Function[] | Function>} */ (unwrap($$props).$$events)?.[
event.type
];
const callbacks = is_array(events) ? events.slice() : [events];
const callbacks = is_array(events) ? events.slice() : events == null ? [] : [events];
let fn;
for (fn of callbacks) {
// Preserve "this" context

@ -0,0 +1,14 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
async test({ assert, target }) {
const input = target.querySelector('input');
flushSync(() => {
input?.click();
});
assert.htmlEqual(target.innerHTML, `<input>`);
}
});
Loading…
Cancel
Save