From f7487cc1b0a345f557eeb9e509f497f05f558cb2 Mon Sep 17 00:00:00 2001 From: Jared Dellitt Date: Wed, 25 Mar 2026 08:43:42 -0500 Subject: [PATCH] fix(KNO-12220): expose remove_inlined_selectors so styles that are inlined don't also exist in style tags --- lib/css_inline.ex | 11 +++++ native/css_inline_nif/src/lib.rs | 2 + test/css_inline_test.exs | 74 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/lib/css_inline.ex b/lib/css_inline.ex index 34cfdca..de73494 100644 --- a/lib/css_inline.ex +++ b/lib/css_inline.ex @@ -31,6 +31,10 @@ defmodule CSSInline do * `:load_remote_stylesheets` - Whether to load remote stylesheets referenced in `` tags. Defaults to `true`. Set to `false` to skip external stylesheets. * `:minify_css` - Whether to minify the inlined CSS. Defaults to `true`. + * `:remove_inlined_selectors` - Whether to remove selectors from ` + + + +
+ Click Me +
+
+ + + """ + + test "preserves !important when inlining styles" do + assert {:ok, result} = CSSInline.inline(@email_html) + assert result =~ ~r/style="[^"]*!important/ + end + + @production_opts [ + load_remote_stylesheets: false, + keep_link_tags: true, + keep_style_tags: true + ] + + test "production settings: inlined selectors remain in