diff --git a/js/csslint/parserlib.js b/js/csslint/parserlib.js index 292fe959..562fa72b 100644 --- a/js/csslint/parserlib.js +++ b/js/csslint/parserlib.js @@ -647,6 +647,13 @@ self.parserlib = (() => { 'font-variation-settings', 'unicode-range', ].map(p => ({[p]: Properties[p]}))), + + '@font-palette-values': Object.assign({ + 'base-palette': 'light | dark | ', + 'override-colors': '[ ]#', + }, ...[ + 'font-family', + ].map(p => ({[p]: Properties[p]}))), }; for (const [k, reps] of Object.entries({ @@ -767,6 +774,8 @@ self.parserlib = (() => { '': ' | | cross-fade()', '': ' | min-content | max-content | auto', '': p => p.isInt || p.isCalc, + '': p => p.isInt && p.value >= 0 || p.isCalc, + '': p => p.isInt && p.value > 0 || p.isCalc, '': vtIsLength, '': p => p.value >= 0 && vtIsLength(p) || p.isCalc, @@ -797,7 +806,6 @@ self.parserlib = (() => { '': vtIsPct, '': p => p.value >= 0 && p.type === 'percentage' || p.isCalc, - '': p => p.isInt && p.value > 0 || p.isCalc, '': 'smaller | larger', '': '', '': 'center | start | end | self-start | self-end | flex-start | flex-end', @@ -862,7 +870,7 @@ self.parserlib = (() => { '': 'none | #', '': ' || ', '': ' | | rgb( ) | rgba( ) | ' + - 'hsl( ) | hsla( )', + 'hsl( ) | hsla( ) | hwb( )', '': '[ | | | ' + 'content( text | before | after | first-letter | marker ) | ' + @@ -895,7 +903,7 @@ self.parserlib = (() => { '': ' || || [ / ]? || ' + ' || || {1,2}', '': - 'repeat( [ ] , [ ? ]+ ? )', + 'repeat( [ ] , [ ? ]+ ? )', '': ' | ' + 'minmax( , ) | ' + 'minmax( , )', @@ -931,6 +939,7 @@ self.parserlib = (() => { '': '', '': '[ | ] {2} [ / ]? | ' + '[ | ] , #{2} [ , ]?', + '': '[ | | none ] [ | none ] [ | none ] [ / [ | none ] ]?', '': 'normal | | ' + '? [ | left | right ]', '': 'auto | normal | stretch | | ? ' + @@ -958,7 +967,7 @@ self.parserlib = (() => { '[ [ filled | open ] || [ dot | circle | double-circle | triangle | sesame ] ] | ' + '', '': '[ ? [ | ] ]+ ?', - '': 'repeat( [ ] , [ ? ]+ ? )', + '': 'repeat( [ ] , [ ? ]+ ? )', '': ' | minmax( , ) | ' + 'fit-content( )', '': @@ -1222,6 +1231,7 @@ self.parserlib = (() => { CHARSET_SYM: {text: '@charset'}, DOCUMENT_SYM: {text: ['@document', '@-moz-document']}, FONT_FACE_SYM: {text: '@font-face'}, + FONT_PALETTE_VALUES_SYM: {text: '@font-palette-values'}, IMPORT_SYM: {text: '@import'}, KEYFRAMES_SYM: {text: ['@keyframes', '@-webkit-keyframes', '@-moz-keyframes', '@-o-keyframes']}, LAYER_SYM: {text: '@layer'}, @@ -2014,7 +2024,7 @@ self.parserlib = (() => { * @returns {SyntaxUnit} */ static addFuncInfo(unit, {expr, name} = unit) { - const isColor = expr && expr.parts && /^(rgb|hsl)a?$/i.test(name); + const isColor = expr && expr.parts && /^((rgb|hsl)a?|hwb)$/i.test(name); if (isColor) unit.type = 'color'; unit._isAttr = unit._isCalc = @@ -3768,6 +3778,15 @@ self.parserlib = (() => { this.fire('endfontface'); } + _fontPaletteValues(start) { + this.fire({ + type: 'startfontpalettevalues', + id: this._tokenStream.mustMatch(Tokens.IDENT), + }, start); + this._readDeclarations({Props: ScopedProperties['@font-palette-values']}); + this.fire('endfontpalettevalues'); + } + _viewport(start) { // only viewport-fit is allowed but we're reusing MediaQuery syntax unit, // and accept anything for the sake of simplicity since the spec isn't yet final: @@ -4576,6 +4595,7 @@ self.parserlib = (() => { ParserRoute[Tokens.SUPPORTS_SYM] = { [Tokens.DOCUMENT_SYM]: Parser.prototype._documentMisplaced, [Tokens.FONT_FACE_SYM]: Parser.prototype._fontFace, + [Tokens.FONT_PALETTE_VALUES_SYM]: Parser.prototype._fontPaletteValues, [Tokens.KEYFRAMES_SYM]: Parser.prototype._keyframes, [Tokens.LAYER_SYM]: Parser.prototype._layer, [Tokens.MEDIA_SYM]: Parser.prototype._media,