@@ -92,7 +92,6 @@ pub fn back(self: *Navigation, page: *Page) !NavigationReturn {
9292
9393 const new_index = self ._index - 1 ;
9494 const next_entry = self ._entries .items [new_index ];
95- self ._index = new_index ;
9695
9796 return self .navigateInner (next_entry ._url , .{ .traverse = new_index }, page );
9897}
@@ -108,7 +107,6 @@ pub fn forward(self: *Navigation, page: *Page) !NavigationReturn {
108107
109108 const new_index = self ._index + 1 ;
110109 const next_entry = self ._entries .items [new_index ];
111- self ._index = new_index ;
112110
113111 return self .navigateInner (next_entry ._url , .{ .traverse = new_index }, page );
114112}
@@ -132,7 +130,10 @@ pub fn updateEntries(self: *Navigation, url: [:0]const u8, kind: NavigationKind,
132130// This is only really safe to run in the `pageDoneCallback` where we can guarantee that the URL and NavigationKind are correct.
133131pub fn processNavigation (self : * Navigation , page : * Page ) ! void {
134132 const url = page .url ;
133+
135134 const kind : NavigationKind = self ._current_navigation_kind orelse .{ .push = null };
135+ defer self ._current_navigation_kind = null ;
136+
136137 try self .updateEntries (url , kind , page , false );
137138}
138139
@@ -247,9 +248,11 @@ pub fn navigateInner(
247248 const committed = try page .js .createPromiseResolver (.page );
248249 const finished = try page .js .createPromiseResolver (.page );
249250
250- const new_url = try URL .resolve (arena , url , page . url , .{});
251+ const new_url = try URL .resolve (arena , page . url , url , .{});
251252 const is_same_document = URL .eqlDocument (new_url , page .url );
252253
254+ const previous = self .getCurrentEntry ();
255+
253256 switch (kind ) {
254257 .push = > | state | {
255258 if (is_same_document ) {
@@ -261,8 +264,7 @@ pub fn navigateInner(
261264
262265 _ = try self .pushEntry (url , .{ .source = .navigation , .value = state }, page , true );
263266 } else {
264- // try page.navigate(url, .{ .reason = .navigation }, kind);
265- try page .navigate (url , .{ .reason = .navigation });
267+ try page .navigate (url , .{ .reason = .navigation }, kind );
266268 }
267269 },
268270 .replace = > | state | {
@@ -275,8 +277,7 @@ pub fn navigateInner(
275277
276278 _ = try self .replaceEntry (url , .{ .source = .navigation , .value = state }, page , true );
277279 } else {
278- // try page.navigate(url, .{ .reason = .navigation }, kind);
279- try page .navigate (url , .{ .reason = .navigation });
280+ try page .navigate (url , .{ .reason = .navigation }, kind );
280281 }
281282 },
282283 .traverse = > | index | {
@@ -289,16 +290,22 @@ pub fn navigateInner(
289290 // todo: Fire navigate event
290291 finished .resolve ("navigation traverse" , {});
291292 } else {
292- // try page.navigate(url, .{ .reason = .navigation }, kind);
293- try page .navigate (url , .{ .reason = .navigation });
293+ try page .navigate (url , .{ .reason = .navigation }, kind );
294294 }
295295 },
296296 .reload = > {
297- // try page.navigate(url, .{ .reason = .navigation }, kind);
298- try page .navigate (url , .{ .reason = .navigation });
297+ try page .navigate (url , .{ .reason = .navigation }, kind );
299298 },
300299 }
301300
301+ // If we haven't navigated off, let us fire off an a currententrychange.
302+ const event = try NavigationCurrentEntryChangeEvent .init (
303+ "currententrychange" ,
304+ .{ .from = previous , .navigationType = @tagName (kind ) },
305+ page ,
306+ );
307+ try self ._proto .dispatch (.{ .currententrychange = event }, page );
308+
302309 return .{
303310 .committed = committed .promise (),
304311 .finished = finished .promise (),
0 commit comments