[6a3a178] | 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 FlexFlow = /*#__PURE__*/function (_Declaration) {
|
---|
| 14 | _inheritsLoose(FlexFlow, _Declaration);
|
---|
| 15 |
|
---|
| 16 | function FlexFlow() {
|
---|
| 17 | return _Declaration.apply(this, arguments) || this;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | var _proto = FlexFlow.prototype;
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * Use two properties for 2009 spec
|
---|
| 24 | */
|
---|
| 25 | _proto.insert = function insert(decl, prefix, prefixes) {
|
---|
| 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 _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | var values = decl.value.split(/\s+/).filter(function (i) {
|
---|
| 38 | return i !== 'wrap' && i !== 'nowrap' && 'wrap-reverse';
|
---|
| 39 | });
|
---|
| 40 |
|
---|
| 41 | if (values.length === 0) {
|
---|
| 42 | return undefined;
|
---|
| 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 value = values[0];
|
---|
| 54 | var orient = value.includes('row') ? 'horizontal' : 'vertical';
|
---|
| 55 | var dir = value.includes('reverse') ? 'reverse' : 'normal';
|
---|
| 56 | var cloned = this.clone(decl);
|
---|
| 57 | cloned.prop = prefix + 'box-orient';
|
---|
| 58 | cloned.value = orient;
|
---|
| 59 |
|
---|
| 60 | if (this.needCascade(decl)) {
|
---|
| 61 | cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | decl.parent.insertBefore(decl, cloned);
|
---|
| 65 | cloned = this.clone(decl);
|
---|
| 66 | cloned.prop = prefix + 'box-direction';
|
---|
| 67 | cloned.value = dir;
|
---|
| 68 |
|
---|
| 69 | if (this.needCascade(decl)) {
|
---|
| 70 | cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | return decl.parent.insertBefore(decl, cloned);
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | return FlexFlow;
|
---|
| 77 | }(Declaration);
|
---|
| 78 |
|
---|
| 79 | _defineProperty(FlexFlow, "names", ['flex-flow', 'box-direction', 'box-orient']);
|
---|
| 80 |
|
---|
| 81 | module.exports = FlexFlow; |
---|