UNPKG

3.44 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
9var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
10
11var _checkProps = function checkProps() {};
12
13if (process.env.NODE_ENV !== 'production') {
14 // Warn if you use longhand and shorthand properties in the same style
15 // object.
16 // https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties
17
18 var shorthandPropertyExpansions = {
19 background: ['backgroundAttachment', 'backgroundBlendMode', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPosition', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundRepeatX', 'backgroundRepeatY', 'backgroundSize'],
20 border: ['borderBottom', 'borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderColor', 'borderLeft', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRight', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderStyle', 'borderTop', 'borderTopColor', 'borderTopStyle', 'borderTopWidth', 'borderWidth'],
21 borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'],
22 borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'],
23 font: ['fontFamily', 'fontKerning', 'fontSize', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantLigatures', 'fontWeight', 'lineHeight'],
24 listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'],
25 margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'],
26 padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'],
27 transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction']
28 };
29
30 _checkProps = function checkProps(config) {
31 var componentName = config.componentName,
32 style = config.style;
33
34 if ((typeof style === 'undefined' ? 'undefined' : _typeof(style)) !== 'object' || !style) {
35 return;
36 }
37
38 var styleKeys = Object.keys(style);
39 styleKeys.forEach(function (styleKey) {
40 if (Array.isArray(shorthandPropertyExpansions[styleKey]) && shorthandPropertyExpansions[styleKey].some(function (sp) {
41 return styleKeys.indexOf(sp) !== -1;
42 })) {
43 if (process.env.NODE_ENV !== 'production') {
44 /* eslint-disable no-console */
45 console.warn('Radium: property "' + styleKey + '" in style object', style, ': do not mix longhand and ' + 'shorthand properties in the same style object. Check the render ' + 'method of ' + componentName + '.', 'See https://github.com/FormidableLabs/radium/issues/95 for more ' + 'information.');
46 /* eslint-enable no-console */
47 }
48 }
49 });
50
51 styleKeys.forEach(function (k) {
52 return _checkProps(_extends({}, config, { style: style[k] }));
53 });
54 return;
55 };
56}
57
58exports.default = _checkProps;
59module.exports = exports['default'];
\No newline at end of file