Skip to content

Commit e045362

Browse files
committed
Merge pull request #2169 from SomMeri/comments-keyframe-rule
Accept comments in @Keyframe and after rule name - merging for next patch release.
2 parents dc691d6 + 9c78547 commit e045362

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

lib/less/parser.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ less.Parser = function Parser(env) {
15781578
value = this.detachedRuleset();
15791579
}
15801580

1581+
this.comments();
15811582
if (!value) {
15821583
// prefer to try to parse first if its a variable or we are compressing
15831584
// but always fallback on the other one
@@ -1822,6 +1823,8 @@ less.Parser = function Parser(env) {
18221823
break;
18231824
}
18241825

1826+
this.comments();
1827+
18251828
if (hasIdentifier) {
18261829
value = this.entity();
18271830
if (!value) {
@@ -1839,6 +1842,8 @@ less.Parser = function Parser(env) {
18391842
}
18401843
}
18411844

1845+
this.comments();
1846+
18421847
if (hasBlock) {
18431848
rules = this.blockRuleset();
18441849
}
@@ -2053,9 +2058,20 @@ less.Parser = function Parser(env) {
20532058
return name.push(a[1]);
20542059
}
20552060
}
2061+
function cutOutBlockComments() {
2062+
//match block comments
2063+
var a = /^\s*\/\*(?:[^*]|\*+[^\/*])*\*+\//.exec(c);
2064+
if (a) {
2065+
length += a[0].length;
2066+
c = c.slice(a[0].length);
2067+
return true;
2068+
}
2069+
return false;
2070+
}
20562071

20572072
match(/^(\*?)/);
20582073
while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // !
2074+
while (cutOutBlockComments());
20592075
if ((name.length > 1) && match(/^\s*((?:\+_|\+)?)\s*:/)) {
20602076
// at last, we have the complete match now. move forward,
20612077
// convert name particles to tree objects and return:

test/css/comments.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
.sr-only-focusable {
5959
clip: auto;
6060
}
61+
@-webkit-keyframes hover {
62+
0% {
63+
color: red;
64+
}
65+
}
6166
#last {
6267
color: #0000ff;
6368
}

test/less/comments.less

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
*/
6363

6464
.selector /* .with */, .lots, /* of */ .comments {
65-
color: grey, /* blue */ orange;
65+
color/* survive */ /* me too */: grey, /* blue */ orange;
6666
-webkit-border-radius: 2px /* webkit only */;
6767
-moz-border-radius: (2px * 4) /* moz only with operation */;
6868
}
@@ -84,6 +84,12 @@
8484
clip: auto;
8585
}
8686

87+
@-webkit-keyframes /* Safari */ hover /* and Chrome */ {
88+
0% {
89+
color: red;
90+
}
91+
}
92+
8793
#last { color: blue }
8894
//
8995

0 commit comments

Comments
 (0)