bug81a.js 702 B

123456789101112131415161718192021222324252627
  1. var postcss = require('postcss');
  2. module.exports = function(decl) {
  3. var regex = /(\d{1,}) (\d{1,}) (calc\(.*\))/g;
  4. var matches = regex.exec(decl.value);
  5. if (decl.prop === 'flex' && matches) {
  6. var grow = postcss.decl({
  7. prop: 'flex-grow',
  8. value: matches[1],
  9. source: decl.source
  10. });
  11. var shrink = postcss.decl({
  12. prop: 'flex-shrink',
  13. value: matches[2],
  14. source: decl.source
  15. });
  16. var basis = postcss.decl({
  17. prop: 'flex-basis',
  18. value: matches[3],
  19. source: decl.source
  20. });
  21. decl.parent.insertBefore(decl, grow);
  22. decl.parent.insertBefore(decl, shrink);
  23. decl.parent.insertBefore(decl, basis);
  24. decl.remove();
  25. }
  26. };