File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
packages/svelte/src/reactivity Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 11/** @import { Source } from '#client' */
2- import { DESTROYED } from '../internal/client/constants.js' ;
32import { derived } from '../internal/client/index.js' ;
43import { source , set } from '../internal/client/reactivity/sources.js' ;
5- import { get } from '../internal/client/runtime.js' ;
4+ import { get , untrack } from '../internal/client/runtime.js' ;
65
76var inited = false ;
87
@@ -43,12 +42,17 @@ export class SvelteDate extends Date {
4342
4443 var d = this . #deriveds. get ( method ) ;
4544
46- if ( d === undefined || ( d . f & DESTROYED ) !== 0 ) {
47- d = derived ( ( ) => {
48- get ( this . #time) ;
49- // @ts -ignore
50- return date_proto [ method ] . apply ( this , args ) ;
51- } ) ;
45+ if ( d === undefined ) {
46+ // We don't want to associate the derived with the current
47+ // reactive context, as that means the derived will get destroyed
48+ // each time it re-fires
49+ d = untrack ( ( ) =>
50+ derived ( ( ) => {
51+ get ( this . #time) ;
52+ // @ts -ignore
53+ return date_proto [ method ] . apply ( this , args ) ;
54+ } )
55+ ) ;
5256
5357 this . #deriveds. set ( method , d ) ;
5458 }
You can’t perform that action at this time.
0 commit comments