node: check owner null before using it

This commit is contained in:
Pierre Tachoire
2025-08-05 18:23:41 +02:00
parent c453dd2b3c
commit 090c0f8857

View File

@@ -206,7 +206,7 @@ pub const Node = struct {
// the parent's ownerDocument. // the parent's ownerDocument.
// This process is known as adoption. // This process is known as adoption.
// (7.1) https://dom.spec.whatwg.org/#concept-node-insert // (7.1) https://dom.spec.whatwg.org/#concept-node-insert
if (child_owner == null or (child_owner.? != self_owner.?)) { if (child_owner == null or (self_owner != null and child_owner.? != self_owner.?)) {
const w = Walker{}; const w = Walker{};
var current = child; var current = child;
while (true) { while (true) {
@@ -319,7 +319,7 @@ pub const Node = struct {
// the parent's ownerDocument. // the parent's ownerDocument.
// This process is known as adoption. // This process is known as adoption.
// (7.1) https://dom.spec.whatwg.org/#concept-node-insert // (7.1) https://dom.spec.whatwg.org/#concept-node-insert
if (new_node_owner == null or (new_node_owner.? != self_owner.?)) { if (new_node_owner == null or (self_owner != null and new_node_owner.? != self_owner.?)) {
const w = Walker{}; const w = Walker{};
var current = new_node; var current = new_node;
while (true) { while (true) {