diff --git a/src/dom/document.zig b/src/dom/document.zig index 9c878871..47582f6b 100644 --- a/src/dom/document.zig +++ b/src/dom/document.zig @@ -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 {} }; diff --git a/src/dom/element.zig b/src/dom/element.zig index 43000655..47d42b05 100644 --- a/src/dom/element.zig +++ b/src/dom/element.zig @@ -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);