source: trip-planner-front/node_modules/autoprefixer/lib/hacks/flex-direction.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1"use strict";
2
3function _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
5function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
6
7function _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
9var flexSpec = require('./flex-spec');
10
11var Declaration = require('../declaration');
12
13var FlexDirection = /*#__PURE__*/function (_Declaration) {
14 _inheritsLoose(FlexDirection, _Declaration);
15
16 function FlexDirection() {
17 return _Declaration.apply(this, arguments) || this;
18 }
19
20 var _proto = FlexDirection.prototype;
21
22 /**
23 * Return property name by final spec
24 */
25 _proto.normalize = function normalize() {
26 return 'flex-direction';
27 }
28 /**
29 * Use two properties for 2009 spec
30 */
31 ;
32
33 _proto.insert = function insert(decl, prefix, prefixes) {
34 var spec;
35
36 var _flexSpec = flexSpec(prefix);
37
38 spec = _flexSpec[0];
39 prefix = _flexSpec[1];
40
41 if (spec !== 2009) {
42 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
43 }
44
45 var already = decl.parent.some(function (i) {
46 return i.prop === prefix + 'box-orient' || i.prop === prefix + 'box-direction';
47 });
48
49 if (already) {
50 return undefined;
51 }
52
53 var v = decl.value;
54 var orient, dir;
55
56 if (v === 'inherit' || v === 'initial' || v === 'unset') {
57 orient = v;
58 dir = v;
59 } else {
60 orient = v.includes('row') ? 'horizontal' : 'vertical';
61 dir = v.includes('reverse') ? 'reverse' : 'normal';
62 }
63
64 var cloned = this.clone(decl);
65 cloned.prop = prefix + 'box-orient';
66 cloned.value = orient;
67
68 if (this.needCascade(decl)) {
69 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
70 }
71
72 decl.parent.insertBefore(decl, cloned);
73 cloned = this.clone(decl);
74 cloned.prop = prefix + 'box-direction';
75 cloned.value = dir;
76
77 if (this.needCascade(decl)) {
78 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
79 }
80
81 return decl.parent.insertBefore(decl, cloned);
82 }
83 /**
84 * Clean two properties for 2009 spec
85 */
86 ;
87
88 _proto.old = function old(prop, prefix) {
89 var spec;
90
91 var _flexSpec2 = flexSpec(prefix);
92
93 spec = _flexSpec2[0];
94 prefix = _flexSpec2[1];
95
96 if (spec === 2009) {
97 return [prefix + 'box-orient', prefix + 'box-direction'];
98 } else {
99 return _Declaration.prototype.old.call(this, prop, prefix);
100 }
101 };
102
103 return FlexDirection;
104}(Declaration);
105
106_defineProperty(FlexDirection, "names", ['flex-direction', 'box-direction', 'box-orient']);
107
108module.exports = FlexDirection;
Note: See TracBrowser for help on using the repository browser.