flex-grow.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. var flexSpec = require('./flex-spec');
  6. var Declaration = require('../declaration');
  7. var Flex = function (_Declaration) {
  8. _inherits(Flex, _Declaration);
  9. function Flex() {
  10. _classCallCheck(this, Flex);
  11. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  12. }
  13. /**
  14. * Return property name by final spec
  15. */
  16. Flex.prototype.normalize = function normalize() {
  17. return 'flex';
  18. };
  19. /**
  20. * Return flex property for 2009 and 2012 specs
  21. */
  22. Flex.prototype.prefixed = function prefixed(prop, prefix) {
  23. var spec = void 0;
  24. var _flexSpec = flexSpec(prefix);
  25. spec = _flexSpec[0];
  26. prefix = _flexSpec[1];
  27. if (spec === 2009) {
  28. return prefix + 'box-flex';
  29. } else if (spec === 2012) {
  30. return prefix + 'flex-positive';
  31. } else {
  32. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  33. }
  34. };
  35. return Flex;
  36. }(Declaration);
  37. Object.defineProperty(Flex, 'names', {
  38. enumerable: true,
  39. writable: true,
  40. value: ['flex-grow', 'flex-positive']
  41. });
  42. module.exports = Flex;