|
| 1 | +/* @flow */ |
| 2 | +const alternativeProps = { |
| 3 | + marginBlockStart: ['WebkitMarginBefore'], |
| 4 | + marginBlockEnd: ['WebkitMarginAfter'], |
| 5 | + marginInlineStart: ['WebkitMarginStart', 'MozMarginStart'], |
| 6 | + marginInlineEnd: ['WebkitMarginEnd', 'MozMarginEnd'], |
| 7 | + paddingBlockStart: ['WebkitPaddingBefore'], |
| 8 | + paddingBlockEnd: ['WebkitPaddingAfter'], |
| 9 | + paddingInlineStart: ['WebkitPaddingStart', 'MozPaddingStart'], |
| 10 | + paddingInlineEnd: ['WebkitPaddingEnd', 'MozPaddingEnd'], |
| 11 | + borderBlockStart: ['WebkitBorderBefore'], |
| 12 | + borderBlockStartColor: ['WebkitBorderBeforeColor'], |
| 13 | + borderBlockStartStyle: ['WebkitBorderBeforeStyle'], |
| 14 | + borderBlockStartWidth: ['WebkitBorderBeforeWidth'], |
| 15 | + borderBlockEnd: ['WebkitBorderAfter'], |
| 16 | + borderBlockEndColor: ['WebkitBorderAfterColor'], |
| 17 | + borderBlockEndStyle: ['WebkitBorderAfterStyle'], |
| 18 | + borderBlockEndWidth: ['WebkitBorderAfterWidth'], |
| 19 | + borderInlineStart: ['WebkitBorderStart', 'MozBorderStart'], |
| 20 | + borderInlineStartColor: ['WebkitBorderStartColor', 'MozBorderStartColor'], |
| 21 | + borderInlineStartStyle: ['WebkitBorderStartStyle', 'MozBorderStartStyle'], |
| 22 | + borderInlineStartWidth: ['WebkitBorderStartWidth', 'MozBorderStartWidth'], |
| 23 | + borderInlineEnd: ['WebkitBorderEnd', 'MozBorderEnd'], |
| 24 | + borderInlineEndColor: ['WebkitBorderEndColor', 'MozBorderEndColor'], |
| 25 | + borderInlineEndStyle: ['WebkitBorderEndStyle', 'MozBorderEndStyle'], |
| 26 | + borderInlineEndWidth: ['WebkitBorderEndWidth', 'MozBorderEndWidth'], |
| 27 | +} |
| 28 | + |
| 29 | +export default function logical( |
| 30 | + property: string, |
| 31 | + value: any, |
| 32 | + style: Object |
| 33 | +): void { |
| 34 | + if (Object.prototype.hasOwnProperty.call(alternativeProps, property)) { |
| 35 | + const alternativePropList = alternativeProps[property] |
| 36 | + for (let i = 0, len = alternativePropList.length; i < len; ++i) { |
| 37 | + style[alternativePropList[i]] = value |
| 38 | + } |
| 39 | + } |
| 40 | +} |
0 commit comments