order.js 2.1 KB

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