mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 07:31:47 +00:00
dom: implement document.importNode
This commit is contained in:
@@ -145,6 +145,10 @@ pub const Document = struct {
|
|||||||
return try parser.documentCreateProcessingInstruction(self, target, data);
|
return try parser.documentCreateProcessingInstruction(self, target, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _importNode(self: *parser.Document, node: *parser.Node, deep: ?bool) !*parser.Node {
|
||||||
|
return try parser.documentImportNode(self, node, deep orelse false);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -263,6 +267,12 @@ pub fn testExecFn(
|
|||||||
};
|
};
|
||||||
try checkCases(js_env, &createProcessingInstruction);
|
try checkCases(js_env, &createProcessingInstruction);
|
||||||
|
|
||||||
|
var importNode = [_]Case{
|
||||||
|
.{ .src = "let nimp = document.getElementById('content')", .ex = "undefined" },
|
||||||
|
.{ .src = "document.importNode(nimp)", .ex = "[object Node]" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &importNode);
|
||||||
|
|
||||||
const tags = comptime parser.Tag.all();
|
const tags = comptime parser.Tag.all();
|
||||||
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
||||||
inline for (tags, 0..) |tag, i| {
|
inline for (tags, 0..) |tag, i| {
|
||||||
|
|||||||
@@ -1176,6 +1176,14 @@ pub inline fn documentCreateProcessingInstruction(doc: *Document, target: []cons
|
|||||||
return pi.?;
|
return pi.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn documentImportNode(doc: *Document, node: *Node, deep: bool) !*Node {
|
||||||
|
var res: NodeExternal = undefined;
|
||||||
|
const nodeext = toNodeExternal(Node, node);
|
||||||
|
const err = documentVtable(doc).dom_document_import_node.?(doc, nodeext, deep, &res);
|
||||||
|
try DOMErr(err);
|
||||||
|
return @as(*Node, @ptrCast(res));
|
||||||
|
}
|
||||||
|
|
||||||
// DocumentHTML
|
// DocumentHTML
|
||||||
pub const DocumentHTML = c.dom_html_document;
|
pub const DocumentHTML = c.dom_html_document;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user