align-content.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 AlignContent = function (_Declaration) {
  8. _inherits(AlignContent, _Declaration);
  9. function AlignContent() {
  10. _classCallCheck(this, AlignContent);
  11. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  12. }
  13. /**
  14. * Change property name for 2012 spec
  15. */
  16. AlignContent.prototype.prefixed = function prefixed(prop, prefix) {
  17. var spec = void 0;
  18. var _flexSpec = flexSpec(prefix);
  19. spec = _flexSpec[0];
  20. prefix = _flexSpec[1];
  21. if (spec === 2012) {
  22. return prefix + 'flex-line-pack';
  23. } else {
  24. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  25. }
  26. };
  27. /**
  28. * Return property name by final spec
  29. */
  30. AlignContent.prototype.normalize = function normalize() {
  31. return 'align-content';
  32. };
  33. /**
  34. * Change value for 2012 spec and ignore prefix for 2009
  35. */
  36. AlignContent.prototype.set = function set(decl, prefix) {
  37. var spec = flexSpec(prefix)[0];
  38. if (spec === 2012) {
  39. decl.value = AlignContent.oldValues[decl.value] || decl.value;
  40. return _Declaration.prototype.set.call(this, decl, prefix);
  41. } else if (spec === 'final') {
  42. return _Declaration.prototype.set.call(this, decl, prefix);
  43. }
  44. return undefined;
  45. };
  46. return AlignContent;
  47. }(Declaration);
  48. Object.defineProperty(AlignContent, 'names', {
  49. enumerable: true,
  50. writable: true,
  51. value: ['align-content', 'flex-line-pack']
  52. });
  53. Object.defineProperty(AlignContent, 'oldValues', {
  54. enumerable: true,
  55. writable: true,
  56. value: {
  57. 'flex-end': 'end',
  58. 'flex-start': 'start',
  59. 'space-between': 'justify',
  60. 'space-around': 'distribute'
  61. }
  62. });
  63. module.exports = AlignContent;