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 1818 "rollup" : " ^1.27.4" ,
1919 "rollup-plugin-node-resolve" : " ^5.0.0" ,
2020 "rollup-plugin-svelte" : " ^5.1.1" ,
21- "svelte" : " ^3.16.0 " ,
21+ "svelte" : " ^3.20.1 " ,
2222 "svelte-listener" : " git+https://github.com/RedHatter/svelte-listener.git" ,
2323 "svgexport" : " ^0.3.2" ,
2424 "tiny-glob" : " ^0.2.6" ,
Original file line number Diff line number Diff line change 22 getNode ,
33 addNodeListener ,
44 startProfiler ,
5- stopProfiler
5+ stopProfiler ,
6+ getSvelteVersion
67} from 'svelte-listener'
78import { highlight , startPicker , stopPicker } from './highlight.js'
89
@@ -72,6 +73,24 @@ function clone(value, seen = new Map()) {
7273 }
7374}
7475
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+
7594function serializeNode ( node ) {
7695 const serialized = {
7796 id : node . id ,
@@ -89,7 +108,11 @@ function serializeNode(node) {
89108 const props = Array . isArray ( internal . props )
90109 ? internal . props // Svelte < 3.13.0 stored props names as an array
91110 : 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+
93116 serialized . detail = {
94117 attributes : props . flatMap ( key => {
95118 delete ctx [ key ]
You can’t perform that action at this time.
0 commit comments