From 23f5b8414e32ccae07a788a658a11f7dab35d5f5 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Mon, 22 Jun 2026 18:57:44 +0800 Subject: [PATCH 1/3] cli: add strip-mode invisible Adds a new strip-mode "invisible" which consults the StyleManager to remove hidden elements. However, unlike the general isHidden check in StyleManager which is spec-compliant and will automatically hide a number of tags, e.g. "meta", this check is explicitly against explicit styles. This seems more practical to me, while it might be useful to remove some tags by default, e.g. template, some tags like head, title and meta are too important to strip out. --- src/browser/StyleManager.zig | 16 ++++++++++++++-- src/browser/dump.zig | 16 +++++++++++++--- src/help.zon | 9 +++++---- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/browser/StyleManager.zig b/src/browser/StyleManager.zig index 93a9a5f25..79936e1d3 100644 --- a/src/browser/StyleManager.zig +++ b/src/browser/StyleManager.zig @@ -326,6 +326,15 @@ pub fn hasDisplayNone(self: *StyleManager, el: *Element) bool { return self.isElementHidden(el, .{}); } +/// Computed display:none coming only from inline style or an author stylesheet +/// rule — the UA stylesheet's hidden elements (,

Title

visible & well

+ ); +} + +test "dump: with_base injects a element" { + try expectDump(.{ .with_base = true }, + \\ + \\

Title

visible & well

+ ); +} + +test "dump: strip.js removes script and noscript" { + try expectDump(.{ .strip = .{ .js = true } }, + \\ + \\

Title

visible & well

+ ); +} + +test "dump: strip.css removes style and stylesheet links" { + try expectDump(.{ .strip = .{ .css = true } }, + \\ + \\

Title

visible & well

+ ); +} + +test "dump: strip.ui removes css plus visual elements" { + try expectDump(.{ .strip = .{ .ui = true } }, + \\ + \\

Title

visible & well

+ ); +} + +test "dump: strip.invisible removes author display:none elements" { + try expectDump(.{ .strip = .{ .invisible = true } }, + \\ + \\

Title

visible & well

+ ); +} diff --git a/src/browser/tests/dump.html b/src/browser/tests/dump.html new file mode 100644 index 000000000..462a2e1f1 --- /dev/null +++ b/src/browser/tests/dump.html @@ -0,0 +1 @@ +

Title

visible & well

\ No newline at end of file