Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not put colorKeyword() into color() (like it was in #2775) because that way the function is called approximately twice more often (for no real reason).
(Obviously that way it works only because keyword() handles named colors in all other contexts, so eventually the whole thing will need some refactoring anyway).

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;
}