Skip to content

Commit

Permalink
Merge pull request less#2643 from SomMeri/shorthand-color-interpolate…
Browse files Browse the repository at this point in the history
…d-into-selector-1481

Keep shorthand color form the same way as named colors are kept.
  • Loading branch information
lukeapage committed Sep 9, 2015
2 parents 3ef676a + 30fe1cb commit 8a135bd
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 18 deletions.
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

0 comments on commit 8a135bd

Please sign in to comment.