index.js 740 B

123456789101112131415161718192021222324
  1. var walk = require('css-tree').walk;
  2. var handlers = {
  3. Atrule: require('./Atrule'),
  4. AttributeSelector: require('./AttributeSelector'),
  5. Value: require('./Value'),
  6. Dimension: require('./Dimension'),
  7. Percentage: require('./Percentage'),
  8. Number: require('./Number'),
  9. String: require('./String'),
  10. Url: require('./Url'),
  11. Hash: require('./color').compressHex,
  12. Identifier: require('./color').compressIdent,
  13. Function: require('./color').compressFunction
  14. };
  15. module.exports = function(ast) {
  16. walk(ast, {
  17. leave: function(node, item, list) {
  18. if (handlers.hasOwnProperty(node.type)) {
  19. handlers[node.type].call(this, node, item, list);
  20. }
  21. }
  22. });
  23. };