File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 3939// event on location change and even that without interception support, etc.
4040! ( function ( ) {
4141 if ( window . navigation == undefined ) {
42+
43+ class NavigationEvent extends CustomEvent {
44+ constructor ( ) {
45+ super ( "navigate" ) ;
46+ this . destination = { url : undefined } ;
47+ }
48+ }
49+
4250 // Create a navigation object on the window
4351 // We create a DOM element for the navigation object so that we can
4452 // attach events on it.
4553 window . navigation = document . createElement ( "div" ) ;
4654
55+ const create_event = ( args ) => {
56+ event = new NavigationEvent ( ) ;
57+ event . destination . url = args [ 2 ] ;
58+ return event ;
59+ } ;
60+
4761 // Patch pushState to trigger an `navigate` event on the navigation
4862 // object when the URL changes.
4963 const pushState = window . history . pushState ;
5064 window . history . pushState = function ( ) {
5165 pushState . apply ( window . history , arguments ) ;
52- window . navigation . dispatchEvent ( new Event ( "navigate" ) ) ;
66+ window . navigation . dispatchEvent ( create_event ( arguments ) ) ;
5367 } ;
5468
5569 // Same with replaceState
5670 const replaceState = window . history . replaceState ;
5771 window . history . replaceState = function ( ) {
5872 replaceState . apply ( window . history , arguments ) ;
59- window . navigation . dispatchEvent ( new Event ( "navigate" ) ) ;
73+ window . navigation . dispatchEvent ( create_event ( arguments ) ) ;
6074 } ;
6175 }
6276} ) ( ) ;
You can’t perform that action at this time.
0 commit comments