Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep shorthand color form the same way as named colors are kept. #2643

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
2 changes: 1 addition & 1 deletion lib/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ var Parser = function Parser(context, imports, fileInfo) {
if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
error("Invalid HEX color code");
}
return new(tree.Color)(rgb[1]);
return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString);
}
},

Expand Down
5 changes: 4 additions & 1 deletion lib/less/tree/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Node = require("./node"),
//
// RGB Colors - #ff0014, #eee
//
var Color = function (rgb, a) {
var Color = function (rgb, a, originalForm) {
//
// The end goal here, is to parse the arguments
// into an integer triplet, such as `128, 255, 0`
Expand All @@ -23,6 +23,9 @@ var Color = function (rgb, a) {
});
}
this.alpha = typeof a === 'number' ? a : 1;
if (typeof originalForm !== 'undefined') {
this.value = originalForm;
}
};

Color.prototype = new Node();
Expand Down
2 changes: 1 addition & 1 deletion test/css/comments2.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Safari and Chrome */
}
.bg {
background-image: linear-gradient(#333333 /*{comment}*/, #111111);
background-image: linear-gradient(#333 /*{comment}*/, #111);
}
#planadvisor,
.first,
Expand Down
2 changes: 1 addition & 1 deletion test/css/compression/compression.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/css/extract-and-length.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.multiunit {
length: 6;
extract: abc "abc" 1 1px 1% #112233;
extract: abc "abc" 1 1px 1% #123;
}
.incorrect-index {
v1: extract(a b c, 5);
Expand Down
6 changes: 3 additions & 3 deletions test/css/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
height: undefined("self");
border-width: 5;
variable: 11;
background: linear-gradient(#000000, #ffffff);
background: linear-gradient(#000, #fff);
}
#built-in {
escaped: -Some::weird(#thing, y);
Expand Down Expand Up @@ -60,15 +60,15 @@
replace-single-quoted: 'foo-2';
replace-escaped-string: bar-2;
replace-keyword: baz-2;
replace-with-color: "#113355#1133557";
replace-with-color: "#135#1357";
replace-with-number: "2em07";
format: "rgb(32, 128, 64)";
format-string: "hello world";
format-multiple: "hello earth 2";
format-url-encode: "red is %23ff0000";
format-single-quoted: 'hello single world';
format-escaped-string: hello escaped world;
format-color-as-string: "#112233";
format-color-as-string: "#123";
format-number-as-string: "4px";
eformat: rgb(32, 128, 64);
unitless: 12;
Expand Down
2 changes: 1 addition & 1 deletion test/css/mixins-args.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
body {
padding: 30px;
color: #ff0000;
color: #f00;
}
.scope-mix {
width: 8;
Expand Down
2 changes: 1 addition & 1 deletion test/css/scope.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.tiny-scope {
color: #998899;
color: #989;
}
.scope1 {
color: blue;
Expand Down
2 changes: 1 addition & 1 deletion test/css/strings.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#interpolation {
url: "http://lesscss.org/dev/image.jpg";
url2: "http://lesscss.org/image-256.jpg";
url3: "http://lesscss.org#445566";
url3: "http://lesscss.org#456";
url4: "http://lesscss.org/hello";
url5: "http://lesscss.org/54.4px";
}
Expand Down
2 changes: 1 addition & 1 deletion test/css/url-args/urls.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#shorthands {
background: url("http://www.lesscss.org/spec.html?424242") no-repeat 0 4px;
background: url("img.jpg?424242") center / 100px;
background: #ffffff url(image.png?424242) center / 1px 100px repeat-x scroll content-box padding-box;
background: #fff url(image.png?424242) center / 1px 100px repeat-x scroll content-box padding-box;
}
#misc {
background-image: url(images/image.jpg?424242);
Expand Down
2 changes: 1 addition & 1 deletion test/css/urls.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
background: url("img.jpg") center / 100px;
background: #ffffff url(image.png) center / 1px 100px repeat-x scroll content-box padding-box;
background: #fff url(image.png) center / 1px 100px repeat-x scroll content-box padding-box;
}
#misc {
background-image: url(images/image.jpg);
Expand Down
10 changes: 5 additions & 5 deletions test/css/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}
.variables {
height: 24px;
color: #888888;
color: #888;
font-family: "Trebuchet MS", Verdana, sans-serif;
quotes: "~" "~";
}
Expand All @@ -16,10 +16,10 @@
.values {
minus-one: -1;
font-family: 'Trebuchet', 'Trebuchet', 'Trebuchet';
color: #888888 !important;
same-color: #888888 !important;
same-again: #888888 !important;
multi-important: #888888 #888888, 'Trebuchet' !important;
color: #888 !important;
same-color: #888 !important;
same-again: #888 !important;
multi-important: #888 #888, 'Trebuchet' !important;
multi: something 'A', B, C, 'Trebuchet';
}
.variable-names .quoted {
Expand Down