diff --git a/CHANGELOG.md b/CHANGELOG.md index 415ed8d97a..c6aae8177d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * **breaking** Error on falsy values instead of stores passed to `derived` ([#7947](https://github.com/sveltejs/svelte/pull/7947)) * **breaking** Custom store implementers now need to pass an `update` function additionally to the `set` function ([#6750](https://github.com/sveltejs/svelte/pull/6750)) * **breaking** Change order in which preprocessors are applied ([#8618](https://github.com/sveltejs/svelte/pull/8618)) +* **breaking** The runtime now makes use of `classList.toggle(name, boolean)` which does not work in very old browsers ([#8629](https://github.com/sveltejs/svelte/pull/8629)) * **breaking** apply `inert` to outroing elements ([#8627](https://github.com/sveltejs/svelte/pull/8627)) * Add a way to modify attributes for script/style preprocessors ([#8618](https://github.com/sveltejs/svelte/pull/8618)) * Improve hydration speed by adding `data-svelte-h` attribute to detect unchanged HTML elements ([#7426](https://github.com/sveltejs/svelte/pull/7426)) diff --git a/src/runtime/internal/dom.js b/src/runtime/internal/dom.js index 935950c36d..aced965a67 100644 --- a/src/runtime/internal/dom.js +++ b/src/runtime/internal/dom.js @@ -993,7 +993,8 @@ export { ResizeObserverSingleton }; /** * @returns {void} */ export function toggle_class(element, name, toggle) { - element.classList[toggle ? 'add' : 'remove'](name); + // The `!!` is required because an `undefined` flag means flipping the current state. + element.classList.toggle(name, !!toggle); } /**