mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #729 from lightpanda-io/fix_node_insert_before_null_reference
support null referene node to Node.insertBefore
This commit is contained in:
@@ -289,8 +289,11 @@ pub const Node = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _insertBefore(self: *parser.Node, new_node: *parser.Node, ref_node: *parser.Node) !*parser.Node {
|
pub fn _insertBefore(self: *parser.Node, new_node: *parser.Node, ref_node_: ?*parser.Node) !Union {
|
||||||
return try parser.nodeInsertBefore(self, new_node, ref_node);
|
if (ref_node_) |ref_node| {
|
||||||
|
return Node.toInterface(try parser.nodeInsertBefore(self, new_node, ref_node));
|
||||||
|
}
|
||||||
|
return _appendChild(self, new_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _isDefaultNamespace(self: *parser.Node, namespace: ?[]const u8) !bool {
|
pub fn _isDefaultNamespace(self: *parser.Node, namespace: ?[]const u8) !bool {
|
||||||
@@ -662,6 +665,10 @@ test "Browser.DOM.node" {
|
|||||||
.{ "let insertBefore = document.createElement('a')", "undefined" },
|
.{ "let insertBefore = document.createElement('a')", "undefined" },
|
||||||
.{ "link.insertBefore(insertBefore, text) !== undefined", "true" },
|
.{ "link.insertBefore(insertBefore, text) !== undefined", "true" },
|
||||||
.{ "link.firstChild.localName === 'a'", "true" },
|
.{ "link.firstChild.localName === 'a'", "true" },
|
||||||
|
|
||||||
|
.{ "let insertBefore2 = document.createElement('b')", null },
|
||||||
|
.{ "link.insertBefore(insertBefore2, null).localName", "b" },
|
||||||
|
.{ "link.childNodes[link.childNodes.length - 1].localName", "b" },
|
||||||
}, .{});
|
}, .{});
|
||||||
|
|
||||||
try runner.testCases(&.{
|
try runner.testCases(&.{
|
||||||
|
|||||||
Reference in New Issue
Block a user