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 = {
99const linkFiber = require ( './linkFiber' ) ( snapShot , mode ) ;
1010const timeJump = require ( './timeJump' ) ( snapShot , mode ) ;
1111
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
1425 switch ( action ) {
1526 case 'jumpToSnap' :
1627 timeJump ( payload ) ;
1728 // Get the pathname from payload and add new entry to browser history
1829 // 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 ) ) ;
2331 break ;
2432 case 'setLock' :
2533 mode . locked = payload ;
You can’t perform that action at this time.
0 commit comments