mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
dom: implement document.adoptNode
This commit is contained in:
@@ -149,6 +149,10 @@ pub const Document = struct {
|
||||
return try parser.documentImportNode(self, node, deep orelse false);
|
||||
}
|
||||
|
||||
pub fn _adoptNode(self: *parser.Document, node: *parser.Node) !*parser.Node {
|
||||
return try parser.documentAdoptNode(self, node);
|
||||
}
|
||||
|
||||
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||
};
|
||||
|
||||
@@ -273,6 +277,12 @@ pub fn testExecFn(
|
||||
};
|
||||
try checkCases(js_env, &importNode);
|
||||
|
||||
var adoptNode = [_]Case{
|
||||
.{ .src = "let nadop = document.getElementById('content')", .ex = "undefined" },
|
||||
.{ .src = "document.adoptNode(nadop)", .ex = "[object Node]" },
|
||||
};
|
||||
try checkCases(js_env, &adoptNode);
|
||||
|
||||
const tags = comptime parser.Tag.all();
|
||||
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
||||
inline for (tags, 0..) |tag, i| {
|
||||
|
||||
@@ -1184,6 +1184,14 @@ pub inline fn documentImportNode(doc: *Document, node: *Node, deep: bool) !*Node
|
||||
return @as(*Node, @ptrCast(res));
|
||||
}
|
||||
|
||||
pub inline fn documentAdoptNode(doc: *Document, node: *Node) !*Node {
|
||||
var res: NodeExternal = undefined;
|
||||
const nodeext = toNodeExternal(Node, node);
|
||||
const err = documentVtable(doc).dom_document_adopt_node.?(doc, nodeext, &res);
|
||||
try DOMErr(err);
|
||||
return @as(*Node, @ptrCast(res));
|
||||
}
|
||||
|
||||
// DocumentHTML
|
||||
pub const DocumentHTML = c.dom_html_document;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user