Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function compressPercentage(node, item) {
node.value = packNumber(node.value, item);
if (node.value === '0' && this.declaration && !blacklist.has(this.declaration.property)) {
// try to convert a number
item.data = {
type: 'Number',
loc: node.loc,
value: node.value
};
// that's ok only when new value matches on length
if (!lexer.matchDeclaration(this.declaration).isType(item.data, 'length')) {
// otherwise rollback changes
item.data = node;
}
}
};
function compressIdent(node, item) {
if (this.declaration === null) {
return;
}
var color = node.name.toLowerCase();
if (NAME_TO_HEX.hasOwnProperty(color) &&
lexer.matchDeclaration(this.declaration).isType(node, 'color')) {
var hex = NAME_TO_HEX[color];
if (hex.length + 1 <= color.length) {
// replace for shorter hex value
item.data = {
type: 'HexColor',
loc: node.loc,
value: hex
};
} else {
// special case for consistent colors
if (color === 'grey') {
color = 'gray';
}
// just replace value for lower cased name