diff --git a/__tests__/value.js b/__tests__/value.js index 02abeeb..909b209 100644 --- a/__tests__/value.js +++ b/__tests__/value.js @@ -4249,8 +4249,8 @@ describe('', () => { expect(parse('', 'all', false, mediaQueryContext)).toMatchObject(mediaQueryList) }) test('valid', () => { - expect(parse('', ';, 1, (condition)', true, mediaQueryContext)) - .toBe('not all, not all, (condition)') + expect(parse('', ';, 1, (condition),', true, mediaQueryContext)) + .toBe('not all, not all, (condition), not all') expect(parse('', 'all and (condition)', true, mediaQueryContext)) .toBe('(condition)') }) diff --git a/lib/parse/parser.js b/lib/parse/parser.js index 7cc9fa0..165826e 100644 --- a/lib/parse/parser.js +++ b/lib/parse/parser.js @@ -1,6 +1,6 @@ const { createContext, getDeclarationValueDefinition, getRuleDefinition, getRuleType } = require('../utils/context.js') -const { isCloseCurlyBrace, isColon, isDelimiter, isOpenCurlyBrace, isSemicolon, isSimpleBlock, isWhitespace } = require('../utils/value.js') +const { isCloseCurlyBrace, isColon, isComma, isDelimiter, isOpenCurlyBrace, isSemicolon, isSimpleBlock, isWhitespace } = require('../utils/value.js') const Stream = require('./stream.js') const blocks = require('../values/blocks.js') const error = require('../error.js') @@ -384,10 +384,12 @@ function parseComponentValue(input) { */ function parseCommaSeparatedComponentValuesList(input) { input = normalizeIntoTokens(input) - const value = list([], ',') - while (!input.atEnd()) { + if (input.atEnd()) { + return list([], ',') + } + const value = list([consumeComponentValuesList(input, [','])], ',') + while (input.consume(isComma)) { value.push(consumeComponentValuesList(input, [','])) - input.consume() } return value }