File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 18
18
"rollup" : " ^1.27.4" ,
19
19
"rollup-plugin-node-resolve" : " ^5.0.0" ,
20
20
"rollup-plugin-svelte" : " ^5.1.1" ,
21
- "svelte" : " ^3.16.0 " ,
21
+ "svelte" : " ^3.20.1 " ,
22
22
"svelte-listener" : " git+https://github.com/RedHatter/svelte-listener.git" ,
23
23
"svgexport" : " ^0.3.2" ,
24
24
"tiny-glob" : " ^0.2.6" ,
Original file line number Diff line number Diff line change 2
2
getNode ,
3
3
addNodeListener ,
4
4
startProfiler ,
5
- stopProfiler
5
+ stopProfiler ,
6
+ getSvelteVersion
6
7
} from 'svelte-listener'
7
8
import { highlight , startPicker , stopPicker } from './highlight.js'
8
9
@@ -72,6 +73,24 @@ function clone(value, seen = new Map()) {
72
73
}
73
74
}
74
75
76
+ function gte ( major , minor , patch ) {
77
+ const version = ( getSvelteVersion ( ) || '0.0.0' )
78
+ . split ( '.' )
79
+ . map ( n => parseInt ( n ) )
80
+ return (
81
+ version [ 0 ] > major ||
82
+ ( version [ 0 ] == major &&
83
+ ( version [ 1 ] > minor || ( version [ 1 ] == minor && version [ 2 ] >= patch ) ) )
84
+ )
85
+ }
86
+
87
+ let _shouldUseCapture = null
88
+ function shouldUseCapture ( ) {
89
+ return _shouldUseCapture == null
90
+ ? ( _shouldUseCapture = gte ( 3 , 19 , 2 ) )
91
+ : _shouldUseCapture
92
+ }
93
+
75
94
function serializeNode ( node ) {
76
95
const serialized = {
77
96
id : node . id ,
@@ -89,7 +108,11 @@ function serializeNode(node) {
89
108
const props = Array . isArray ( internal . props )
90
109
? internal . props // Svelte < 3.13.0 stored props names as an array
91
110
: Object . keys ( internal . props )
92
- const ctx = clone ( internal . ctx )
111
+ let ctx = clone (
112
+ shouldUseCapture ( ) ? node . detail . $capture_state ( ) : internal . ctx
113
+ )
114
+ if ( ctx === undefined ) ctx = { }
115
+
93
116
serialized . detail = {
94
117
attributes : props . flatMap ( key => {
95
118
delete ctx [ key ]
You can’t perform that action at this time.
0 commit comments