Skip to content

Register the ::marker pseudo-element#202

Open
jhaygood86 wants to merge 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/marker-pseudo-element
Open

Register the ::marker pseudo-element#202
jhaygood86 wants to merge 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/marker-pseudo-element

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Problem

li::marker { color: red } fails to parse — sheet.Rules.Length is 0, the whole rule is dropped.

::marker is a standard pseudo-element (CSS Lists 3 §6.1), but it is missing from the registered set in PseudoElementSelectorFactory:

new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
    PseudoElementNames.Before,
    PseudoElementNames.After,
    // PseudoElementNames.Marker  <-- absent
    PseudoElementNames.Selection,
    PseudoElementNames.FirstLine,
    PseudoElementNames.FirstLetter,
    PseudoElementNames.Content,
}

So Create("marker") returns null (unless AllowInvalidSelectors is set), and the selector — and its rule — is discarded.

Fix

Add PseudoElementNames.Marker = "marker" and register it in the factory, exactly like the other pseudo-elements. It now parses to a PseudoElementSelector with Name == "marker" and round-trips as ::marker.

Only the two-colon form is registered. Unlike ::before/::after, ::marker has no one-colon legacy spelling (it postdates CSS2), so :marker stays invalid.

Scope note

This is the parse fix only. In the fork this came from, ::marker registration rode along with a larger rework that also gives :first-child/:only-child/etc. dedicated selector subtypes — but those already parse correctly here (identical text and specificity), so that part is an object-model change specific to that fork's matching engine, not a parsing or spec-conformance fix, and is left out.

Tests

3 tests in SelectorsTests.cs: li::marker and bare ::marker parse and round-trip, and the subject is a PseudoElementSelector named marker. All 3 fail on master. The full suite (1263 existing tests) stays green, and all seven target frameworks build with no new warnings.

@jhaygood86
jhaygood86 marked this pull request as ready for review July 22, 2026 22:32
::marker is a standard pseudo-element (CSS Lists 3 6.1), but it was
absent from PseudoElementSelectorFactory's registered set, so a rule
that used it - "li::marker { … }" - failed to parse and was dropped
whole rather than producing a PseudoElementSelector.

Add it to the factory (and PseudoElementNames). Only the two-colon form
is registered; unlike ::before/::after, ::marker has no one-colon legacy
spelling.
@jhaygood86
jhaygood86 force-pushed the feature/marker-pseudo-element branch from 6c3930e to f2c9670 Compare July 23, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant