mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-30 17:25:58 -04:00
webapi: Attr.ownerDocument follows the owning element
Fixes the failing subtest of WPT /dom/nodes/Node-mutation-adoptNode.html
("Adopting an element ... owner docs of it's attributes"): after
adopting an element into another document, its attribute nodes'
ownerDocument must report the new document.
Attribute nodes are parent-less, so ownerDocument fell through to the
detached-node fallback (the per-frame owner map / main document), which
never changes on adoption. An attribute node with an owning element now
delegates to that element's ownerDocument; detached Attr nodes keep the
old resolution.
Coverage:
- /dom/nodes/Node-mutation-adoptNode.html 1/2 -> 2/2 (fully green)
- /dom/nodes/attributes-namednodemap-cross-document.window.html 0/2 -> 1/2
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
committed by
Karl Seguin
parent
bf3c858b35
commit
91a2bbcfe3
@@ -650,6 +650,14 @@ pub fn ownerDocument(self: *const Node, frame: *const Frame) ?*Document {
|
||||
return null;
|
||||
}
|
||||
|
||||
// An attribute node has no parent; its owner follows its element's
|
||||
// (including across adoption into another document).
|
||||
if (self._type == .attribute) {
|
||||
if (self._type.attribute._element) |element| {
|
||||
return element.asNode().ownerDocument(frame);
|
||||
}
|
||||
}
|
||||
|
||||
// The root of the tree that a node belongs to is its owner.
|
||||
var current = self;
|
||||
while (current._parent) |parent| {
|
||||
|
||||
Reference in New Issue
Block a user