2023-12-18 13:12:25 +08:00
|
|
|
var walk = require('css-tree').walk;
|
|
|
|
var handlers = {
|
|
|
|
Atrule: require('./Atrule'),
|
|
|
|
AttributeSelector: require('./AttributeSelector'),
|
|
|
|
Value: require('./Value'),
|
|
|
|
Dimension: require('./Dimension'),
|
|
|
|
Percentage: require('./Percentage'),
|
|
|
|
Number: require('./Number'),
|
|
|
|
String: require('./String'),
|
|
|
|
Url: require('./Url'),
|
2024-01-16 21:26:16 +08:00
|
|
|
Hash: require('./color').compressHex,
|
2023-12-18 13:12:25 +08:00
|
|
|
Identifier: require('./color').compressIdent,
|
|
|
|
Function: require('./color').compressFunction
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = function(ast) {
|
|
|
|
walk(ast, {
|
|
|
|
leave: function(node, item, list) {
|
|
|
|
if (handlers.hasOwnProperty(node.type)) {
|
|
|
|
handlers[node.type].call(this, node, item, list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|