align-items.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 AlignItems = /*#__PURE__*/function (_Declaration) {
  8. _inheritsLoose(AlignItems, _Declaration);
  9. function AlignItems() {
  10. return _Declaration.apply(this, arguments) || this;
  11. }
  12. var _proto = AlignItems.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-align';
  23. }
  24. if (spec === 2012) {
  25. return prefix + 'flex-align';
  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 'align-items';
  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. decl.value = AlignItems.oldValues[decl.value] || decl.value;
  44. }
  45. return _Declaration.prototype.set.call(this, decl, prefix);
  46. };
  47. return AlignItems;
  48. }(Declaration);
  49. _defineProperty(AlignItems, "names", ['align-items', 'flex-align', 'box-align']);
  50. _defineProperty(AlignItems, "oldValues", {
  51. 'flex-end': 'end',
  52. 'flex-start': 'start'
  53. });
  54. module.exports = AlignItems;