@@ -197,7 +197,7 @@ pub fn replaceEntry(
197197 const entry = try arena .create (NavigationHistoryEntry );
198198 entry .* = NavigationHistoryEntry {
199199 .id = id_str ,
200- .key = id_str ,
200+ .key = previous . key ,
201201 .url = url ,
202202 .state = state ,
203203 };
@@ -260,6 +260,19 @@ pub fn navigate(
260260 try page .navigateFromWebAPI (url , .{ .reason = .navigation }, kind );
261261 }
262262 },
263+ .replace = > | state | {
264+ if (is_same_document ) {
265+ page .url = new_url ;
266+
267+ try committed .resolve ({});
268+ // todo: Fire navigate event
269+ try finished .resolve ({});
270+
271+ _ = try self .replaceEntry (url , .{ .source = .navigation , .value = state }, page , true );
272+ } else {
273+ try page .navigateFromWebAPI (url , .{ .reason = .navigation }, kind );
274+ }
275+ },
263276 .traverse = > | index | {
264277 self .index = index ;
265278
@@ -276,7 +289,6 @@ pub fn navigate(
276289 .reload = > {
277290 try page .navigateFromWebAPI (url , .{ .reason = .navigation }, kind );
278291 },
279- else = > unreachable ,
280292 }
281293
282294 return .{
@@ -288,7 +300,13 @@ pub fn navigate(
288300pub fn _navigate (self : * Navigation , _url : []const u8 , _opts : ? NavigateOptions , page : * Page ) ! NavigationReturn {
289301 const opts = _opts orelse NavigateOptions {};
290302 const json = if (opts .state ) | state | state .toJson (page .session .arena ) catch return error .DataClone else null ;
291- return try self .navigate (_url , .{ .push = json }, page );
303+
304+ const kind : NavigationKind = switch (opts .history ) {
305+ .replace = > .{ .replace = json },
306+ .push , .auto = > .{ .push = json },
307+ };
308+
309+ return try self .navigate (_url , kind , page );
292310}
293311
294312pub const ReloadOptions = struct {
0 commit comments