align-content.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. "use strict";
  2. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  3. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
  4. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5. var flexSpec = require('./flex-spec');
  6. var Declaration = require('../declaration');
  7. var AlignContent = /*#__PURE__*/function (_Declaration) {
  8. _inheritsLoose(AlignContent, _Declaration);
  9. function AlignContent() {
  10. return _Declaration.apply(this, arguments) || this;
  11. }
  12. var _proto = AlignContent.prototype;
  13. /**
  14. * Change property name for 2012 spec
  15. */
  16. _proto.prefixed = function prefixed(prop, prefix) {
  17. var spec;
  18. var _flexSpec = flexSpec(prefix);
  19. spec = _flexSpec[0];
  20. prefix = _flexSpec[1];
  21. if (spec === 2012) {
  22. return prefix + 'flex-line-pack';
  23. }
  24. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  25. }
  26. /**
  27. * Return property name by final spec
  28. */
  29. ;
  30. _proto.normalize = function normalize() {
  31. return 'align-content';
  32. }
  33. /**
  34. * Change value for 2012 spec and ignore prefix for 2009
  35. */
  36. ;
  37. _proto.set = function set(decl, prefix) {
  38. var spec = flexSpec(prefix)[0];
  39. if (spec === 2012) {
  40. decl.value = AlignContent.oldValues[decl.value] || decl.value;
  41. return _Declaration.prototype.set.call(this, decl, prefix);
  42. }
  43. if (spec === 'final') {
  44. return _Declaration.prototype.set.call(this, decl, prefix);
  45. }
  46. return undefined;
  47. };
  48. return AlignContent;
  49. }(Declaration);
  50. _defineProperty(AlignContent, "names", ['align-content', 'flex-line-pack']);
  51. _defineProperty(AlignContent, "oldValues", {
  52. 'flex-end': 'end',
  53. 'flex-start': 'start',
  54. 'space-between': 'justify',
  55. 'space-around': 'distribute'
  56. });
  57. module.exports = AlignContent;