Skip to content

Commit

Permalink
Two extra colons added when completing a pseudo-selector. Fixes micro…
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Nov 5, 2020
1 parent bd4f3e0 commit 9a01c75
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/parser/cssParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,11 @@ export class Parser {
return null;
}
// optional, support ::
if (this.accept(TokenType.Colon) && this.hasWhitespace()) {
this.markError(node, ParseError.IdentifierExpected);
}
if (!node.addChild(this._parseIdent())) {
this.markError(node, ParseError.IdentifierExpected);
this.accept(TokenType.Colon);
if (this.hasWhitespace() || !node.addChild(this._parseIdent())) {
return this.finish(node, ParseError.IdentifierExpected);
}
return node;
return this.finish(node);
}

public _tryParsePrio(): nodes.Node | null {
Expand Down
11 changes: 11 additions & 0 deletions src/test/css/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ suite('CSS - Completion', () => {
{ label: '::after', resultText: 'a::after ' }
]
});
await testCompletionFor('a::| foo { }', { // #104111
items: [
{ label: ':hover', resultText: 'a:hover ' },
{ label: '::after', resultText: 'a::after foo { }' }
]
});
await testCompletionFor('a:| foo { }', { // #104111
items: [
{ label: '::after', resultText: 'a::after foo { }' }
]
});
await testCompletionFor('a#| ', {
items: [
{ label: ':hover', resultText: 'a:hover ' },
Expand Down
2 changes: 2 additions & 0 deletions src/test/css/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ suite('CSS - Parser', () => {
assertNode(':global(.output ::selection)', parser, parser._parsePseudo.bind(parser)); // #49010
assertNode(':matches(:hover, :focus)', parser, parser._parsePseudo.bind(parser)); // #49010
assertNode(':host([foo=bar][bar=foo])', parser, parser._parsePseudo.bind(parser)); // #49589
assertError('::', parser, parser._parsePseudo.bind(parser), ParseError.IdentifierExpected);
assertError(':: foo', parser, parser._parsePseudo.bind(parser), ParseError.IdentifierExpected);
});

test('declaration', function () {
Expand Down

0 comments on commit 9a01c75

Please sign in to comment.