-
Notifications
You must be signed in to change notification settings - Fork 219
elementFromPoint + elementsFromPoint #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9fd889b
acf0e20
71c7ede
3064b2f
14fbc16
f359c33
b834fab
44210ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ const Walker = @import("walker.zig").WalkerDepthFirst; | |
const HTML = @import("../html/html.zig"); | ||
const HTMLElem = @import("../html/elements.zig"); | ||
|
||
const log = std.log.scoped(.node); | ||
|
||
// Node interfaces | ||
pub const Interfaces = .{ | ||
Attr, | ||
|
@@ -262,13 +264,15 @@ pub const Node = struct { | |
return try parser.nodeContains(self, other); | ||
} | ||
|
||
pub fn _getRootNode(self: *parser.Node) !?HTMLElem.Union { | ||
// TODO return this’s shadow-including root if options["composed"] is true | ||
const res = try parser.nodeOwnerDocument(self); | ||
if (res == null) { | ||
return null; | ||
} | ||
return try HTMLElem.toInterface(HTMLElem.Union, @as(*parser.Element, @ptrCast(res.?))); | ||
// Returns itself or ancestor object inheriting from Node. | ||
// - An Element inside a standard web page will return an HTMLDocument object representing the entire page (or <iframe>). | ||
// - An Element inside a shadow DOM will return the associated ShadowRoot. | ||
// - An Element that is not attached to a document or a shadow tree will return the root of the DOM tree it belongs to | ||
pub fn _getRootNode(self: *parser.Node, options: ?struct { composed: bool = false }) !Union { | ||
if (options) |options_| if (options_.composed) { | ||
log.warn("getRootNode composed is not implemented yet", .{}); | ||
}; | ||
return try Node.toInterface(try parser.nodeGetRootNode(self)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just trying to understand. If But for cases where the document isn't attached, and possibly also the shadow dom, you use the new Is that right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Note that I actually now use the difference between getRootNode and nodeOwnerDocument to determine whether an element is or is not detached. |
||
} | ||
|
||
pub fn _hasChildNodes(self: *parser.Node) !bool { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that we should not be throwing these errors in this use case, so a pre-exiting bug that is not fixed in the PR