mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +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 jsruntime = @import("jsruntime");
|
||||||
const Case = jsruntime.test_utils.Case;
|
const Case = jsruntime.test_utils.Case;
|
||||||
const checkCases = jsruntime.test_utils.checkCases;
|
const checkCases = jsruntime.test_utils.checkCases;
|
||||||
|
const Variadic = jsruntime.Variadic;
|
||||||
|
|
||||||
const Node = @import("node.zig").Node;
|
const Node = @import("node.zig").Node;
|
||||||
const NodeList = @import("nodelist.zig").NodeList;
|
const NodeList = @import("nodelist.zig").NodeList;
|
||||||
@@ -228,6 +229,28 @@ pub const Document = struct {
|
|||||||
return list;
|
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 {}
|
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ pub const Element = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (nodes.?.slice) |node| {
|
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.
|
// function must accept either node or string.
|
||||||
// blocked by https://github.com/lightpanda-io/jsruntime-lib/issues/114
|
// blocked by https://github.com/lightpanda-io/jsruntime-lib/issues/114
|
||||||
pub fn _replaceChildren(self: *parser.Element, nodes: ?Variadic(*parser.Node)) !void {
|
pub fn _replaceChildren(self: *parser.Element, nodes: ?Variadic(*parser.Node)) !void {
|
||||||
// if (nodes == null) return;
|
if (nodes == null) return;
|
||||||
// if (nodes.?.slice.len == 0) return;
|
if (nodes.?.slice.len == 0) return;
|
||||||
|
|
||||||
const nself = parser.elementToNode(self);
|
const nself = parser.elementToNode(self);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user