Skip to content

Commit

Permalink
Fix: variable names beginning with a keyword and dash (#2634)
Browse files Browse the repository at this point in the history
* Fix variables beginning with a keyword and dash
* Add trailing space
  • Loading branch information
groenroos committed Sep 22, 2021
1 parent d2cddcf commit 33a5fd9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lexer.js
Expand Up @@ -448,7 +448,7 @@ Lexer.prototype = {
keyword: function() {
var captures
, tok;
if (captures = /^(return|if|else|unless|for|in)\b[ \t]*/.exec(this.str)) {
if (captures = /^(return|if|else|unless|for|in)\b(?!-)[ \t]*/.exec(this.str)) {
var keyword = captures[1];
this.skip(captures);
if (this.isPartOfSelector()) {
Expand Down
13 changes: 13 additions & 0 deletions test/cases/regression.2422.css
@@ -0,0 +1,13 @@
.foobar {
border-radius: 4px;
columns: 5;
foo: 1;
foo: 2;
foo: 3;
}
@media (min-width: 600px) {
.foobar {
columns: 1;
font-weight: 700;
}
}
18 changes: 18 additions & 0 deletions test/cases/regression.2422.styl
@@ -0,0 +1,18 @@
forsooth = 4px
for-something = 5
if_bar = 700

for-tablet-portrait-up()
@media (min-width: 600px)
{block}

.foobar
border-radius: forsooth
columns: for-something

for --num in 1 2 3
foo: --num

+for-tablet-portrait-up()
columns: 1
font-weight: if_bar

0 comments on commit 33a5fd9

Please sign in to comment.