This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+9
View File
@@ -1,5 +1,14 @@
var property = require('css-tree').property;
module.exports = function cleanDeclartion(node, item, list) {
if (node.value.children && node.value.children.isEmpty()) {
list.remove(item);
return;
}
if (property(node.property).custom) {
if (/\S/.test(node.value.value)) {
node.value.value = node.value.value.trim();
}
}
};
+7 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
};
+6 -2
View File
@@ -78,7 +78,7 @@ function TRBL(name) {
TRBL.prototype.getValueSequence = function(declaration, count) {
var values = [];
var iehack = '';
var hasBadValues = declaration.value.children.some(function(child) {
var hasBadValues = declaration.value.type !== 'Value' || declaration.value.children.some(function(child) {
var special = false;
switch (child.type) {
@@ -115,12 +115,16 @@ TRBL.prototype.getValueSequence = function(declaration, count) {
}
break;
case 'HexColor': // color
case 'Hash': // color
case 'Number':
case 'Percentage':
break;
case 'Function':
if (child.name === 'var') {
return true;
}
special = child.name;
break;
+17 -17
View File
@@ -14,17 +14,21 @@ var DONT_MIX_VALUE = {
'text-align': /^(start|end|match-parent|justify-all)$/i
};
var CURSOR_SAFE_VALUE = [
'auto', 'crosshair', 'default', 'move', 'text', 'wait', 'help',
'n-resize', 'e-resize', 's-resize', 'w-resize',
'ne-resize', 'nw-resize', 'se-resize', 'sw-resize',
'pointer', 'progress', 'not-allowed', 'no-drop', 'vertical-text', 'all-scroll',
'col-resize', 'row-resize'
];
var POSITION_SAFE_VALUE = [
'static', 'relative', 'absolute', 'fixed'
];
var SAFE_VALUES = {
cursor: [
'auto', 'crosshair', 'default', 'move', 'text', 'wait', 'help',
'n-resize', 'e-resize', 's-resize', 'w-resize',
'ne-resize', 'nw-resize', 'se-resize', 'sw-resize',
'pointer', 'progress', 'not-allowed', 'no-drop', 'vertical-text', 'all-scroll',
'col-resize', 'row-resize'
],
overflow: [
'hidden', 'visible', 'scroll', 'auto'
],
position: [
'static', 'relative', 'absolute', 'fixed'
]
};
var NEEDLESS_TABLE = {
'border-width': ['border'],
@@ -105,12 +109,8 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
iehack = RegExp.lastMatch;
}
if (realName === 'cursor') {
if (CURSOR_SAFE_VALUE.indexOf(name) === -1) {
special[name] = true;
}
} else if (realName === 'position') {
if (POSITION_SAFE_VALUE.indexOf(name) === -1) {
if (SAFE_VALUES.hasOwnProperty(realName)) {
if (SAFE_VALUES[realName].indexOf(name) === -1) {
special[name] = true;
}
} else if (DONT_MIX_VALUE.hasOwnProperty(realName)) {
+2 -2
View File
@@ -44,7 +44,7 @@ module.exports = function freeze(node, usageData) {
var name = node.name.toLowerCase();
if (!nonFreezePseudoClasses.hasOwnProperty(name)) {
pseudos[name] = true;
pseudos[':' + name] = true;
hasPseudo = true;
}
break;
@@ -53,7 +53,7 @@ module.exports = function freeze(node, usageData) {
var name = node.name.toLowerCase();
if (!nonFreezePseudoElements.hasOwnProperty(name)) {
pseudos[name] = true;
pseudos['::' + name] = true;
hasPseudo = true;
}
break;