Skip to content

Commit 50546dd

Browse files
committed
fix: ensure SvelteDate cached methods have no reactive context
1 parent 29d686c commit 50546dd

File tree

2 files changed

+4
-2
lines changed
  • packages/svelte/src

2 files changed

+4
-2
lines changed

packages/svelte/src/internal/client/dom/elements/bindings/shared.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function listen(target, events, handler, call_handler_immediately = true)
3434
/**
3535
* @template T
3636
* @param {() => T} fn
37+
* @returns {T}
3738
*/
3839
export function without_reactive_context(fn) {
3940
var previous_reaction = active_reaction;

packages/svelte/src/reactivity/date.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/** @import { Source } from '#client' */
2+
import { without_reactive_context } from '../internal/client/dom/elements/bindings/shared.js';
23
import { derived } from '../internal/client/index.js';
34
import { source, set } from '../internal/client/reactivity/sources.js';
4-
import { get, untrack } from '../internal/client/runtime.js';
5+
import { get } from '../internal/client/runtime.js';
56

67
var inited = false;
78

@@ -46,7 +47,7 @@ export class SvelteDate extends Date {
4647
// We don't want to associate the derived with the current
4748
// reactive context, as that means the derived will get destroyed
4849
// each time it re-fires
49-
d = untrack(() =>
50+
d = without_reactive_context(() =>
5051
derived(() => {
5152
get(this.#time);
5253
// @ts-ignore

0 commit comments

Comments
 (0)