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.

85 lines
2.3 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 AlignSelf =
  8. /*#__PURE__*/
  9. function (_Declaration) {
  10. _inheritsLoose(AlignSelf, _Declaration);
  11. function AlignSelf() {
  12. return _Declaration.apply(this, arguments) || this;
  13. }
  14. var _proto = AlignSelf.prototype;
  15. _proto.check = function check(decl) {
  16. return decl.parent && !decl.parent.some(function (i) {
  17. return i.prop && i.prop.startsWith('grid-');
  18. });
  19. }
  20. /**
  21. * Change property name for 2012 specs
  22. */
  23. ;
  24. _proto.prefixed = function prefixed(prop, prefix) {
  25. var spec;
  26. var _flexSpec = flexSpec(prefix);
  27. spec = _flexSpec[0];
  28. prefix = _flexSpec[1];
  29. if (spec === 2012) {
  30. return prefix + 'flex-item-align';
  31. }
  32. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  33. }
  34. /**
  35. * Return property name by final spec
  36. */
  37. ;
  38. _proto.normalize = function normalize() {
  39. return 'align-self';
  40. }
  41. /**
  42. * Change value for 2012 spec and ignore prefix for 2009
  43. */
  44. ;
  45. _proto.set = function set(decl, prefix) {
  46. var spec = flexSpec(prefix)[0];
  47. if (spec === 2012) {
  48. decl.value = AlignSelf.oldValues[decl.value] || decl.value;
  49. return _Declaration.prototype.set.call(this, decl, prefix);
  50. }
  51. if (spec === 'final') {
  52. return _Declaration.prototype.set.call(this, decl, prefix);
  53. }
  54. return undefined;
  55. };
  56. return AlignSelf;
  57. }(Declaration);
  58. _defineProperty(AlignSelf, "names", ['align-self', 'flex-item-align']);
  59. _defineProperty(AlignSelf, "oldValues", {
  60. 'flex-end': 'end',
  61. 'flex-start': 'start'
  62. });
  63. module.exports = AlignSelf;