align-items.js 2.1 KB

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