Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/browser/css/css.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn parse(alloc: std.mem.Allocator, s: []const u8, opts: parser.ParseOptions)

// matchFirst call m.match with the first node that matches the selector s, from the
// descendants of n and returns true. If none matches, it returns false.
pub fn matchFirst(s: Selector, node: anytype, m: anytype) !bool {
pub fn matchFirst(s: *const Selector, node: anytype, m: anytype) !bool {
var c = try node.firstChild();
while (true) {
if (c == null) break;
Expand All @@ -63,7 +63,7 @@ pub fn matchFirst(s: Selector, node: anytype, m: anytype) !bool {

// matchAll call m.match with the all the nodes that matches the selector s, from the
// descendants of n.
pub fn matchAll(s: Selector, node: anytype, m: anytype) !void {
pub fn matchAll(s: *const Selector, node: anytype, m: anytype) !void {
var c = try node.firstChild();
while (true) {
if (c == null) break;
Expand Down
8 changes: 4 additions & 4 deletions src/browser/css/selector.zig
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ pub const Selector = union(enum) {
}

// match returns true if the node matches the selector query.
pub fn match(s: Selector, n: anytype) !bool {
return switch (s) {
pub fn match(s: *const Selector, n: anytype) !bool {
return switch (s.*) {
.tag => |v| n.isElement() and std.ascii.eqlIgnoreCase(v, try n.tag()),
.id => |v| return n.isElement() and std.mem.eql(u8, v, try n.attr("id") orelse return false),
.class => |v| return n.isElement() and word(try n.attr("class") orelse return false, v, false),
Expand Down Expand Up @@ -794,8 +794,8 @@ pub const Selector = union(enum) {
return false;
}

pub fn deinit(sel: Selector, alloc: std.mem.Allocator) void {
switch (sel) {
pub fn deinit(sel: *const Selector, alloc: std.mem.Allocator) void {
switch (sel.*) {
.group => |v| {
for (v) |vv| vv.deinit(alloc);
alloc.free(v);
Expand Down
4 changes: 2 additions & 2 deletions src/browser/dom/css.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn querySelector(alloc: std.mem.Allocator, n: *parser.Node, selector: []cons

var m = MatchFirst{};

_ = try css.matchFirst(ps, Node{ .node = n }, &m);
_ = try css.matchFirst(&ps, Node{ .node = n }, &m);
return m.n;
}

Expand Down Expand Up @@ -75,6 +75,6 @@ pub fn querySelectorAll(alloc: std.mem.Allocator, n: *parser.Node, selector: []c
var m = MatchAll.init(alloc);
defer m.deinit();

try css.matchAll(ps, Node{ .node = n }, &m);
try css.matchAll(&ps, Node{ .node = n }, &m);
return m.toOwnedList();
}