1 | "use strict";
|
---|
2 |
|
---|
3 | 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; }
|
---|
4 |
|
---|
5 | function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
|
---|
6 |
|
---|
7 | 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; }
|
---|
8 |
|
---|
9 | var flexSpec = require('./flex-spec');
|
---|
10 |
|
---|
11 | var Declaration = require('../declaration');
|
---|
12 |
|
---|
13 | var Order = /*#__PURE__*/function (_Declaration) {
|
---|
14 | _inheritsLoose(Order, _Declaration);
|
---|
15 |
|
---|
16 | function Order() {
|
---|
17 | return _Declaration.apply(this, arguments) || this;
|
---|
18 | }
|
---|
19 |
|
---|
20 | var _proto = Order.prototype;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Change property name for 2009 and 2012 specs
|
---|
24 | */
|
---|
25 | _proto.prefixed = function prefixed(prop, prefix) {
|
---|
26 | var spec;
|
---|
27 |
|
---|
28 | var _flexSpec = flexSpec(prefix);
|
---|
29 |
|
---|
30 | spec = _flexSpec[0];
|
---|
31 | prefix = _flexSpec[1];
|
---|
32 |
|
---|
33 | if (spec === 2009) {
|
---|
34 | return prefix + 'box-ordinal-group';
|
---|
35 | }
|
---|
36 |
|
---|
37 | if (spec === 2012) {
|
---|
38 | return prefix + 'flex-order';
|
---|
39 | }
|
---|
40 |
|
---|
41 | return _Declaration.prototype.prefixed.call(this, prop, prefix);
|
---|
42 | }
|
---|
43 | /**
|
---|
44 | * Return property name by final spec
|
---|
45 | */
|
---|
46 | ;
|
---|
47 |
|
---|
48 | _proto.normalize = function normalize() {
|
---|
49 | return 'order';
|
---|
50 | }
|
---|
51 | /**
|
---|
52 | * Fix value for 2009 spec
|
---|
53 | */
|
---|
54 | ;
|
---|
55 |
|
---|
56 | _proto.set = function set(decl, prefix) {
|
---|
57 | var spec = flexSpec(prefix)[0];
|
---|
58 |
|
---|
59 | if (spec === 2009 && /\d/.test(decl.value)) {
|
---|
60 | decl.value = (parseInt(decl.value) + 1).toString();
|
---|
61 | return _Declaration.prototype.set.call(this, decl, prefix);
|
---|
62 | }
|
---|
63 |
|
---|
64 | return _Declaration.prototype.set.call(this, decl, prefix);
|
---|
65 | };
|
---|
66 |
|
---|
67 | return Order;
|
---|
68 | }(Declaration);
|
---|
69 |
|
---|
70 | _defineProperty(Order, "names", ['order', 'flex-order', 'box-ordinal-group']);
|
---|
71 |
|
---|
72 | module.exports = Order; |
---|