flex-basis.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 FlexBasis =
  8. /*#__PURE__*/
  9. function (_Declaration) {
  10. _inheritsLoose(FlexBasis, _Declaration);
  11. function FlexBasis() {
  12. return _Declaration.apply(this, arguments) || this;
  13. }
  14. var _proto = FlexBasis.prototype;
  15. /**
  16. * Return property name by final spec
  17. */
  18. _proto.normalize = function normalize() {
  19. return 'flex-basis';
  20. }
  21. /**
  22. * Return flex property for 2012 spec
  23. */
  24. ;
  25. _proto.prefixed = function prefixed(prop, prefix) {
  26. var spec;
  27. var _flexSpec = flexSpec(prefix);
  28. spec = _flexSpec[0];
  29. prefix = _flexSpec[1];
  30. if (spec === 2012) {
  31. return prefix + 'flex-preferred-size';
  32. }
  33. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  34. }
  35. /**
  36. * Ignore 2009 spec and use flex property for 2012
  37. */
  38. ;
  39. _proto.set = function set(decl, prefix) {
  40. var spec;
  41. var _flexSpec2 = flexSpec(prefix);
  42. spec = _flexSpec2[0];
  43. prefix = _flexSpec2[1];
  44. if (spec === 2012 || spec === 'final') {
  45. return _Declaration.prototype.set.call(this, decl, prefix);
  46. }
  47. return undefined;
  48. };
  49. return FlexBasis;
  50. }(Declaration);
  51. _defineProperty(FlexBasis, "names", ['flex-basis', 'flex-preferred-size']);
  52. module.exports = FlexBasis;