Skip to content

Commit

Permalink
Merge pull request #2169 from SomMeri/comments-keyframe-rule
Browse files Browse the repository at this point in the history
Accept comments in @Keyframe and after rule name - merging for next patch release.
  • Loading branch information
SomMeri committed Aug 31, 2014
2 parents dc691d6 + 9c78547 commit e045362
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/less/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,7 @@ less.Parser = function Parser(env) {
value = this.detachedRuleset();
}

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

this.comments();

if (hasIdentifier) {
value = this.entity();
if (!value) {
Expand All @@ -1839,6 +1842,8 @@ less.Parser = function Parser(env) {
}
}

this.comments();

if (hasBlock) {
rules = this.blockRuleset();
}
Expand Down Expand Up @@ -2053,9 +2058,20 @@ less.Parser = function Parser(env) {
return name.push(a[1]);
}
}
function cutOutBlockComments() {
//match block comments
var a = /^\s*\/\*(?:[^*]|\*+[^\/*])*\*+\//.exec(c);
if (a) {
length += a[0].length;
c = c.slice(a[0].length);
return true;
}
return false;
}

match(/^(\*?)/);
while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // !
while (cutOutBlockComments());
if ((name.length > 1) && match(/^\s*((?:\+_|\+)?)\s*:/)) {
// at last, we have the complete match now. move forward,
// convert name particles to tree objects and return:
Expand Down
5 changes: 5 additions & 0 deletions test/css/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
.sr-only-focusable {
clip: auto;
}
@-webkit-keyframes hover {
0% {
color: red;
}
}
#last {
color: #0000ff;
}
Expand Down
8 changes: 7 additions & 1 deletion test/less/comments.less
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
*/

.selector /* .with */, .lots, /* of */ .comments {
color: grey, /* blue */ orange;
color/* survive */ /* me too */: grey, /* blue */ orange;
-webkit-border-radius: 2px /* webkit only */;
-moz-border-radius: (2px * 4) /* moz only with operation */;
}
Expand All @@ -84,6 +84,12 @@
clip: auto;
}

@-webkit-keyframes /* Safari */ hover /* and Chrome */ {
0% {
color: red;
}
}

#last { color: blue }
//

Expand Down

0 comments on commit e045362

Please sign in to comment.