mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
dom: declare document prepend/append/replaceChildren
This commit is contained in:
@@ -5,6 +5,7 @@ const parser = @import("../netsurf.zig");
|
||||
const jsruntime = @import("jsruntime");
|
||||
const Case = jsruntime.test_utils.Case;
|
||||
const checkCases = jsruntime.test_utils.checkCases;
|
||||
const Variadic = jsruntime.Variadic;
|
||||
|
||||
const Node = @import("node.zig").Node;
|
||||
const NodeList = @import("nodelist.zig").NodeList;
|
||||
@@ -228,6 +229,28 @@ pub const Document = struct {
|
||||
return list;
|
||||
}
|
||||
|
||||
// TODO according with https://dom.spec.whatwg.org/#parentnode, the
|
||||
// function must accept either node or string.
|
||||
// blocked by https://github.com/lightpanda-io/jsruntime-lib/issues/114
|
||||
pub fn _prepend(_: *parser.Document, _: ?Variadic(*parser.Node)) !void {
|
||||
return parser.DOMError.HierarchyRequest;
|
||||
}
|
||||
|
||||
// TODO according with https://dom.spec.whatwg.org/#parentnode, the
|
||||
// function must accept either node or string.
|
||||
// blocked by https://github.com/lightpanda-io/jsruntime-lib/issues/114
|
||||
pub fn _append(_: *parser.Document, _: ?Variadic(*parser.Node)) !void {
|
||||
return parser.DOMError.HierarchyRequest;
|
||||
}
|
||||
|
||||
// TODO according with https://dom.spec.whatwg.org/#parentnode, the
|
||||
// function must accept either node or string.
|
||||
// blocked by https://github.com/lightpanda-io/jsruntime-lib/issues/114
|
||||
pub fn _replaceChildren(_: *parser.Document, _: ?Variadic(*parser.Node)) !void {
|
||||
// TODO implement function correctly
|
||||
return parser.DOMError.HierarchyRequest;
|
||||
}
|
||||
|
||||
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||
};
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ pub const Element = struct {
|
||||
}
|
||||
|
||||
for (nodes.?.slice) |node| {
|
||||
_ = try parser.nodeInsertBefore(nself, first.?, node);
|
||||
_ = try parser.nodeInsertBefore(nself, node, first.?);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@ pub const Element = struct {
|
||||
// function must accept either node or string.
|
||||
// blocked by https://github.com/lightpanda-io/jsruntime-lib/issues/114
|
||||
pub fn _replaceChildren(self: *parser.Element, nodes: ?Variadic(*parser.Node)) !void {
|
||||
// if (nodes == null) return;
|
||||
// if (nodes.?.slice.len == 0) return;
|
||||
if (nodes == null) return;
|
||||
if (nodes.?.slice.len == 0) return;
|
||||
|
||||
const nself = parser.elementToNode(self);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user