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