justify-content.js 2.4 KB

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