justify-content.js 2.4 KB

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