Merge pull request #2643 from SomMeri/shorthand-color-interpolated-into-selector-1481

Keep shorthand color form the same way as named colors are kept.
This commit is contained in:
Luke Page
2015-09-09 13:03:03 +01:00
12 changed files with 21 additions and 18 deletions

View File

@@ -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);
}
},

View File

@@ -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`
@@ -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();