Skip to content

Commit

Permalink
Merge pull request #2806 from seven-phases-max/fix-named-colors-regre…
Browse files Browse the repository at this point in the history
…ssion

Fix comments after named color regression
  • Loading branch information
seven-phases-max committed Feb 6, 2016
2 parents 52198e2 + 01b11a7 commit 17efa86
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
42 changes: 19 additions & 23 deletions lib/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,26 +325,6 @@ var Parser = function Parser(context, imports, fileInfo) {
}
},

namedColor: function () {
parserInput.save();
var autoCommentAbsorb = parserInput.autoCommentAbsorb;
parserInput.autoCommentAbsorb = false;
var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/);
parserInput.autoCommentAbsorb = autoCommentAbsorb;
if (!k) {
parserInput.forget();
return ;
}
var result = tree.Color.fromKeyword(k);
if (!result) {
parserInput.restore();
} else {
parserInput.forget();
return result;
}

},

//
// A function call
//
Expand Down Expand Up @@ -511,8 +491,24 @@ var Parser = function Parser(context, imports, fileInfo) {
}
return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString);
}
},

return this.namedColor();
colorKeyword: function () {
parserInput.save();
var autoCommentAbsorb = parserInput.autoCommentAbsorb;
parserInput.autoCommentAbsorb = false;
var k = parserInput.$re(/^[A-Za-z]+/);
parserInput.autoCommentAbsorb = autoCommentAbsorb;
if (!k) {
parserInput.forget();
return;
}
parserInput.restore();
var color = tree.Color.fromKeyword(k);
if (color) {
parserInput.$str(k);
return color;
}
},

//
Expand Down Expand Up @@ -1706,8 +1702,8 @@ var Parser = function Parser(context, imports, fileInfo) {
}

var o = this.sub() || entities.dimension() ||
entities.variable() ||
entities.call() || entities.color();
entities.color() || entities.variable() ||
entities.call() || entities.colorKeyword();

if (negate) {
o.parensInOp = true;
Expand Down
6 changes: 6 additions & 0 deletions test/css/comments2.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
margin: 10px;
total-width: (1 * 6em * 12) + (2em * 12);
}
.some-inline-comments {
a: yes /* comment */;
b: red /* comment */;
c: yes /* comment */;
d: red /* comment */;
}
11 changes: 11 additions & 0 deletions test/less/comments2.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@
@gutter-width * // We strongly recommend you */
@columns); // do not change this formula. */
@total-width : @gridsystem-width; // set to 100% for fluid grid */

// .............................................................................

.some-inline-comments {
a: yes /* comment */;
b: red /* comment */;
@c: yes /* comment */;
@d: red /* comment */;
c: @c;
d: @d;
}

0 comments on commit 17efa86

Please sign in to comment.