File tree Expand file tree Collapse file tree 2 files changed +25
-15
lines changed
packages/svelte/src/internal/client/dev Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure snapshot logs don't affect dependency graph
Original file line number Diff line number Diff line change 1
1
import { STATE_SYMBOL } from '../constants.js' ;
2
2
import { snapshot } from '../../shared/clone.js' ;
3
3
import * as w from '../warnings.js' ;
4
+ import { untrack } from '../runtime.js' ;
4
5
5
6
/**
6
7
* @param {string } method
7
8
* @param {...any } objects
8
9
*/
9
10
export function log_if_contains_state ( method , ...objects ) {
10
- let has_state = false ;
11
- const transformed = [ ] ;
11
+ untrack ( ( ) => {
12
+ try {
13
+ let has_state = false ;
14
+ const transformed = [ ] ;
12
15
13
- for ( const obj of objects ) {
14
- if ( obj && typeof obj === 'object' && STATE_SYMBOL in obj ) {
15
- transformed . push ( snapshot ( obj , true ) ) ;
16
- has_state = true ;
17
- } else {
18
- transformed . push ( obj ) ;
19
- }
20
- }
16
+ for ( const obj of objects ) {
17
+ if ( obj && typeof obj === 'object' && STATE_SYMBOL in obj ) {
18
+ transformed . push ( snapshot ( obj , true ) ) ;
19
+ has_state = true ;
20
+ } else {
21
+ transformed . push ( obj ) ;
22
+ }
23
+ }
21
24
22
- if ( has_state ) {
23
- w . console_log_state ( method ) ;
25
+ if ( has_state ) {
26
+ w . console_log_state ( method ) ;
24
27
25
- // eslint-disable-next-line no-console
26
- console . log ( '%c[snapshot]' , 'color: grey' , ...transformed ) ;
27
- }
28
+ // eslint-disable-next-line no-console
29
+ console . log ( '%c[snapshot]' , 'color: grey' , ...transformed ) ;
30
+ }
31
+ } catch { }
32
+ } ) ;
28
33
29
34
return objects ;
30
35
}
You can’t perform that action at this time.
0 commit comments