@@ -36,6 +36,8 @@ const Screen = @import("screen.zig").Screen;
3636const  domcss  =  @import ("../dom/css.zig" );
3737const  Css  =  @import ("../css/css.zig" ).Css ;
3838const  EventHandler  =  @import ("../events/event.zig" ).EventHandler ;
39+ const  URL  =  @import ("../../url.zig" ).URL ;
40+ const  WebApiURL  =  @import ("../url/url.zig" ).URL ;
3941
4042const  Request  =  @import ("../fetch/Request.zig" );
4143const  fetchFn  =  @import ("../fetch/fetch.zig" ).fetch ;
@@ -52,7 +54,7 @@ pub const Window = struct {
5254
5355 document : * parser.DocumentHTML ,
5456 target : []const  u8  =  "" ,
55-  location : Location = .default ,
57+  location : Location ,
5658 storage_shelf : ? * storage.Shelf  =  null ,
5759
5860 // counter for having unique timer ids 
@@ -75,17 +77,30 @@ pub const Window = struct {
7577 const  doc  =  parser .documentHTMLToDocument (html_doc );
7678 try  parser .documentSetDocumentURI (doc , "about:blank" );
7779
80+  const  native_url  =  URL .parse ("about:blank" , null ) catch  unreachable ;
81+ 82+  // Here we manually initialize; this is a special case and 
83+  // one should prefer constructor functions instead. 
84+  const  url  =  WebApiURL {
85+  .internal  =  native_url .internal ,
86+  .search_params  =  .{},
87+  };
88+ 7889 return  .{
7990 .document  =  html_doc ,
91+  .location  =  .{ .url  =  url  },
8092 .target  =  target  orelse  "" ,
8193 .navigator  =  navigator  orelse  .{},
8294 .performance  =  Performance .init (),
8395 };
8496 }
8597
86-  pub  fn  replaceLocation (self : * Window , loc : Location ) ! void  {
87-  self .location  =  loc ;
88-  try  parser .documentHTMLSetLocation (Location , self .document , & self .location );
98+  pub  fn  replaceLocation (self : * Window , location : Location ) ! void  {
99+  // Remove current. 
100+  self .location .url .destructor ();
101+  // Put the new one. 
102+  self .location  =  location ;
103+  return  parser .documentHTMLSetLocation (Location , self .document , & self .location );
89104 }
90105
91106 pub  fn  replaceDocument (self : * Window , doc : * parser.DocumentHTML ) ! void  {
0 commit comments