update
This commit is contained in:
+7
-1
@@ -1,4 +1,10 @@
|
||||
var packNumber = require('./Number').pack;
|
||||
var MATH_FUNCTIONS = {
|
||||
'calc': true,
|
||||
'min': true,
|
||||
'max': true,
|
||||
'clamp': true
|
||||
};
|
||||
var LENGTH_UNIT = {
|
||||
// absolute length units
|
||||
'px': true,
|
||||
@@ -43,7 +49,7 @@ module.exports = function compressDimension(node, item) {
|
||||
}
|
||||
|
||||
// issue #222: don't remove units inside calc
|
||||
if (this.function && this.function.name === 'calc') {
|
||||
if (this.function && MATH_FUNCTIONS.hasOwnProperty(this.function.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ var OMIT_PLUSSIGN = /^(?:\+|(-))?0*(\d*)(?:\.0*|(\.\d*?)0*)?$/;
|
||||
var KEEP_PLUSSIGN = /^([\+\-])?0*(\d*)(?:\.0*|(\.\d*?)0*)?$/;
|
||||
var unsafeToRemovePlusSignAfter = {
|
||||
Dimension: true,
|
||||
HexColor: true,
|
||||
Hash: true,
|
||||
Identifier: true,
|
||||
Number: true,
|
||||
Raw: true,
|
||||
|
||||
+2
-2
@@ -442,7 +442,7 @@ function compressFunction(node, item, list) {
|
||||
}
|
||||
|
||||
item.data = {
|
||||
type: 'HexColor',
|
||||
type: 'Hash',
|
||||
loc: node.loc,
|
||||
value: toHex(args[0]) + toHex(args[1]) + toHex(args[2])
|
||||
};
|
||||
@@ -465,7 +465,7 @@ function compressIdent(node, item) {
|
||||
if (hex.length + 1 <= color.length) {
|
||||
// replace for shorter hex value
|
||||
item.data = {
|
||||
type: 'HexColor',
|
||||
type: 'Hash',
|
||||
loc: node.loc,
|
||||
value: hex
|
||||
};
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ var handlers = {
|
||||
Number: require('./Number'),
|
||||
String: require('./String'),
|
||||
Url: require('./Url'),
|
||||
HexColor: require('./color').compressHex,
|
||||
Hash: require('./color').compressHex,
|
||||
Identifier: require('./color').compressIdent,
|
||||
Function: require('./color').compressFunction
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user