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
25 changes: 25 additions & 0 deletions src/ExCSS.Tests/SelectorsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,31 @@ public void NthChildRejectsMalformedSpacedOffset(string selector)
Assert.Equal(0, sheet.Rules.Length);
}

[Theory]
// ::marker is a standard pseudo-element (CSS Lists 3 6.1). It was unregistered, so a rule using it
// was rejected wholesale rather than parsed. Only the two-colon form exists - unlike ::before/::after,
// ::marker has no one-colon legacy spelling.
[InlineData("li::marker", "li::marker")]
[InlineData("::marker", "::marker")]
public void MarkerPseudoElementIsParsed(string selector, string expectedText)
{
var sheet = new StylesheetParser().Parse(selector + " { color: red }");

Assert.Equal(1, sheet.Rules.Length);
Assert.Equal(expectedText, ((StyleRule)sheet.Rules[0]).SelectorText);
}

[Fact]
public void MarkerPseudoElementProducesPseudoElementSelector()
{
var sheet = new StylesheetParser().Parse("li::marker { color: red }");
var selector = ((StyleRule)sheet.Rules[0]).Selector;
var subject = selector is CompoundSelector compound ? compound.Last() : selector;

var pseudo = Assert.IsType<PseudoElementSelector>(subject);
Assert.Equal("marker", pseudo.Name);
}

private static bool HasStandardPseudoElementSelector(ISelector selector, bool negate = false)
{
if (selector is PseudoElementSelector pes)
Expand Down
1 change: 1 addition & 0 deletions src/ExCSS/Enumerations/PseudoElementNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public static class PseudoElementNames
{
public static readonly string Before = "before";
public static readonly string After = "after";
public static readonly string Marker = "marker";
public static readonly string Selection = "selection";
public static readonly string FirstLine = "first-line";
public static readonly string FirstLetter = "first-letter";
Expand Down
1 change: 1 addition & 0 deletions src/ExCSS/Factories/PseudoElementSelectorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed class PseudoElementSelectorFactory
// some implementations are dubious (first-line, first-letter, ...)
PseudoElementNames.Before,
PseudoElementNames.After,
PseudoElementNames.Marker,
PseudoElementNames.Selection,
PseudoElementNames.FirstLine,
PseudoElementNames.FirstLetter,
Expand Down