You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
903 B

'use strict';
const cssTree = require('css-tree');
const Atrule = require('./Atrule.cjs');
const AttributeSelector = require('./AttributeSelector.cjs');
const Value = require('./Value.cjs');
const Dimension = require('./Dimension.cjs');
const Percentage = require('./Percentage.cjs');
const _Number = require('./Number.cjs');
const Url = require('./Url.cjs');
const color = require('./color.cjs');
const handlers = {
Atrule,
AttributeSelector,
Value,
Dimension,
Percentage,
Number: _Number.Number,
Url,
Hash: color.compressHex,
Identifier: color.compressIdent,
Function: color.compressFunction
};
function replace(ast) {
cssTree.walk(ast, {
leave(node, item, list) {
if (handlers.hasOwnProperty(node.type)) {
handlers[node.type].call(this, node, item, list);
}
}
});
}
module.exports = replace;