-
Notifications
You must be signed in to change notification settings - Fork 298
Support isEqualNode
#1246
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
base: zigdom
Are you sure you want to change the base?
Support isEqualNode
#1246
Conversation
| } | ||
|
|
||
| // TODO: Compare `localName` and prefix. | ||
| switch (self._type) { |
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.
Could push this logic into each type, e.g.
if (self.as(Element).isEqualNode(other.as(Element)) == false) {
return false;
}| const e1 = self.as(Element); | ||
| const e2 = other.as(Element); | ||
|
|
||
| const e1_tag = e1.getTagNameSpec(&page.buf); |
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 think you can use getTagNameDump() instead, which doesn't require a buffer
| return false; | ||
| } | ||
|
|
||
| if (e1._namespace != e2._namespace or !std.mem.eql(u8, e1_tag, e2_tag) or iter1_count != iter2_count) { |
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.
Both more efficient and easier to read if you group these a little better. Check the tags names and namespaces where you get them, before iterating through all the attributes and comparing htem.
|
|
||
| return std.mem.eql(u8, c1.getData(), c2.getData()); | ||
| }, | ||
| else => @panic("NIY"), |
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.
log.warn(.browser, "not implemented", .{
.type = self._type,
.feature = "Node.isEqualNode",
});
return false;
| else => @panic("NIY"), | ||
| } | ||
|
|
||
| // `Node.childNodes` allocate memory, this seems like a better option. |
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.
| // `Node.childNodes` allocate memory, this seems like a better option. |
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.
Yes, childrenIterator is meant for internal iteration within the Zig code, specifically to avoid the overhead of childNodes necessary to fulfill the webapi of that type.
This is the bare minimum required for a specific website, I'll add support for other variants once needed.