| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var shorthandParser = require('../parsers').shorthandParser;
|
|---|
| 4 | var shorthandSetter = require('../parsers').shorthandSetter;
|
|---|
| 5 | var shorthandGetter = require('../parsers').shorthandGetter;
|
|---|
| 6 |
|
|---|
| 7 | var shorthand_for = {
|
|---|
| 8 | 'flex-grow': require('./flexGrow'),
|
|---|
| 9 | 'flex-shrink': require('./flexShrink'),
|
|---|
| 10 | 'flex-basis': require('./flexBasis'),
|
|---|
| 11 | };
|
|---|
| 12 |
|
|---|
| 13 | var myShorthandSetter = shorthandSetter('flex', shorthand_for);
|
|---|
| 14 |
|
|---|
| 15 | module.exports.isValid = function isValid(v) {
|
|---|
| 16 | return shorthandParser(v, shorthand_for) !== undefined;
|
|---|
| 17 | };
|
|---|
| 18 |
|
|---|
| 19 | module.exports.definition = {
|
|---|
| 20 | set: function(v) {
|
|---|
| 21 | var normalizedValue = String(v)
|
|---|
| 22 | .trim()
|
|---|
| 23 | .toLowerCase();
|
|---|
| 24 |
|
|---|
| 25 | if (normalizedValue === 'none') {
|
|---|
| 26 | myShorthandSetter.call(this, '0 0 auto');
|
|---|
| 27 | return;
|
|---|
| 28 | }
|
|---|
| 29 | if (normalizedValue === 'initial') {
|
|---|
| 30 | myShorthandSetter.call(this, '0 1 auto');
|
|---|
| 31 | return;
|
|---|
| 32 | }
|
|---|
| 33 | if (normalizedValue === 'auto') {
|
|---|
| 34 | this.removeProperty('flex-grow');
|
|---|
| 35 | this.removeProperty('flex-shrink');
|
|---|
| 36 | this.setProperty('flex-basis', normalizedValue);
|
|---|
| 37 | return;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | myShorthandSetter.call(this, v);
|
|---|
| 41 | },
|
|---|
| 42 | get: shorthandGetter('flex', shorthand_for),
|
|---|
| 43 | enumerable: true,
|
|---|
| 44 | configurable: true,
|
|---|
| 45 | };
|
|---|