diff --git a/src/browser/css/css.zig b/src/browser/css/css.zig index e9d67735..72ceb8e9 100644 --- a/src/browser/css/css.zig +++ b/src/browser/css/css.zig @@ -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; @@ -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; diff --git a/src/browser/css/selector.zig b/src/browser/css/selector.zig index 60441ccc..e36717f0 100644 --- a/src/browser/css/selector.zig +++ b/src/browser/css/selector.zig @@ -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), @@ -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); diff --git a/src/browser/dom/css.zig b/src/browser/dom/css.zig index c9f3d647..26e69167 100644 --- a/src/browser/dom/css.zig +++ b/src/browser/dom/css.zig @@ -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; } @@ -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(); }