No Description

flex.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. (function() {
  2. var Declaration, Flex, flexSpec, list,
  3. extend = 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(superClass) {
  9. extend(Flex, superClass);
  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 ref, spec;
  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);