Skip to content

Commit e5ec0fa

Browse files
committed
Fix a stale Ignore and its own test bug on an already-working ::after test
CssContentWithCssEscapeInString_RendersLiterally was Ignore'd, citing "this fork has no pseudo-element support at all" - false: ::before already works (the CSS-escape test right above it in this same file passes), and CssContentEngine/CssData's pseudo-element creation predates this port entirely. Un-ignoring it surfaced a real bug in the TEST itself, not the engine: its box-finding predicate (HtmlTag == null && Text != null) matches the real text node "text" (which also has no HtmlTag) before it reaches the ::after box, since ::after is appended at the end of p.Boxes while ::before is inserted at index 0 - the sibling test just above happens to pass because ::before's insert-at-0 placement wins the FirstOrDefault race by coincidence. Fixed to key off IsAfterPseudoElement directly, and it passes.
1 parent 0f793a5 commit e5ec0fa

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Source/Test/HtmlRenderer.IntegrationTest/Text/HtmlEntityDecodingIntegrationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ public void CssContentWithCssEscape_RendersLiterally()
189189
Assert.AreEqual("&", beforeBox!.Text);
190190
}
191191

192-
[Ignore("Requires ::before/::after pseudo-elements with a CSS content: property - this fork has no " +
193-
"pseudo-element support at all (confirmed: no \"::before\"/\"::after\"/pseudo-element handling " +
194-
"anywhere in Core, only :link/:hover pseudo-CLASSES are recognized).")]
195192
[TestMethod]
196193
public void CssContentWithCssEscapeInString_RendersLiterally()
197194
{
@@ -200,7 +197,10 @@ public void CssContentWithCssEscapeInString_RendersLiterally()
200197
var (root, _) = LayoutHarness.Layout(html);
201198
var p = LayoutHarness.FindById(root, "p")!;
202199

203-
var afterBox = p.Boxes.FirstOrDefault(b => b.HtmlTag == null && b.Text != null);
200+
// Unlike ::before (inserted at index 0), ::after is appended at the end of p.Boxes - so
201+
// FirstOrDefault(HtmlTag == null) would instead match the real text node "text" (which also has
202+
// no HtmlTag), not the pseudo box. IsAfterPseudoElement identifies it unambiguously.
203+
var afterBox = p.Boxes.FirstOrDefault(b => b.IsAfterPseudoElement);
204204
Assert.IsNotNull(afterBox);
205205
Assert.IsTrue(afterBox!.Text!.Contains('<'));
206206
Assert.IsTrue(afterBox.Text!.Contains('>'));

0 commit comments

Comments
 (0)