You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB

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