Skip to content

Commit 2ccbadd

Browse files
authored
chore(KNO-12220): update css-inline to version that fixes important inlinging (#14)
1 parent 060a62f commit 2ccbadd

3 files changed

Lines changed: 11 additions & 46 deletions

File tree

native/css_inline_nif/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

native/css_inline_nif/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ nif_version_2_17 = ["rustler/nif_version_2_17"]
1717

1818
[dependencies]
1919
rustler = "0.37"
20-
css-inline = "0.20.0"
20+
css-inline = "0.20.1"

test/css_inline_test.exs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -273,44 +273,9 @@ defmodule CSSInlineTest do
273273

274274
test "preserves !important when inlining styles" do
275275
assert {:ok, result} = CSSInline.inline(@email_html)
276-
assert result =~ ~r/style="[^"]*!important/
277-
end
278-
279-
@production_opts [
280-
load_remote_stylesheets: false,
281-
keep_link_tags: true,
282-
keep_style_tags: true
283-
]
284-
285-
test "production settings: inlined selectors remain in <style> without remove_inlined_selectors" do
286-
assert {:ok, result} = CSSInline.inline(@email_html, @production_opts)
287-
288-
assert result =~ ~r/style="[^"]*!important/,
289-
"Inlined styles should preserve !important"
290-
291-
[_, style_content] = Regex.run(~r/<style[^>]*>(.*?)<\/style>/s, result)
292-
293-
assert style_content =~ "u + #body a",
294-
"Non-inlinable selectors should remain in <style> tag"
295-
296-
assert style_content =~ ".button a",
297-
"Without remove_inlined_selectors, inlined selectors remain in <style>"
298-
end
299-
300-
test "production settings + remove_inlined_selectors strips inlined rules from <style>" do
301-
{:ok, result} =
302-
CSSInline.inline(@email_html, [remove_inlined_selectors: true] ++ @production_opts)
303-
304-
assert result =~ ~r/style="[^"]*color:[^"]*!important/,
305-
"Inlined styles should preserve !important"
306-
307-
[_, style_content] = Regex.run(~r/<style[^>]*>(.*?)<\/style>/s, result)
308-
309-
assert style_content =~ "u + #body a",
310-
"Non-inlinable selectors (complex email client overrides) must remain"
311276

312-
refute style_content =~ ".button a",
313-
"Inlined selectors should be removed from <style> to prevent conflicts"
277+
assert result =~
278+
"<a href=\"https://example.com\" style=\"color:#ffffff !important;font-size:16px !important;font-weight:bold !important\">"
314279
end
315280
end
316281

0 commit comments

Comments
 (0)