Skip to content

Commit

Permalink
Fix a regression for at-rule syntax matching
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Aug 14, 2022
1 parent efdd3e7 commit de6c241
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## next

- Fixed a regression added in `2.2.0` for at-rule syntax matching when at-rule has no prelude

## 2.2.0 (August 10, 2022)

- Bumped `mdn-data` to `2.0.28`
Expand Down
7 changes: 7 additions & 0 deletions lib/__tests/lexer-match-atrule-prelude.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ describe('Lexer#matchAtrulePrelude()', () => {
});
});

it('should be positive when no prelude and at-rule has no prelude', () => {
const match = lexer.matchAtrulePrelude('font-face', null);

assert.strictEqual(match.matched, null);
assert.strictEqual(match.error, null);
});

describe('should not match css wide keywords', function() {
for (const keyword of cssWideKeywords) {
it(keyword, () => {
Expand Down
8 changes: 7 additions & 1 deletion lib/lexer/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ export class Lexer {
return buildMatchResult(null, error);
}

return matchSyntax(this, this.getAtrule(atruleName).prelude, prelude || '', false);
const atrule = this.getAtrule(atruleName);

if (!atrule.prelude) {
return buildMatchResult(null, null);
}

return matchSyntax(this, atrule.prelude, prelude || '', false);
}
matchAtruleDescriptor(atruleName, descriptorName, value) {
const error = this.checkAtruleDescriptorName(atruleName, descriptorName);
Expand Down

0 comments on commit de6c241

Please sign in to comment.