Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/HtmlRenderer/Core/Dom/CssBoxProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,8 @@ public double GetEmHeight()
protected string NoEms(string length)
{
var len = new CssLength(length);
if (len.Unit == CssUnit.Ems)
// CssLength reads rem as em with a parse error
if (len.Unit == CssUnit.Ems && !len.HasError)
{
length = len.ConvertEmToPixels(GetEmHeight()).ToString();
}
Expand Down
11 changes: 11 additions & 0 deletions Source/Test/HtmlRenderer.Test/Css/TextPropertyTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HtmlRenderer.Test.CssEngineSupport;
using HtmlRenderer.Test.TestSupport;
using TheArtOfDev.HtmlRenderer.Core.CssEngine;

namespace HtmlRenderer.Test.Css;
Expand Down Expand Up @@ -822,4 +823,14 @@ public void OverflowWrapAlternateNameNoneIllegal()
Assert.IsInstanceOfType<OverflowWrapProperty>(property);
Assert.IsFalse(property.HasValue);
}

[TestMethod]
[DataRow("text-indent")]
[DataRow("word-spacing")]
public void RemLengthDoesNotFailTheDocument(string property)
{
var (root, _) = LayoutHarness.Layout(LayoutHarness.Wrap($"<p id=x style='{property}: 2rem'>a b</p>"));

Assert.IsNotNull(LayoutHarness.FindById(root, "x"));
}
}
Loading