Add the @property at-rule#212
Merged
TylerBrinks merged 1 commit intoJul 23, 2026
Merged
Conversation
@Property (CSS Properties and Values API 1 3) registers a typed custom property with syntax, initial-value and inherits descriptors. Add PropertyRule (a DeclarationRule like FontFaceRule, with a Name captured from the prelude), IPropertyRule, RuleNames.Property, RuleType.Property, the three descriptor names, PropertyFactory.CreatePropertyDescriptor (storing each raw via UnknownProperty, since their values have no fixed grammar), and StylesheetComposer.CreateProperty with its dispatch. Includes the "--foo" lexer fix from the custom-properties change (also submitted standalone), needed here to lex the "--name" prelude; if that merges first, this rebases cleanly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature
The
@propertyat-rule (CSS Properties and Values API 1 §3) registers a typed custom property:Implementation
PropertyRule— aDeclarationRulelikeFontFaceRule, with itsNamecaptured from the prelude likeKeyframesRule, andSyntax/InitialValue/Inheritsaccessors. Exposed asIPropertyRule.RuleNames.Property,RuleType.Property, and the three descriptor property names.PropertyFactory.CreatePropertyDescriptor— the descriptors have no fixed grammar (initial-valuedepends onsyntax;syntaxis an arbitrary string), so each is stored raw viaUnknownProperty.StylesheetComposer.CreatePropertyand its dispatch inCreateAtRule.The rule round-trips:
@property --gap { syntax: "<length>"; initial-value: 0px; inherits: true }.Scope: object model only, no registration/substitution
This adds the object model for the
@propertyrule — parsing the prelude and the three descriptors into an inspectable, round-trippableIPropertyRule. It does not register the custom property or apply itssyntax/initial-value/inheritssemantics: nothing validates avar()substitution against the declaredsyntax, supplies theinitial-valuewhen a reference is invalid, or drives inheritance frominherits. Doing that is a computed-value/registered-property layer that would have to be built on top — the same substitution layer described in #211.To be useful at all, this needs #211 (custom properties and
var()):@propertyregisters a custom property, so without custom-property/var()support there is nothing for it to describe. #211 is the foundation; this is the@propertyrule on top of it, and a substitution/registration layer would sit above both. (This branch already carries the one--lexer change from #211 so it builds standalone — see Dependency below.)If a registration/computed-value layer would be useful upstream, I'm happy to contribute one as a follow-up: this was extracted from a downstream renderer that already applies the
@propertydescriptors (syntax-checked substitution,initial-valuefallback, inheritance) on top of exactly these types, so a version that builds on this framework already exists and could be adapted.Dependency
The
--nameprelude requires--to lex as a single ident, which is the lexer fix from "Add custom properties and var()" (#211). This branch includes that one lexer change so it's self-contained; if #211 merges first, it rebases cleanly.Tests
5 tests in
AtPropertyTests.cs: name/descriptor capture, round-trip, the universal*syntax,IPropertyRuleexposure, and an@propertyamong style rules.The full suite (1263 existing tests) stays green, and all seven target frameworks build with no new warnings.