Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/extendReactClass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import linkClass from './linkClass';
import React from 'react';
import _ from 'lodash';
import isObject from 'lodash/lang/isObject';
import assign from 'lodash/object/assign';

let extendReactClass;

Expand All @@ -18,8 +19,8 @@ extendReactClass = (Component, defaultStyles, options) => {

if (this.props.styles) {
styles = this.props.styles;
} else if (_.isObject(defaultStyles)) {
this.props = _.assign({}, this.props, {
} else if (isObject(defaultStyles)) {
this.props = assign({}, this.props, {
styles: defaultStyles
});

Expand Down
7 changes: 4 additions & 3 deletions src/linkClass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import makeConfiguration from './makeConfiguration';
import _ from 'lodash';
import filter from 'lodash/collection/filter';
import isArray from 'lodash/lang/isArray';

let linkClass;

Expand Down Expand Up @@ -29,7 +30,7 @@ linkClass = (element, styles = {}, userConfiguration) => {

if (styleNames) {
styleNames = styleNames.split(' ');
styleNames = _.filter(styleNames);
styleNames = filter(styleNames);

if (configuration.allowMultiple === false && styleNames.length > 1) {
throw new Error(`ReactElement styleName property defines multiple module names ("${element.props.styleName}").`);
Expand Down Expand Up @@ -64,7 +65,7 @@ linkClass = (element, styles = {}, userConfiguration) => {

if (React.isValidElement(element.props.children)) {
newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
} else if (_.isArray(element.props.children)) {
} else if (isArray(element.props.children)) {
newChildren = React.Children.map(element.props.children, (node) => {
if (React.isValidElement(node)) {
return linkClass(node, styles, configuration);
Expand Down
4 changes: 2 additions & 2 deletions src/makeConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import forEach from 'lodash/collection/forEach';

/**
* @typedef CSSModules~Options
Expand All @@ -19,7 +19,7 @@ export default (userConfiguration = {}) => {
errorWhenNotFound: true
};

_.forEach(userConfiguration, (value, name) => {
forEach(userConfiguration, (value, name) => {
if (typeof configuration[name] === 'undefined') {
throw new Error(`Unknown configuration property "${name}".`);
}
Expand Down
9 changes: 5 additions & 4 deletions src/wrapStatelessFunction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import linkClass from './linkClass';
import React from 'react';
import _ from 'lodash';
import assign from 'lodash/object/assign';
import isObject from 'lodash/lang/isObject';

let wrapStatelessFunction;

Expand All @@ -22,8 +23,8 @@ wrapStatelessFunction = (Component, defaultStyles, options) => {
if (props.styles) {
useProps = props;
styles = props.styles;
} else if (_.isObject(defaultStyles)) {
useProps = _.assign({}, props, {
} else if (isObject(defaultStyles)) {
useProps = assign({}, props, {
styles: defaultStyles
});

Expand All @@ -42,7 +43,7 @@ wrapStatelessFunction = (Component, defaultStyles, options) => {
return React.createElement('noscript');
};

_.assign(WrappedComponent, Component);
assign(WrappedComponent, Component);

return WrappedComponent;
};
Expand Down