align-content.js 2.3 KB

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