css: implement legend siblings check for :disabled

This commit is contained in:
Pierre Tachoire
2024-03-25 17:55:30 +01:00
parent 4e61a50946
commit 4c50b2af1a

View File

@@ -508,14 +508,26 @@ pub const Selector = union(enum) {
}; };
} }
fn hasLegendInPreviousSiblings(n: anytype) anyerror!bool {
var c = try n.prevSibling();
while (c != null) {
const ctag = try c.?.tag();
if (std.ascii.eqlIgnoreCase("legend", ctag)) return true;
c = try c.?.prevSibling();
}
return false;
}
fn inDisabledFieldset(n: anytype) anyerror!bool { fn inDisabledFieldset(n: anytype) anyerror!bool {
const p = try n.parent(); const p = try n.parent();
if (p == null) return false; if (p == null) return false;
const ntag = try n.tag();
const ptag = try p.?.tag(); const ptag = try p.?.tag();
if (std.ascii.eqlIgnoreCase("fieldset", ptag) and if (std.ascii.eqlIgnoreCase("fieldset", ptag) and
try p.?.attr("disabled") != null) try p.?.attr("disabled") != null and
(!std.ascii.eqlIgnoreCase("legend", ntag) or try hasLegendInPreviousSiblings(n)))
{ {
return true; return true;
} }