flex.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. (function() {
  2. var Declaration, Flex, flexSpec, list,
  3. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4. __hasProp = {}.hasOwnProperty;
  5. flexSpec = require('./flex-spec');
  6. Declaration = require('../declaration');
  7. list = require('postcss/lib/list');
  8. Flex = (function(_super) {
  9. __extends(Flex, _super);
  10. function Flex() {
  11. return Flex.__super__.constructor.apply(this, arguments);
  12. }
  13. Flex.names = ['flex', 'box-flex'];
  14. Flex.oldValues = {
  15. 'auto': '1',
  16. 'none': '0'
  17. };
  18. Flex.prototype.prefixed = function(prop, prefix) {
  19. var spec, _ref;
  20. _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1];
  21. if (spec === 2009) {
  22. return prefix + 'box-flex';
  23. } else {
  24. return Flex.__super__.prefixed.apply(this, arguments);
  25. }
  26. };
  27. Flex.prototype.normalize = function() {
  28. return 'flex';
  29. };
  30. Flex.prototype.set = function(decl, prefix) {
  31. var spec;
  32. spec = flexSpec(prefix)[0];
  33. if (spec === 2009) {
  34. decl.value = list.space(decl.value)[0];
  35. decl.value = Flex.oldValues[decl.value] || decl.value;
  36. return Flex.__super__.set.call(this, decl, prefix);
  37. } else {
  38. return Flex.__super__.set.apply(this, arguments);
  39. }
  40. };
  41. return Flex;
  42. })(Declaration);
  43. module.exports = Flex;
  44. }).call(this);