flex-shrink.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 FlexShrink = function (_Declaration) {
  8. _inherits(FlexShrink, _Declaration);
  9. function FlexShrink() {
  10. _classCallCheck(this, FlexShrink);
  11. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  12. }
  13. /**
  14. * Return property name by final spec
  15. */
  16. FlexShrink.prototype.normalize = function normalize() {
  17. return 'flex-shrink';
  18. };
  19. /**
  20. * Return flex property for 2012 spec
  21. */
  22. FlexShrink.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 === 2012) {
  28. return prefix + 'flex-negative';
  29. } else {
  30. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  31. }
  32. };
  33. /**
  34. * Ignore 2009 spec and use flex property for 2012
  35. */
  36. FlexShrink.prototype.set = function set(decl, prefix) {
  37. var spec = void 0;
  38. var _flexSpec2 = flexSpec(prefix);
  39. spec = _flexSpec2[0];
  40. prefix = _flexSpec2[1];
  41. if (spec === 2012 || spec === 'final') {
  42. return _Declaration.prototype.set.call(this, decl, prefix);
  43. }
  44. return undefined;
  45. };
  46. return FlexShrink;
  47. }(Declaration);
  48. Object.defineProperty(FlexShrink, 'names', {
  49. enumerable: true,
  50. writable: true,
  51. value: ['flex-shrink', 'flex-negative']
  52. });
  53. module.exports = FlexShrink;