order.js 2.1 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 Order =
  8. /*#__PURE__*/
  9. function (_Declaration) {
  10. _inheritsLoose(Order, _Declaration);
  11. function Order() {
  12. return _Declaration.apply(this, arguments) || this;
  13. }
  14. var _proto = Order.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-ordinal-group';
  25. }
  26. if (spec === 2012) {
  27. return prefix + 'flex-order';
  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 'order';
  37. }
  38. /**
  39. * Fix value for 2009 spec
  40. */
  41. ;
  42. _proto.set = function set(decl, prefix) {
  43. var spec = flexSpec(prefix)[0];
  44. if (spec === 2009 && /\d/.test(decl.value)) {
  45. decl.value = (parseInt(decl.value) + 1).toString();
  46. return _Declaration.prototype.set.call(this, decl, prefix);
  47. }
  48. return _Declaration.prototype.set.call(this, decl, prefix);
  49. };
  50. return Order;
  51. }(Declaration);
  52. _defineProperty(Order, "names", ['order', 'flex-order', 'box-ordinal-group']);
  53. module.exports = Order;