mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
make sure parent is not Document in beforebegin and afterend
This commit is contained in:
@@ -273,12 +273,22 @@ pub const Element = struct {
|
|||||||
if (std.mem.eql(u8, position, "beforebegin")) {
|
if (std.mem.eql(u8, position, "beforebegin")) {
|
||||||
// The node must have a parent node in order to use this variant.
|
// The node must have a parent node in order to use this variant.
|
||||||
const parent = parser.nodeParentNode(self_node) orelse return error.NoModificationAllowed;
|
const parent = parser.nodeParentNode(self_node) orelse return error.NoModificationAllowed;
|
||||||
|
// Parent cannot be Document.
|
||||||
|
// Should have checks for document_fragment and document_type?
|
||||||
|
if (parser.nodeType(parent) == .document) {
|
||||||
|
return error.NoModificationAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
break :blk .{ parent, self_node };
|
break :blk .{ parent, self_node };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std.mem.eql(u8, position, "afterend")) {
|
if (std.mem.eql(u8, position, "afterend")) {
|
||||||
// The node must have a parent node in order to use this variant.
|
// The node must have a parent node in order to use this variant.
|
||||||
const parent = parser.nodeParentNode(self_node) orelse return error.NoModificationAllowed;
|
const parent = parser.nodeParentNode(self_node) orelse return error.NoModificationAllowed;
|
||||||
|
// Parent cannot be Document.
|
||||||
|
if (parser.nodeType(parent) == .document) {
|
||||||
|
return error.NoModificationAllowed;
|
||||||
|
}
|
||||||
// Get the next sibling or null; null indicates our node is the only one.
|
// Get the next sibling or null; null indicates our node is the only one.
|
||||||
const sibling = parser.nodeNextSibling(self_node);
|
const sibling = parser.nodeNextSibling(self_node);
|
||||||
break :blk .{ parent, sibling };
|
break :blk .{ parent, sibling };
|
||||||
|
|||||||
Reference in New Issue
Block a user