Support the modern attr() type() syntax#495
Open
ATKasem wants to merge 1 commit into
Open
Conversation
attr() is parsed through the generic function machinery, so the modern attr( <name> <type>?, <fallback>? ) form reported false syntax errors: type(<length>) failed because the <length> syntax tokens are not valid value terms. Recognize type(<syntax>) as an argument, scoped to inside attr() via a depth guard so a user-defined type() function elsewhere is unaffected. Legacy attr(), units, raw-string, and Sass/Less variables are unchanged. Fixes microsoft#451
Author
|
@microsoft-github-policy-service agree |
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.
Fixes #451
attr()is parsed through the generic function machinery, so the modernattr( <name> <type>?, <fallback>? )form reported false syntax errors.attr(data-x type(<length>))produced) expectedandat-rule or selector expectedbecause the<length>syntax tokens insidetype()aren't valid value terms.This teaches the parser the
type( <syntax> )argument (*,<type-name>components joined with|, with optional+/#multipliers), scoped to insideattr()via a small depth counter so a user-definedtype()function elsewhere (e.g. a Sass@function type()) is left alone.Everything that already parsed keeps parsing the same way — legacy
attr(name)/attr(name unit)/attr(name, fallback),raw-string,type(*), emptyattr(), and Sass/Less variables. Malformed types such asattr(x type())orattr(x type(<length))still report an error.Added parser tests in
parser.test.tscovering the legacy forms, the moderntype()forms, the non-attrtype()guard, and the malformed cases.