From 5b1bb1bc786f62ef2f444c81640a934e42f8bef0 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 26 Sep 2026 23:55:06 -0400 Subject: [PATCH] Respect important declarations in tracked CSS cascade --- src/browser/StyleManager.zig | 106 +++++++++++++------ src/browser/tests/css/important_cascade.html | 33 ++++++ src/testing.zig | 8 ++ 3 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 src/browser/tests/css/important_cascade.html diff --git a/src/browser/StyleManager.zig b/src/browser/StyleManager.zig index 0f8f8af9f..991863359 100644 --- a/src/browser/StyleManager.zig +++ b/src/browser/StyleManager.zig @@ -41,7 +41,7 @@ const String = lp.String; const Allocator = std.mem.Allocator; // Tracks the CSS properties the renderless layout acts on (display, visibility, -// opacity, pointer-events, overflow, width, height) from + + + +
hidden despite normal inline style
+
visible with important inline style
+
hidden by the earlier important layer
+ + diff --git a/src/testing.zig b/src/testing.zig index f2c578c9d..72619afd3 100644 --- a/src/testing.zig +++ b/src/testing.zig @@ -1014,6 +1014,14 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void { }); } + if (std.mem.eql(u8, path, "/styles/important-cascade.css")) { + return req.respond(".no-js-flex { display: none !important; }", .{ + .extra_headers = &.{ + .{ .name = "Content-Type", .value = "text/css" }, + }, + }); + } + if (std.mem.eql(u8, path, "/styles/visibility.css")) { // Used by css/external_stylesheet.html — drives the visibility // cascade through StyleManager via Frame.loadExternalStylesheet