File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,27 @@ const mode = {
9
9
const linkFiber = require ( './linkFiber' ) ( snapShot , mode ) ;
10
10
const timeJump = require ( './timeJump' ) ( snapShot , mode ) ;
11
11
12
- window . addEventListener ( 'message' , ( { data : { action, payload } } ) => {
13
- //runs automatically twice per second with inspectedElement
12
+ let url = '/' ;
13
+ function getRouteURL ( node ) {
14
+ if ( node . name === 'Router' ) {
15
+ url = node . state . location . pathname ;
16
+ }
17
+ if ( node . children . length >= 1 ) {
18
+ const tempNode = node . children ;
19
+ for ( let index = 0 ; index < tempNode . length ; index += 1 ) {
20
+ getRouteURL ( tempNode [ index ] ) ;
21
+ }
22
+ }
23
+ }
24
+
25
+ window . addEventListener ( 'message' , ( { data : { action, payload } } ) => { // runs automatically twice per second with inspectedElement
14
26
switch ( action ) {
15
27
case 'jumpToSnap' :
16
28
timeJump ( payload ) ;
29
+ getRouteURL ( payload ) ;
17
30
// Get the pathname from payload and add new entry to browser history
18
31
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
19
- if ( payload . children [ 0 ] . state && payload . children [ 0 ] . state . location ) {
20
- const route = payload . children [ 0 ] . state . location . pathname ;
21
- window . history . pushState ( '' , '' , route ) ;
22
- }
32
+ window . history . pushState ( '' , '' , url ) ;
23
33
break ;
24
34
case 'setLock' :
25
35
mode . locked = payload ;
You can’t perform that action at this time.
0 commit comments