mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
dom: implement getElementsByClassName
This commit is contained in:
@@ -522,6 +522,11 @@ pub fn nodeReplaceChild(node: *Node, new_child: *Node, old_child: *Node) *Node {
|
||||
return res.?;
|
||||
}
|
||||
|
||||
// nodeToElement is an helper to convert a node to an element.
|
||||
pub inline fn nodeToElement(node: *Node) *Element {
|
||||
return @as(*Element, @ptrCast(node));
|
||||
}
|
||||
|
||||
// CharacterData
|
||||
pub const CharacterData = c.dom_characterdata;
|
||||
|
||||
@@ -621,6 +626,12 @@ pub fn elementGetAttribute(elem: *Element, name: []const u8) ?[]const u8 {
|
||||
return stringToData(s.?);
|
||||
}
|
||||
|
||||
pub fn elementHasClass(elem: *Element, class: []const u8) bool {
|
||||
var res: bool = undefined;
|
||||
_ = elementVtable(elem).dom_element_has_class.?(elem, stringFromData(class), &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// elementToNode is an helper to convert an element to a node.
|
||||
pub inline fn elementToNode(e: *Element) *Node {
|
||||
return @as(*Node, @ptrCast(e));
|
||||
|
||||
Reference in New Issue
Block a user