mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 00:38:59 +00:00
dom: expose document.location
This commit is contained in:
@@ -28,6 +28,7 @@ const Node = @import("../dom/node.zig").Node;
|
||||
const Document = @import("../dom/document.zig").Document;
|
||||
const NodeList = @import("../dom/nodelist.zig").NodeList;
|
||||
const HTMLElem = @import("elements.zig");
|
||||
const Location = @import("location.zig").Location;
|
||||
|
||||
const collection = @import("../dom/html_collection.zig");
|
||||
const Walker = @import("../dom/walker.zig").WalkerDepthFirst;
|
||||
@@ -157,6 +158,10 @@ pub const HTMLDocument = struct {
|
||||
return try parser.documentHTMLGetCurrentScript(self);
|
||||
}
|
||||
|
||||
pub fn get_location(self: *parser.DocumentHTML) !?*Location {
|
||||
return try parser.documentHTMLGetLocation(Location, self);
|
||||
}
|
||||
|
||||
pub fn get_designMode(_: *parser.DocumentHTML) []const u8 {
|
||||
return "off";
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ pub fn testExecFn(
|
||||
) anyerror!void {
|
||||
var location = [_]Case{
|
||||
.{ .src = "location.href", .ex = "" },
|
||||
.{ .src = "document.location.href", .ex = "" },
|
||||
};
|
||||
try checkCases(js_env, &location);
|
||||
}
|
||||
|
||||
@@ -62,12 +62,17 @@ pub const Window = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn replaceLocation(self: *Window, loc: Location) void {
|
||||
pub fn replaceLocation(self: *Window, loc: Location) !void {
|
||||
self.location = loc;
|
||||
|
||||
if (self.doc != null) {
|
||||
try parser.documentHTMLSetLocation(Location, self.doc.?, &self.location);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replaceDocument(self: *Window, doc: *parser.DocumentHTML) void {
|
||||
pub fn replaceDocument(self: *Window, doc: *parser.DocumentHTML) !void {
|
||||
self.document = doc;
|
||||
try parser.documentHTMLSetLocation(Location, doc, &self.location);
|
||||
}
|
||||
|
||||
pub fn setStorageShelf(self: *Window, shelf: *storage.Shelf) void {
|
||||
|
||||
Reference in New Issue
Block a user