File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -273,12 +273,22 @@ pub const Element = struct {
273273 if (std .mem .eql (u8 , position , "beforebegin" )) {
274274 // The node must have a parent node in order to use this variant.
275275 const parent = parser .nodeParentNode (self_node ) orelse return error .NoModificationAllowed ;
276+ // Parent cannot be Document.
277+ // Should have checks for document_fragment and document_type?
278+ if (parser .nodeType (parent ) == .document ) {
279+ return error .NoModificationAllowed ;
280+ }
281+
276282 break :blk .{ parent , self_node };
277283 }
278284
279285 if (std .mem .eql (u8 , position , "afterend" )) {
280286 // The node must have a parent node in order to use this variant.
281287 const parent = parser .nodeParentNode (self_node ) orelse return error .NoModificationAllowed ;
288+ // Parent cannot be Document.
289+ if (parser .nodeType (parent ) == .document ) {
290+ return error .NoModificationAllowed ;
291+ }
282292 // Get the next sibling or null; null indicates our node is the only one.
283293 const sibling = parser .nodeNextSibling (self_node );
284294 break :blk .{ parent , sibling };
You can’t perform that action at this time.
0 commit comments