Skip to content

Commit 30fe1cb

Browse files
author
jurcovicovam
committed
Keep shorthand color form the same way as named colors are kept. less#2481
1 parent 3178103 commit 30fe1cb

File tree

12 files changed

+21
-18
lines changed

12 files changed

+21
-18
lines changed

lib/less/parser/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ var Parser = function Parser(context, imports, fileInfo) {
489489
if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
490490
error("Invalid HEX color code");
491491
}
492-
return new(tree.Color)(rgb[1]);
492+
return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString);
493493
}
494494
},
495495

lib/less/tree/color.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Node = require("./node"),
44
//
55
// RGB Colors - #ff0014, #eee
66
//
7-
var Color = function (rgb, a) {
7+
var Color = function (rgb, a, originalForm) {
88
//
99
// The end goal here, is to parse the arguments
1010
// into an integer triplet, such as `128, 255, 0`
@@ -23,6 +23,9 @@ var Color = function (rgb, a) {
2323
});
2424
}
2525
this.alpha = typeof a === 'number' ? a : 1;
26+
if (typeof originalForm !== 'undefined') {
27+
this.value = originalForm;
28+
}
2629
};
2730

2831
Color.prototype = new Node();

test/css/comments2.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* Safari and Chrome */
33
}
44
.bg {
5-
background-image: linear-gradient(#333333 /*{comment}*/, #111111);
5+
background-image: linear-gradient(#333 /*{comment}*/, #111);
66
}
77
#planadvisor,
88
.first,

test/css/compression/compression.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/css/extract-and-length.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.multiunit {
22
length: 6;
3-
extract: abc "abc" 1 1px 1% #112233;
3+
extract: abc "abc" 1 1px 1% #123;
44
}
55
.incorrect-index {
66
v1: extract(a b c, 5);

test/css/functions.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
height: undefined("self");
55
border-width: 5;
66
variable: 11;
7-
background: linear-gradient(#000000, #ffffff);
7+
background: linear-gradient(#000, #fff);
88
}
99
#built-in {
1010
escaped: -Some::weird(#thing, y);
@@ -60,15 +60,15 @@
6060
replace-single-quoted: 'foo-2';
6161
replace-escaped-string: bar-2;
6262
replace-keyword: baz-2;
63-
replace-with-color: "#113355#1133557";
63+
replace-with-color: "#135#1357";
6464
replace-with-number: "2em07";
6565
format: "rgb(32, 128, 64)";
6666
format-string: "hello world";
6767
format-multiple: "hello earth 2";
6868
format-url-encode: "red is %23ff0000";
6969
format-single-quoted: 'hello single world';
7070
format-escaped-string: hello escaped world;
71-
format-color-as-string: "#112233";
71+
format-color-as-string: "#123";
7272
format-number-as-string: "4px";
7373
eformat: rgb(32, 128, 64);
7474
unitless: 12;

test/css/mixins-args.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
body {
3636
padding: 30px;
37-
color: #ff0000;
37+
color: #f00;
3838
}
3939
.scope-mix {
4040
width: 8;

test/css/scope.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.tiny-scope {
2-
color: #998899;
2+
color: #989;
33
}
44
.scope1 {
55
color: blue;

test/css/strings.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#interpolation {
2929
url: "http://lesscss.org/dev/image.jpg";
3030
url2: "http://lesscss.org/image-256.jpg";
31-
url3: "http://lesscss.org#445566";
31+
url3: "http://lesscss.org#456";
3232
url4: "http://lesscss.org/hello";
3333
url5: "http://lesscss.org/54.4px";
3434
}

test/css/url-args/urls.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#shorthands {
66
background: url("http://www.lesscss.org/spec.html?424242") no-repeat 0 4px;
77
background: url("img.jpg?424242") center / 100px;
8-
background: #ffffff url(image.png?424242) center / 1px 100px repeat-x scroll content-box padding-box;
8+
background: #fff url(image.png?424242) center / 1px 100px repeat-x scroll content-box padding-box;
99
}
1010
#misc {
1111
background-image: url(images/image.jpg?424242);

test/css/urls.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#shorthands {
1313
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
1414
background: url("img.jpg") center / 100px;
15-
background: #ffffff url(image.png) center / 1px 100px repeat-x scroll content-box padding-box;
15+
background: #fff url(image.png) center / 1px 100px repeat-x scroll content-box padding-box;
1616
}
1717
#misc {
1818
background-image: url(images/image.jpg);

test/css/variables.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44
.variables {
55
height: 24px;
6-
color: #888888;
6+
color: #888;
77
font-family: "Trebuchet MS", Verdana, sans-serif;
88
quotes: "~" "~";
99
}
@@ -16,10 +16,10 @@
1616
.values {
1717
minus-one: -1;
1818
font-family: 'Trebuchet', 'Trebuchet', 'Trebuchet';
19-
color: #888888 !important;
20-
same-color: #888888 !important;
21-
same-again: #888888 !important;
22-
multi-important: #888888 #888888, 'Trebuchet' !important;
19+
color: #888 !important;
20+
same-color: #888 !important;
21+
same-again: #888 !important;
22+
multi-important: #888 #888, 'Trebuchet' !important;
2323
multi: something 'A', B, C, 'Trebuchet';
2424
}
2525
.variable-names .quoted {

0 commit comments

Comments
 (0)