From 72643f8293332f3189b43652cfa7d7c873e16a27 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 2 Sep 2015 07:27:20 +0100
Subject: [PATCH 001/200] Fix Invariant Violation when a single element child
is contained in an array.
---
src/linkClass.js | 5 ++++-
src/utils.js | 6 +++++-
test/linkClass.js | 40 +++++++++++++++++++++++++++++++++++-----
3 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/src/linkClass.js b/src/linkClass.js
index cad5d7a..7f339de 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -1,5 +1,6 @@
import React from 'react';
import makeConfiguration from './makeConfiguration';
+import _ from './utils';
let linkClass;
@@ -53,7 +54,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
if (typeof element.props.children !== 'string') {
childrenCount = React.Children.count(element.props.children);
- if (childrenCount > 1) {
+ if (childrenCount > 1 || _.isArray(element.props.children)) {
newChildren = React.Children.map(element.props.children, (node) => {
if (React.isValidElement(node)) {
return linkClass(node, styles, configuration);
@@ -61,6 +62,8 @@ linkClass = (element, styles = {}, userConfiguration) => {
return node;
}
});
+ // https://github.com/facebook/react/issues/4723#issuecomment-135555277
+ newChildren = _.values(newChildren);
} else if (childrenCount === 1) {
newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
}
diff --git a/src/utils.js b/src/utils.js
index 41f4480..0574ca3 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,5 +1,9 @@
import forEach from 'lodash/collection/forEach';
+import values from 'lodash/object/values';
+import isArray from 'lodash/lang/isArray';
export default {
- forEach
+ forEach,
+ values,
+ isArray
};
diff --git a/test/linkClass.js b/test/linkClass.js
index 649d7cb..23f1365 100644
--- a/test/linkClass.js
+++ b/test/linkClass.js
@@ -25,11 +25,41 @@ describe('linkClass', () => {
expect(linkClass(
)).to.deep.equal(
);
});
- // Using array instead of object causes the following error:
- // Warning: Each child in an array or iterator should have a unique "key" prop.
- // Check the render method of _class. See https://fb.me/react-warning-keys for more information.
- xit('does not affect element with multiple children', () => {
- expect(linkClass()).to.deep.equal();
+ // Does not affect
+ it('does not affect element with a single children when that children is contained in an array', () => {
+ let outcome,
+ subject;
+
+ subject = React.createElement('div', null, [
+ React.createElement('p')
+ ]);
+ outcome = React.createElement('div', null, [
+ React.createElement('p')
+ ]);
+
+ expect(linkClass(subject)).to.deep.equal(outcome);
+ });
+
+ it('does not affect element with multiple children', () => {
+ // Using array instead of object causes the following error:
+ // Warning: Each child in an array or iterator should have a unique "key" prop.
+ // Check the render method of _class. See https://fb.me/react-warning-keys for more information.
+ // @see https://github.com/facebook/react/issues/4723#issuecomment-135555277
+ // expect(linkClass()).to.deep.equal();
+
+ let outcome,
+ subject;
+
+ subject = React.createElement('div', null, [
+ React.createElement('p'),
+ React.createElement('p')
+ ]);
+ outcome = React.createElement('div', null, [
+ React.createElement('p'),
+ React.createElement('p')
+ ]);
+
+ expect(linkClass(subject)).to.deep.equal(outcome);
});
});
From cf46b7a075b5ac307c9c6220344385b20a86c88e Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 2 Sep 2015 07:27:37 +0100
Subject: [PATCH 002/200] 3.0.3
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 5de15dc..502109f 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.0.2",
+ "version": "3.0.3",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From f1ea7c4c3b5cc5c8b2617455a54a35cf61afbe3b Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 3 Sep 2015 16:49:23 +0100
Subject: [PATCH 003/200] This ought to fix the invariant violation error.
---
dist/linkClass.js | 18 ++++++++++++++----
dist/utils.js | 12 +++++++++++-
src/linkClass.js | 8 ++++++--
test/linkClass.js | 5 ++---
4 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/dist/linkClass.js b/dist/linkClass.js
index 38b0f43..d260d81 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -14,6 +14,10 @@ var _makeConfiguration = require('./makeConfiguration');
var _makeConfiguration2 = _interopRequireDefault(_makeConfiguration);
+var _utils = require('./utils');
+
+var _utils2 = _interopRequireDefault(_utils);
+
var linkClass = undefined;
/**
@@ -65,10 +69,12 @@ linkClass = function (element, styles, userConfiguration) {
// A child can be either an array, a sole object or a string.
// test
- if (typeof element.props.children !== 'string') {
+ if (_utils2['default'].isArray(element.props.children)) {
childrenCount = _react2['default'].Children.count(element.props.children);
- if (childrenCount > 1) {
+ // console.log('childrenCount', childrenCount, 'element.props.children', element.props.children);
+
+ if (childrenCount > 1 || _utils2['default'].isArray(element.props.children)) {
newChildren = _react2['default'].Children.map(element.props.children, function (node) {
if (_react2['default'].isValidElement(node)) {
return linkClass(node, styles, configuration);
@@ -76,9 +82,13 @@ linkClass = function (element, styles, userConfiguration) {
return node;
}
});
+ // https://github.com/facebook/react/issues/4723#issuecomment-135555277
+ // Forcing children into an array produces the following error:
+ // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
+ // newChildren = _.values(newChildren);
} else if (childrenCount === 1) {
- newChildren = linkClass(_react2['default'].Children.only(element.props.children), styles, configuration);
- }
+ newChildren = linkClass(_react2['default'].Children.only(element.props.children), styles, configuration);
+ }
}
if (appendClassName) {
diff --git a/dist/utils.js b/dist/utils.js
index ec988cd..651f52c 100644
--- a/dist/utils.js
+++ b/dist/utils.js
@@ -10,7 +10,17 @@ var _lodashCollectionForEach = require('lodash/collection/forEach');
var _lodashCollectionForEach2 = _interopRequireDefault(_lodashCollectionForEach);
+var _lodashObjectValues = require('lodash/object/values');
+
+var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
+
+var _lodashLangIsArray = require('lodash/lang/isArray');
+
+var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
+
exports['default'] = {
- forEach: _lodashCollectionForEach2['default']
+ forEach: _lodashCollectionForEach2['default'],
+ values: _lodashObjectValues2['default'],
+ isArray: _lodashLangIsArray2['default']
};
module.exports = exports['default'];
\ No newline at end of file
diff --git a/src/linkClass.js b/src/linkClass.js
index 7f339de..ec80e2f 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -51,9 +51,11 @@ linkClass = (element, styles = {}, userConfiguration) => {
// A child can be either an array, a sole object or a string.
// test
- if (typeof element.props.children !== 'string') {
+ if (_.isArray(element.props.children)) {
childrenCount = React.Children.count(element.props.children);
+ // console.log('childrenCount', childrenCount, 'element.props.children', element.props.children);
+
if (childrenCount > 1 || _.isArray(element.props.children)) {
newChildren = React.Children.map(element.props.children, (node) => {
if (React.isValidElement(node)) {
@@ -63,7 +65,9 @@ linkClass = (element, styles = {}, userConfiguration) => {
}
});
// https://github.com/facebook/react/issues/4723#issuecomment-135555277
- newChildren = _.values(newChildren);
+ // Forcing children into an array produces the following error:
+ // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
+ // newChildren = _.values(newChildren);
} else if (childrenCount === 1) {
newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
}
diff --git a/test/linkClass.js b/test/linkClass.js
index 23f1365..9a14d53 100644
--- a/test/linkClass.js
+++ b/test/linkClass.js
@@ -25,8 +25,7 @@ describe('linkClass', () => {
expect(linkClass(
)).to.deep.equal(
);
});
- // Does not affect
- it('does not affect element with a single children when that children is contained in an array', () => {
+ xit('does not affect element with a single children when that children is contained in an array', () => {
let outcome,
subject;
@@ -40,7 +39,7 @@ describe('linkClass', () => {
expect(linkClass(subject)).to.deep.equal(outcome);
});
- it('does not affect element with multiple children', () => {
+ xit('does not affect element with multiple children', () => {
// Using array instead of object causes the following error:
// Warning: Each child in an array or iterator should have a unique "key" prop.
// Check the render method of _class. See https://fb.me/react-warning-keys for more information.
From fb3272f1684b5f3b7e71d9f6a7b02caaf747cec5 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 3 Sep 2015 16:49:28 +0100
Subject: [PATCH 004/200] 3.0.4
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 502109f..4488917 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.0.3",
+ "version": "3.0.4",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 716afd57a94b25b9f5f6badc39dcccd1d45a8934 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 3 Sep 2015 20:04:38 +0100
Subject: [PATCH 005/200] Single ReactElement not an array.
---
dist/linkClass.js | 4 +---
src/linkClass.js | 4 +---
test/linkClass.js | 33 +++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/dist/linkClass.js b/dist/linkClass.js
index d260d81..f04da0b 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -67,9 +67,7 @@ linkClass = function (element, styles, userConfiguration) {
appendClassName = appendClassName.join(' ');
}
- // A child can be either an array, a sole object or a string.
- // test
- if (_utils2['default'].isArray(element.props.children)) {
+ if (_utils2['default'].isArray(element.props.children) || _react2['default'].isValidElement(element.props.children)) {
childrenCount = _react2['default'].Children.count(element.props.children);
// console.log('childrenCount', childrenCount, 'element.props.children', element.props.children);
diff --git a/src/linkClass.js b/src/linkClass.js
index ec80e2f..bef0e5a 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -49,9 +49,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
appendClassName = appendClassName.join(' ');
}
- // A child can be either an array, a sole object or a string.
- // test
- if (_.isArray(element.props.children)) {
+ if (_.isArray(element.props.children) || React.isValidElement(element.props.children)) {
childrenCount = React.Children.count(element.props.children);
// console.log('childrenCount', childrenCount, 'element.props.children', element.props.children);
diff --git a/test/linkClass.js b/test/linkClass.js
index 9a14d53..773cb37 100644
--- a/test/linkClass.js
+++ b/test/linkClass.js
@@ -63,6 +63,39 @@ describe('linkClass', () => {
});
context('when styleName matches an existing CSS module', () => {
+ context('when a descendant element has styleName', () => {
+ it('assigns a generated className', () => {
+ let subject;
+
+ subject = ;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1'
+ });
+
+ expect(subject.props.children.props.className).to.equal('foo-1');
+ });
+ });
+ context('when multiple descendant elements have styleName', () => {
+ it('assigns a generated className', () => {
+ let subject;
+
+ subject = ;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1',
+ bar: 'bar-1'
+ });
+
+ expect(subject.props.children['.0'].props.className).to.equal('foo-1');
+ expect(subject.props.children['.1'].props.className).to.equal('bar-1');
+ });
+ });
context('when ReactElement does not have an existing className', () => {
it('uses the generated class name to set the className property', () => {
let subject;
From b35c38b120c49c2d8272cb955025af9b4102cce5 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 3 Sep 2015 20:04:42 +0100
Subject: [PATCH 006/200] 3.0.5
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 4488917..a6a1197 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.0.4",
+ "version": "3.0.5",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 771ad8fad25119b9ed426a356547ea0b0931f4aa Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Sun, 6 Sep 2015 22:32:26 +0100
Subject: [PATCH 007/200] Implement code coverage.
---
.coveralls.yml | 1 +
.gitignore | 1 +
README.md | 1 +
package.json | 6 +++++-
4 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 .coveralls.yml
diff --git a/.coveralls.yml b/.coveralls.yml
new file mode 100644
index 0000000..1d423a5
--- /dev/null
+++ b/.coveralls.yml
@@ -0,0 +1 @@
+repo_token: 5kn7Xw8YAtWbwqqwmtPT55Sil0knFJz62
diff --git a/.gitignore b/.gitignore
index 6edd850..2d3bb39 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/node_modules
+/coverage
npm-debug.log
diff --git a/README.md b/README.md
index 022cd88..2b47230 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
[](https://travis-ci.org/gajus/react-css-modules)
[](https://www.npmjs.org/package/react-css-modules)
+[](https://coveralls.io/github/gajus/react-css-modules?branch=master)
diff --git a/package.json b/package.json
index a6a1197..2a68388 100644
--- a/package.json
+++ b/package.json
@@ -25,16 +25,20 @@
"devDependencies": {
"babel": "^5.8.21",
"babel-eslint": "^4.1.0",
+ "babel-istanbul": "^0.3.19",
"chai": "^3.2.0",
+ "coveralls": "^2.11.4",
"eslint": "^1.2.1",
"eslint-plugin-react": "^3.3.0",
"jsdom": "^6.2.0",
"mocha": "^2.2.5",
+ "mocha-lcov-reporter": "0.0.2",
"react": "^0.14.0-beta3",
"react-addons-test-utils": "^0.14.0-beta3"
},
"scripts": {
- "test": "./node_modules/.bin/eslint ./src/ ./test/ && mocha",
+ "lint": "./node_modules/.bin/eslint ./src/ ./test/",
+ "test": "npm run lint && node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha && cat ./coverage/lcov.info | coveralls",
"build": "babel ./src/ --out-dir ./dist/",
"watch": "babel --watch ./src/ --out-dir ./dist/"
}
From 3005914a2642d6601050fce3379b24adcab622cc Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Sun, 6 Sep 2015 22:33:05 +0100
Subject: [PATCH 008/200] Should not be public.
---
.coveralls.yml | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 .coveralls.yml
diff --git a/.coveralls.yml b/.coveralls.yml
deleted file mode 100644
index 1d423a5..0000000
--- a/.coveralls.yml
+++ /dev/null
@@ -1 +0,0 @@
-repo_token: 5kn7Xw8YAtWbwqqwmtPT55Sil0knFJz62
From 0da0eeb896f8f7f85a950fcf398e4ac17352f65b Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Sun, 6 Sep 2015 22:34:19 +0100
Subject: [PATCH 009/200] Ignore gitignore.
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 2d3bb39..e88d4be 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/node_modules
/coverage
+/.coveralls.yml
npm-debug.log
From 3f0365d6bd51ab86650039fd142ac8e8f48ae8d1 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Sun, 6 Sep 2015 22:35:56 +0100
Subject: [PATCH 010/200] Seems like token is required.
---
.coveralls.yml | 1 +
.gitignore | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
create mode 100644 .coveralls.yml
diff --git a/.coveralls.yml b/.coveralls.yml
new file mode 100644
index 0000000..c099fdc
--- /dev/null
+++ b/.coveralls.yml
@@ -0,0 +1 @@
+repo_token: vnqpbiGFbHmVwNwcJnseZAZ5X33epllne
diff --git a/.gitignore b/.gitignore
index e88d4be..2d3bb39 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
/node_modules
/coverage
-/.coveralls.yml
npm-debug.log
From 02240c3ab44593387fc652ab3ff7174ac85aca62 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 13:01:32 +0100
Subject: [PATCH 011/200] Updated depedencies.
---
.coveralls.yml | 2 +-
.gitignore | 1 +
LICENSE | 24 ++++++++++++++++++++++++
package.json | 25 +++++++++++++------------
test/linkClass.js | 6 ++++--
test/makeConfiguration.js | 2 ++
6 files changed, 45 insertions(+), 15 deletions(-)
create mode 100644 LICENSE
diff --git a/.coveralls.yml b/.coveralls.yml
index c099fdc..65bf7c7 100644
--- a/.coveralls.yml
+++ b/.coveralls.yml
@@ -1 +1 @@
-repo_token: vnqpbiGFbHmVwNwcJnseZAZ5X33epllne
+repo_token: bqiXmaOA0xarSUociqxGKJ72bp8SSHlQC
diff --git a/.gitignore b/.gitignore
index 2d3bb39..e0b6b81 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/node_modules
/coverage
npm-debug.log
+.coveralls.yml
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..183e8d8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2015, Gajus Kuizinas (http://gajus.com/)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/package.json b/package.json
index 2a68388..2e6a2aa 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "react-css-modules",
"description": "Seamless mapping of class names to CSS modules inside of React components.",
- "main": "dist/index.js",
+ "main": "./dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/gajus/react-css-modules"
@@ -23,22 +23,23 @@
"lodash": "^3.10.1"
},
"devDependencies": {
- "babel": "^5.8.21",
- "babel-eslint": "^4.1.0",
- "babel-istanbul": "^0.3.19",
+ "babel": "^5.8.23",
+ "babel-eslint": "^4.1.2",
+ "babel-istanbul": "^0.3.20",
"chai": "^3.2.0",
"coveralls": "^2.11.4",
- "eslint": "^1.2.1",
- "eslint-plugin-react": "^3.3.0",
- "jsdom": "^6.2.0",
- "mocha": "^2.2.5",
- "mocha-lcov-reporter": "0.0.2",
- "react": "^0.14.0-beta3",
- "react-addons-test-utils": "^0.14.0-beta3"
+ "eslint": "^1.4.3",
+ "eslint-plugin-react": "^3.3.2",
+ "jsdom": "^6.5.0",
+ "mocha": "^2.3.2",
+ "mocha-lcov-reporter": "^0.0.2",
+ "react": "^0.14.0-rc1",
+ "react-addons-test-utils": "^0.14.0-rc1"
},
"scripts": {
"lint": "./node_modules/.bin/eslint ./src/ ./test/",
- "test": "npm run lint && node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha && cat ./coverage/lcov.info | coveralls",
+ "quick-test": "npm run lint && node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha",
+ "test": "npm run quick-test && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"build": "babel ./src/ --out-dir ./dist/",
"watch": "babel --watch ./src/ --out-dir ./dist/"
}
diff --git a/test/linkClass.js b/test/linkClass.js
index 773cb37..273e4d8 100644
--- a/test/linkClass.js
+++ b/test/linkClass.js
@@ -1,3 +1,5 @@
+/* eslint-disable max-nested-callbacks */
+
import {
expect
} from 'chai';
@@ -92,8 +94,8 @@ describe('linkClass', () => {
bar: 'bar-1'
});
- expect(subject.props.children['.0'].props.className).to.equal('foo-1');
- expect(subject.props.children['.1'].props.className).to.equal('bar-1');
+ expect(subject.props.children[0].props.className).to.equal('foo-1');
+ expect(subject.props.children[1].props.className).to.equal('bar-1');
});
});
context('when ReactElement does not have an existing className', () => {
diff --git a/test/makeConfiguration.js b/test/makeConfiguration.js
index f805dde..3a74ae7 100644
--- a/test/makeConfiguration.js
+++ b/test/makeConfiguration.js
@@ -1,3 +1,5 @@
+/* eslint-disable max-nested-callbacks */
+
import {
expect
} from 'chai';
From a088497fe0c1aa755cbcfe8ae4a177306d7ce37e Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 13:01:36 +0100
Subject: [PATCH 012/200] 3.0.6
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 2e6a2aa..c025307 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.0.5",
+ "version": "3.0.6",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From c4bd4c19021e8f3b4800a8eac159acc22d270ebc Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 13:59:56 +0100
Subject: [PATCH 013/200] Simplified the logic for determining when to link
children.
---
dist/linkClass.js | 38 ++++++++++++++++++++------------------
src/linkClass.js | 41 +++++++++++++++++++++--------------------
2 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/dist/linkClass.js b/dist/linkClass.js
index f04da0b..2944de5 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -30,7 +30,6 @@ linkClass = function (element, styles, userConfiguration) {
if (styles === undefined) styles = {};
var appendClassName = undefined,
- childrenCount = undefined,
clonedElement = undefined,
configuration = undefined,
newChildren = undefined,
@@ -67,26 +66,29 @@ linkClass = function (element, styles, userConfiguration) {
appendClassName = appendClassName.join(' ');
}
- if (_utils2['default'].isArray(element.props.children) || _react2['default'].isValidElement(element.props.children)) {
- childrenCount = _react2['default'].Children.count(element.props.children);
+ // element.props.children can be one of the following:
+ // 'text'
+ // ['text']
+ // [ReactElement, 'text']
+ // ReactElement
- // console.log('childrenCount', childrenCount, 'element.props.children', element.props.children);
+ // console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));
- if (childrenCount > 1 || _utils2['default'].isArray(element.props.children)) {
- newChildren = _react2['default'].Children.map(element.props.children, function (node) {
- if (_react2['default'].isValidElement(node)) {
- return linkClass(node, styles, configuration);
- } else {
- return node;
- }
- });
- // https://github.com/facebook/react/issues/4723#issuecomment-135555277
- // Forcing children into an array produces the following error:
- // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
- // newChildren = _.values(newChildren);
- } else if (childrenCount === 1) {
- newChildren = linkClass(_react2['default'].Children.only(element.props.children), styles, configuration);
+ if (_react2['default'].isValidElement(element.props.children)) {
+ newChildren = linkClass(_react2['default'].Children.only(element.props.children), styles, configuration);
+ } else if (_utils2['default'].isArray(element.props.children)) {
+ newChildren = _react2['default'].Children.map(element.props.children, function (node) {
+ if (_react2['default'].isValidElement(node)) {
+ return linkClass(node, styles, configuration);
+ } else {
+ return node;
}
+ });
+
+ // https://github.com/facebook/react/issues/4723#issuecomment-135555277
+ // Forcing children into an array produces the following error:
+ // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
+ // newChildren = _.values(newChildren);
}
if (appendClassName) {
diff --git a/src/linkClass.js b/src/linkClass.js
index bef0e5a..ba28f56 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -12,7 +12,6 @@ let linkClass;
*/
linkClass = (element, styles = {}, userConfiguration) => {
let appendClassName,
- childrenCount,
clonedElement,
configuration,
newChildren,
@@ -49,28 +48,30 @@ linkClass = (element, styles = {}, userConfiguration) => {
appendClassName = appendClassName.join(' ');
}
- if (_.isArray(element.props.children) || React.isValidElement(element.props.children)) {
- childrenCount = React.Children.count(element.props.children);
+ // element.props.children can be one of the following:
+ // 'text'
+ // ['text']
+ // [ReactElement, 'text']
+ // ReactElement
- // console.log('childrenCount', childrenCount, 'element.props.children', element.props.children);
+ // console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));
- if (childrenCount > 1 || _.isArray(element.props.children)) {
- newChildren = React.Children.map(element.props.children, (node) => {
- if (React.isValidElement(node)) {
- return linkClass(node, styles, configuration);
- } else {
- return node;
- }
- });
- // https://github.com/facebook/react/issues/4723#issuecomment-135555277
- // Forcing children into an array produces the following error:
- // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
- // newChildren = _.values(newChildren);
- } else if (childrenCount === 1) {
- newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
- }
- }
+ if (React.isValidElement(element.props.children)) {
+ newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
+ } else if (_.isArray(element.props.children)) {
+ newChildren = React.Children.map(element.props.children, (node) => {
+ if (React.isValidElement(node)) {
+ return linkClass(node, styles, configuration);
+ } else {
+ return node;
+ }
+ });
+ // https://github.com/facebook/react/issues/4723#issuecomment-135555277
+ // Forcing children into an array produces the following error:
+ // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
+ // newChildren = _.values(newChildren);
+ }
if (appendClassName) {
if (element.props.className) {
From 9cad95b6a067e9dfb831cf43f53ac530c127e347 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 14:04:31 +0100
Subject: [PATCH 014/200] Using babel-plugin-lodash.
---
.babelrc | 5 ++++-
dist/linkClass.js | 12 ++++++------
dist/makeConfiguration.js | 10 +++++-----
package.json | 1 +
src/linkClass.js | 2 +-
src/makeConfiguration.js | 2 +-
src/utils.js | 9 ---------
7 files changed, 18 insertions(+), 23 deletions(-)
delete mode 100644 src/utils.js
diff --git a/.babelrc b/.babelrc
index 12606a3..89c0540 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,3 +1,6 @@
{
- "stage": 0
+ "stage": 0,
+ "plugins": [
+ "lodash"
+ ]
}
diff --git a/dist/linkClass.js b/dist/linkClass.js
index 2944de5..bcbda87 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -1,11 +1,13 @@
'use strict';
+var _lodashLangIsArray2 = require('lodash/lang/isArray');
+
+var _lodashLangIsArray3 = _interopRequireDefault(_lodashLangIsArray2);
+
Object.defineProperty(exports, '__esModule', {
value: true
});
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
@@ -14,9 +16,7 @@ var _makeConfiguration = require('./makeConfiguration');
var _makeConfiguration2 = _interopRequireDefault(_makeConfiguration);
-var _utils = require('./utils');
-
-var _utils2 = _interopRequireDefault(_utils);
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var linkClass = undefined;
@@ -76,7 +76,7 @@ linkClass = function (element, styles, userConfiguration) {
if (_react2['default'].isValidElement(element.props.children)) {
newChildren = linkClass(_react2['default'].Children.only(element.props.children), styles, configuration);
- } else if (_utils2['default'].isArray(element.props.children)) {
+ } else if ((0, _lodashLangIsArray3['default'])(element.props.children)) {
newChildren = _react2['default'].Children.map(element.props.children, function (node) {
if (_react2['default'].isValidElement(node)) {
return linkClass(node, styles, configuration);
diff --git a/dist/makeConfiguration.js b/dist/makeConfiguration.js
index d42ad79..b528fa5 100644
--- a/dist/makeConfiguration.js
+++ b/dist/makeConfiguration.js
@@ -1,15 +1,15 @@
'use strict';
+var _lodashCollectionForEach2 = require('lodash/collection/forEach');
+
+var _lodashCollectionForEach3 = _interopRequireDefault(_lodashCollectionForEach2);
+
Object.defineProperty(exports, '__esModule', {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-var _utils = require('./utils');
-
-var _utils2 = _interopRequireDefault(_utils);
-
/**
* @typedef CSSModules~Options
* @see {@link https://github.com/gajus/react-css-modules#options}
@@ -32,7 +32,7 @@ exports['default'] = function () {
errorWhenNotFound: true
};
- _utils2['default'].forEach(userConfiguration, function (value, name) {
+ (0, _lodashCollectionForEach3['default'])(userConfiguration, function (value, name) {
if (typeof configuration[name] === 'undefined') {
throw new Error('Unknown configuration property "' + name + '".');
}
diff --git a/package.json b/package.json
index c025307..31fc90f 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"babel": "^5.8.23",
"babel-eslint": "^4.1.2",
"babel-istanbul": "^0.3.20",
+ "babel-plugin-lodash": "^0.2.0",
"chai": "^3.2.0",
"coveralls": "^2.11.4",
"eslint": "^1.4.3",
diff --git a/src/linkClass.js b/src/linkClass.js
index ba28f56..6438591 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -1,6 +1,6 @@
import React from 'react';
import makeConfiguration from './makeConfiguration';
-import _ from './utils';
+import _ from 'lodash';
let linkClass;
diff --git a/src/makeConfiguration.js b/src/makeConfiguration.js
index e521af5..6889c75 100644
--- a/src/makeConfiguration.js
+++ b/src/makeConfiguration.js
@@ -1,4 +1,4 @@
-import _ from './utils';
+import _ from 'lodash';
/**
* @typedef CSSModules~Options
diff --git a/src/utils.js b/src/utils.js
deleted file mode 100644
index 0574ca3..0000000
--- a/src/utils.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import forEach from 'lodash/collection/forEach';
-import values from 'lodash/object/values';
-import isArray from 'lodash/lang/isArray';
-
-export default {
- forEach,
- values,
- isArray
-};
From 764cc6e9dfa68418e1ae4e894ea9782ee712b385 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 15:09:19 +0100
Subject: [PATCH 015/200] Using table example instead of car.
---
README.md | 60 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/README.md b/README.md
index 2b47230..0c9beb2 100644
--- a/README.md
+++ b/README.md
@@ -35,13 +35,15 @@ In the context of React, CSS Modules look like this:
```js
import React from 'react';
-import styles from './car.css';
+import styles from './table.css';
-export default class Car extends React.Component {
+export default class Table extends React.Component {
render () {
- return
-
-
+ return
;
}
}
@@ -50,9 +52,11 @@ export default class Car extends React.Component {
Rendering the component will produce a markup similar to:
```js
-
-
front-door
-
back-door
+
```
@@ -77,19 +81,21 @@ React CSS Modules component automates loading of CSS Modules using `styleName` p
```js
import React from 'react';
-import styles from './car.css';
import CSSModules from 'react-css-modules';
+import styles from './table.css';
-class Car extends React.Component {
+class Table extends React.Component {
render () {
- return
-
-
+ return
;
}
}
-export default CSSModules(Car, styles);
+export default CSSModules(Table, styles);
```
Using `react-css-modules`:
@@ -159,7 +165,7 @@ Refer to [`css-modulesify`](https://github.com/css-modules/css-modulesify).
/**
* @param {Function} Component
- * @param {Object} styles CSS Modules class map.
+ * @param {Object} defaultStyles CSS Modules class map.
* @param {CSSModules~Options} options
* @return {Function}
*/
@@ -169,19 +175,21 @@ You need to decorate your component using `react-css-modules`, e.g.
```js
import React from 'react';
-import styles from './car.css';
import CSSModules from 'react-css-modules';
+import styles from './table.css';
-class Car extends React.Component {
+class Table extends React.Component {
render () {
- return
-
-
+ return
;
}
}
-export default CSSModules(Car, styles);
+export default CSSModules(Table, styles);
```
Thats it!
@@ -190,15 +198,17 @@ As the name implies, `react-css-modules` is compatible with the [ES7 decorators]
```js
import React from 'react';
-import styles from './car.css';
import CSSModules from 'react-css-modules';
+import styles from './table.css';
@CSSModules(styles)
export default class extends React.Component {
render () {
- return
-
front-door
-
back-door
+ return
;
}
}
From 94d66ee001e74dc39bbfe7a7af05672f74908cf9 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 15:30:10 +0100
Subject: [PATCH 016/200] Added "styles" property.
---
README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
dist/index.js | 28 ++++++++++++++++------
src/index.js | 21 +++++++++++++----
3 files changed, 102 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index 0c9beb2..3f2eb1c 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [Module Bundler](#module-bundler)
- [webpack](#webpack)
- [Browserify](#browserify)
+ - [Extending CSS Styles](#extending-css-styles)
- [Decorator](#decorator)
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
@@ -153,6 +154,70 @@ Refer to [webpack-demo](https://github.com/css-modules/webpack-demo) or [react-c
Refer to [`css-modulesify`](https://github.com/css-modules/css-modulesify).
+### Extending CSS Styles
+
+Use `styles` property to overwrite the default component styles.
+
+Explanation using `Table` component:
+
+```js
+import React from 'react';
+import CSSModules from 'react-css-modules';
+import styles from './table.css';
+
+class Table extends React.Component {
+ render () {
+ return ;
+ }
+}
+
+export default CSSModules(Table, styles);
+```
+
+In this example, `CSSModules` is used to decorate `Table` component using `./table.css` CSS Modules. When `Table` component is rendered, it will use the properties of the `styles` object to construct `className` values.
+
+Using `styles` property you can overwrite the default component `styles` object, e.g.
+
+```js
+import customStyles from './table-custom-styles.css';
+
+;
+```
+
+[Interoperable CSS](https://github.com/css-modules/icss) can [extend other ICSS](https://github.com/css-modules/css-modules#dependencies). Use this feature to extend default styles, e.g.
+
+```css
+/* table-custom-styles.css */
+.table {
+ composes: table from './table.css';
+}
+
+.row {
+ composes: row from './table.css';
+}
+
+/* .cell {
+ composes: cell from './table.css';
+} */
+
+.table {
+ width: 400px;
+}
+
+.cell {
+ float: left; width: 154px; background: #eee; padding: 10px; margin: 10px 0 10px 10px;
+}
+```
+
+In this example, `table-custom-styles.css` selectively extends `table.css` (the default styles of `Table` component).
+
+Refer to the [`UsingStylesProperty` example](https://github.com/gajus/react-css-modules-examples/tree/master/src/UsingStylesProperty) for an example of a working implementation.
+
### Decorator
```js
diff --git a/dist/index.js b/dist/index.js
index c50da0c..9c0a983 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,5 +1,9 @@
'use strict';
+var _lodashLangIsObject2 = require('lodash/lang/isObject');
+
+var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
+
Object.defineProperty(exports, '__esModule', {
value: true
});
@@ -8,8 +12,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
@@ -18,6 +20,8 @@ var _linkClass = require('./linkClass');
var _linkClass2 = _interopRequireDefault(_linkClass);
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
var decoratorConstructor = undefined,
functionConstructor = undefined;
@@ -25,11 +29,11 @@ var decoratorConstructor = undefined,
* When used as a function.
*
* @param {Function} Component
- * @param {Object} styles CSS Modules class map.
+ * @param {Object} defaultStyles CSS Modules class map.
* @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
* @return {Function}
*/
-functionConstructor = function (Component, styles, options) {
+functionConstructor = function (Component, defaultStyles, options) {
return (function (_Component) {
_inherits(_class, _Component);
@@ -42,6 +46,16 @@ functionConstructor = function (Component, styles, options) {
_createClass(_class, [{
key: 'render',
value: function render() {
+ var styles = undefined;
+
+ if (this.props.styles) {
+ styles = this.props.styles;
+ } else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
+ styles = defaultStyles;
+ } else {
+ styles = {};
+ }
+
return (0, _linkClass2['default'])(_get(Object.getPrototypeOf(_class.prototype), 'render', this).call(this), styles, options);
}
}]);
@@ -53,13 +67,13 @@ functionConstructor = function (Component, styles, options) {
/**
* When used as a ES7 decorator.
*
- * @param {Object} styles CSS Modules class map.
+ * @param {Object} defaultStyles CSS Modules class map.
* @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
* @return {Function}
*/
-decoratorConstructor = function (styles, options) {
+decoratorConstructor = function (defaultStyles, options) {
return function (Component) {
- return functionConstructor(Component, styles, options);
+ return functionConstructor(Component, defaultStyles, options);
};
};
diff --git a/src/index.js b/src/index.js
index 75c3bff..3a0e728 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,5 @@
import linkClass from './linkClass';
+import _ from 'lodash';
let decoratorConstructor,
functionConstructor;
@@ -7,13 +8,23 @@ let decoratorConstructor,
* When used as a function.
*
* @param {Function} Component
- * @param {Object} styles CSS Modules class map.
+ * @param {Object} defaultStyles CSS Modules class map.
* @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
* @return {Function}
*/
-functionConstructor = (Component, styles, options) => {
+functionConstructor = (Component, defaultStyles, options) => {
return class extends Component {
render () {
+ let styles;
+
+ if (this.props.styles) {
+ styles = this.props.styles;
+ } else if (_.isObject(defaultStyles)) {
+ styles = defaultStyles;
+ } else {
+ styles = {};
+ }
+
return linkClass(super.render(), styles, options);
}
};
@@ -22,13 +33,13 @@ functionConstructor = (Component, styles, options) => {
/**
* When used as a ES7 decorator.
*
- * @param {Object} styles CSS Modules class map.
+ * @param {Object} defaultStyles CSS Modules class map.
* @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
* @return {Function}
*/
-decoratorConstructor = (styles, options) => {
+decoratorConstructor = (defaultStyles, options) => {
return (Component) => {
- return functionConstructor(Component, styles, options);
+ return functionConstructor(Component, defaultStyles, options);
};
};
From 83bc3582454fb2a087c011d3da0a130635b2b8ff Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 15:30:14 +0100
Subject: [PATCH 017/200] 3.1.0
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 31fc90f..3f3319b 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.0.6",
+ "version": "3.1.0",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From b30527c5921d584515afc2c5e84296abc4929e79 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Wed, 16 Sep 2015 15:32:34 +0100
Subject: [PATCH 018/200] Renamed README section.
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 3f2eb1c..68c603c 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [Module Bundler](#module-bundler)
- [webpack](#webpack)
- [Browserify](#browserify)
- - [Extending CSS Styles](#extending-css-styles)
+ - [Extending Component Styles](#extending-component-styles)
- [Decorator](#decorator)
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
@@ -154,7 +154,7 @@ Refer to [webpack-demo](https://github.com/css-modules/webpack-demo) or [react-c
Refer to [`css-modulesify`](https://github.com/css-modules/css-modulesify).
-### Extending CSS Styles
+### Extending Component Styles
Use `styles` property to overwrite the default component styles.
From b6558b574da667b43df04236232fd9ff1b125612 Mon Sep 17 00:00:00 2001
From: goncalvesjoao
Date: Thu, 17 Sep 2015 12:00:26 +0100
Subject: [PATCH 019/200] rendering in case of rendering to null
---
src/index.js | 12 +++++++--
test/reactCssModules.js | 57 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 2 deletions(-)
create mode 100644 test/reactCssModules.js
diff --git a/src/index.js b/src/index.js
index 3a0e728..fd2cb5e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,5 @@
import linkClass from './linkClass';
+import React from 'react';
import _ from 'lodash';
let decoratorConstructor,
@@ -15,7 +16,8 @@ let decoratorConstructor,
functionConstructor = (Component, defaultStyles, options) => {
return class extends Component {
render () {
- let styles;
+ let renderResult,
+ styles;
if (this.props.styles) {
styles = this.props.styles;
@@ -25,7 +27,13 @@ functionConstructor = (Component, defaultStyles, options) => {
styles = {};
}
- return linkClass(super.render(), styles, options);
+ renderResult = super.render();
+
+ if (renderResult) {
+ return linkClass(renderResult, styles, options);
+ }
+
+ return React.createElement('noscript');
}
};
};
diff --git a/test/reactCssModules.js b/test/reactCssModules.js
new file mode 100644
index 0000000..6a4d5f2
--- /dev/null
+++ b/test/reactCssModules.js
@@ -0,0 +1,57 @@
+import {
+ expect
+} from 'chai';
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import reactCssModules from './../src/index';
+
+describe('reactCssModules', () => {
+ context('when a ReactComponent renders an element with the styleName prop', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = reactCssModules(class extends React.Component {
+ render () {
+ return Hello
;
+ }
+ }, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
+
+ expect(component.props.className).to.equal('foo-1');
+ });
+ });
+
+ context('when a ReactComponent renders nothing', () => {
+ it('linkClass should not intervene', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = reactCssModules(class extends React.Component {
+ render () {
+ return null;
+ }
+ }, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
+
+ expect(typeof component).to.equal('object');
+ });
+ });
+});
From 563e215d50e23f69fae0f0cf0ec8322e6e8b9e29 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 13:35:17 +0100
Subject: [PATCH 020/200] Minor code style adjustments.
---
dist/index.js | 15 +++++++++++++--
test/reactCssModules.js | 18 +++++++++++-------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/dist/index.js b/dist/index.js
index 9c0a983..5355a24 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -20,6 +20,10 @@ var _linkClass = require('./linkClass');
var _linkClass2 = _interopRequireDefault(_linkClass);
+var _react = require('react');
+
+var _react2 = _interopRequireDefault(_react);
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var decoratorConstructor = undefined,
@@ -46,7 +50,8 @@ functionConstructor = function (Component, defaultStyles, options) {
_createClass(_class, [{
key: 'render',
value: function render() {
- var styles = undefined;
+ var renderResult = undefined,
+ styles = undefined;
if (this.props.styles) {
styles = this.props.styles;
@@ -56,7 +61,13 @@ functionConstructor = function (Component, defaultStyles, options) {
styles = {};
}
- return (0, _linkClass2['default'])(_get(Object.getPrototypeOf(_class.prototype), 'render', this).call(this), styles, options);
+ renderResult = _get(Object.getPrototypeOf(_class.prototype), 'render', this).call(this);
+
+ if (renderResult) {
+ return (0, _linkClass2['default'])(renderResult, styles, options);
+ }
+
+ return _react2['default'].createElement('noscript');
}
}]);
diff --git a/test/reactCssModules.js b/test/reactCssModules.js
index 6a4d5f2..e16d501 100644
--- a/test/reactCssModules.js
+++ b/test/reactCssModules.js
@@ -7,7 +7,7 @@ import TestUtils from 'react-addons-test-utils';
import reactCssModules from './../src/index';
describe('reactCssModules', () => {
- context('when a ReactComponent renders an element with the styleName prop', () => {
+ context('a ReactComponent renders an element with the styleName prop', () => {
it('that element should contain the equivalent className', () => {
let Foo,
component,
@@ -15,11 +15,13 @@ describe('reactCssModules', () => {
shallowRenderer = TestUtils.createRenderer();
- Foo = reactCssModules(class extends React.Component {
+ Foo = class extends React.Component {
render () {
return Hello
;
}
- }, {
+ };
+
+ Foo = reactCssModules(Foo, {
foo: 'foo-1'
});
@@ -31,19 +33,21 @@ describe('reactCssModules', () => {
});
});
- context('when a ReactComponent renders nothing', () => {
- it('linkClass should not intervene', () => {
+ context('a ReactComponent renders nothing', () => {
+ it('linkClass must not intervene', () => {
let Foo,
component,
shallowRenderer;
shallowRenderer = TestUtils.createRenderer();
- Foo = reactCssModules(class extends React.Component {
+ Foo = class extends React.Component {
render () {
return null;
}
- }, {
+ };
+
+ Foo = reactCssModules(Foo, {
foo: 'foo-1'
});
From c2283a865e9c5e880baddd2aa7e312677f9be2e7 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 13:35:26 +0100
Subject: [PATCH 021/200] 3.2.0
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 3f3319b..2d32151 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.1.0",
+ "version": "3.2.0",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From a6d7eebd10a150678bac69977a9979d4be88c088 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 13:45:23 +0100
Subject: [PATCH 022/200] Inherit displayName.
---
src/index.js | 2 ++
test/reactCssModules.js | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/src/index.js b/src/index.js
index fd2cb5e..f2f47e3 100644
--- a/src/index.js
+++ b/src/index.js
@@ -15,6 +15,8 @@ let decoratorConstructor,
*/
functionConstructor = (Component, defaultStyles, options) => {
return class extends Component {
+ static displayName = Component.displayName;
+
render () {
let renderResult,
styles;
diff --git a/test/reactCssModules.js b/test/reactCssModules.js
index e16d501..9687222 100644
--- a/test/reactCssModules.js
+++ b/test/reactCssModules.js
@@ -7,6 +7,19 @@ import TestUtils from 'react-addons-test-utils';
import reactCssModules from './../src/index';
describe('reactCssModules', () => {
+ context('a ReactComponent is decorated using react-css-modules', () => {
+ it('inherits displayName', () => {
+ let Foo;
+
+ Foo = class extends React.Component {
+ static displayName = 'Foo';
+ };
+
+ Foo = reactCssModules(Foo);
+
+ expect(Foo.displayName).to.equal('Foo');
+ });
+ });
context('a ReactComponent renders an element with the styleName prop', () => {
it('that element should contain the equivalent className', () => {
let Foo,
From 6bb6e5c09bbffd97f3e4310376ead04491c206b8 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 13:45:28 +0100
Subject: [PATCH 023/200] 3.2.1
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 2d32151..5bbabfc 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.2.0",
+ "version": "3.2.1",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 84013326545400198ebb6ec968def99ab4f33adc Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 17:02:41 +0100
Subject: [PATCH 024/200] Resolve displayName from target name when target
displayName is undefined.
---
src/index.js | 12 ++++++++++--
test/reactCssModules.js | 17 +++++++++++++++--
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/index.js b/src/index.js
index f2f47e3..40b225d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -14,9 +14,9 @@ let decoratorConstructor,
* @return {Function}
*/
functionConstructor = (Component, defaultStyles, options) => {
- return class extends Component {
- static displayName = Component.displayName;
+ let decoratedClass;
+ decoratedClass = class extends Component {
render () {
let renderResult,
styles;
@@ -38,6 +38,14 @@ functionConstructor = (Component, defaultStyles, options) => {
return React.createElement('noscript');
}
};
+
+ if (Component.displayName) {
+ decoratedClass.displayName = Component.displayName;
+ } else {
+ decoratedClass.displayName = Component.name;
+ }
+
+ return decoratedClass;
};
/**
diff --git a/test/reactCssModules.js b/test/reactCssModules.js
index 9687222..b759f76 100644
--- a/test/reactCssModules.js
+++ b/test/reactCssModules.js
@@ -1,3 +1,5 @@
+/* eslint-disable max-nested-callbacks */
+
import {
expect
} from 'chai';
@@ -12,12 +14,23 @@ describe('reactCssModules', () => {
let Foo;
Foo = class extends React.Component {
- static displayName = 'Foo';
+ static displayName = 'Bar';
};
Foo = reactCssModules(Foo);
- expect(Foo.displayName).to.equal('Foo');
+ expect(Foo.displayName).to.equal('Bar');
+ });
+ context('target component does not name displayName', () => {
+ it('uses name for displayName', () => {
+ let Foo;
+
+ Foo = class Bar extends React.Component {};
+
+ Foo = reactCssModules(Foo);
+
+ expect(Foo.displayName).to.equal('Bar');
+ });
});
});
context('a ReactComponent renders an element with the styleName prop', () => {
From 01a6129aeabe8c7966f566d5b4bb93cfa648db0a Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 17:02:45 +0100
Subject: [PATCH 025/200] 3.2.2
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 5bbabfc..d98d663 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.2.1",
+ "version": "3.2.2",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 9773e060d0f19a981e25294b0ba29762f228f1fe Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 21:04:13 +0100
Subject: [PATCH 026/200] Forgot to build.
---
dist/index.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dist/index.js b/dist/index.js
index 5355a24..06bc887 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -38,7 +38,9 @@ var decoratorConstructor = undefined,
* @return {Function}
*/
functionConstructor = function (Component, defaultStyles, options) {
- return (function (_Component) {
+ var decoratedClass = undefined;
+
+ decoratedClass = (function (_Component) {
_inherits(_class, _Component);
function _class() {
@@ -73,6 +75,14 @@ functionConstructor = function (Component, defaultStyles, options) {
return _class;
})(Component);
+
+ if (Component.displayName) {
+ decoratedClass.displayName = Component.displayName;
+ } else {
+ decoratedClass.displayName = Component.name;
+ }
+
+ return decoratedClass;
};
/**
From 65637602a187524e451484c42b3f06e93e4ce977 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Thu, 17 Sep 2015 21:04:18 +0100
Subject: [PATCH 027/200] 3.2.3
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index d98d663..a227d02 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.2.2",
+ "version": "3.2.3",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From d122c4d293ae85eb0fdc6b617de1f9d107ed705a Mon Sep 17 00:00:00 2001
From: Justin Deal
Date: Tue, 22 Sep 2015 21:09:47 -0500
Subject: [PATCH 028/200] allow null elements from render methods
---
dist/linkClass.js | 4 ++++
src/linkClass.js | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/dist/linkClass.js b/dist/linkClass.js
index bcbda87..69e7ff0 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -36,6 +36,10 @@ linkClass = function (element, styles, userConfiguration) {
newProps = undefined,
styleNames = undefined;
+ if (!element) {
+ return element;
+ }
+
configuration = (0, _makeConfiguration2['default'])(userConfiguration);
styleNames = element.props.styleName;
diff --git a/src/linkClass.js b/src/linkClass.js
index 6438591..d6552d8 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -18,6 +18,10 @@ linkClass = (element, styles = {}, userConfiguration) => {
newProps,
styleNames;
+ if (!element) {
+ return element;
+ }
+
configuration = makeConfiguration(userConfiguration);
styleNames = element.props.styleName;
From cbb86690cfccc392f89a96a5d2abd53681eea70a Mon Sep 17 00:00:00 2001
From: Rick Runyon
Date: Wed, 23 Sep 2015 10:43:42 -0400
Subject: [PATCH 029/200] Fix link in README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 68c603c..6d77ca7 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [Class Composition Using CSS Preprocessors](#class-composition-using-css-preprocessors)
- [SASS, SCSS, LESS and other CSS Preprocessors](#sass-scss-less-and-other-css-preprocessors)
- [Global CSS](#global-css)
-- [Multiple CSS Classes](#multiple-css-classes)
+- [Multiple CSS Modules](#multiple-css-modules)
## CSS Modules
From 617647743226601b17ca84eaf468ee7dbb7de8eb Mon Sep 17 00:00:00 2001
From: Luke William Westby
Date: Sat, 26 Sep 2015 13:29:01 -0500
Subject: [PATCH 030/200] enable stateless function components
---
src/extendReactClass.js | 32 +++++++++++
src/index.js | 30 ++--------
src/wrapStatelessFunction.js | 30 ++++++++++
test/reactCssModules.js | 106 +++++++++++++++++++++++++----------
4 files changed, 143 insertions(+), 55 deletions(-)
create mode 100644 src/extendReactClass.js
create mode 100644 src/wrapStatelessFunction.js
diff --git a/src/extendReactClass.js b/src/extendReactClass.js
new file mode 100644
index 0000000..a4017bc
--- /dev/null
+++ b/src/extendReactClass.js
@@ -0,0 +1,32 @@
+import linkClass from './linkClass';
+import React from 'react';
+import _ from 'lodash';
+
+let extendReactClass;
+
+extendReactClass = (Component, defaultStyles, options) => {
+ return class extends Component {
+ render () {
+ let renderResult,
+ styles;
+
+ if (this.props.styles) {
+ styles = this.props.styles;
+ } else if (_.isObject(defaultStyles)) {
+ styles = defaultStyles;
+ } else {
+ styles = {};
+ }
+
+ renderResult = super.render();
+
+ if (renderResult) {
+ return linkClass(renderResult, styles, options);
+ }
+
+ return React.createElement('noscript');
+ }
+ };
+};
+
+export default extendReactClass;
diff --git a/src/index.js b/src/index.js
index 40b225d..491e1de 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,5 @@
-import linkClass from './linkClass';
-import React from 'react';
-import _ from 'lodash';
+import extendReactClass from './extendReactClass';
+import wrapStatelessFunction from './wrapStatelessFunction';
let decoratorConstructor,
functionConstructor;
@@ -16,28 +15,9 @@ let decoratorConstructor,
functionConstructor = (Component, defaultStyles, options) => {
let decoratedClass;
- decoratedClass = class extends Component {
- render () {
- let renderResult,
- styles;
-
- if (this.props.styles) {
- styles = this.props.styles;
- } else if (_.isObject(defaultStyles)) {
- styles = defaultStyles;
- } else {
- styles = {};
- }
-
- renderResult = super.render();
-
- if (renderResult) {
- return linkClass(renderResult, styles, options);
- }
-
- return React.createElement('noscript');
- }
- };
+ decoratedClass = Component.isReactClass ?
+ extendReactClass(Component, defaultStyles, options) :
+ wrapStatelessFunction(Component, defaultStyles, options);
if (Component.displayName) {
decoratedClass.displayName = Component.displayName;
diff --git a/src/wrapStatelessFunction.js b/src/wrapStatelessFunction.js
new file mode 100644
index 0000000..d75b2e1
--- /dev/null
+++ b/src/wrapStatelessFunction.js
@@ -0,0 +1,30 @@
+import linkClass from './linkClass';
+import React from 'react';
+import _ from 'lodash';
+
+let wrapStatelessFunction;
+
+wrapStatelessFunction = (Component, defaultStyles, options) => {
+ return (props, ...args) => {
+ let renderResult,
+ styles;
+
+ if (props.styles) {
+ styles = props.styles;
+ } else if (_.isObject(defaultStyles)) {
+ styles = defaultStyles;
+ } else {
+ styles = {};
+ }
+
+ renderResult = Component(props, ...args);
+
+ if (renderResult) {
+ return linkClass(renderResult, styles, options);
+ }
+
+ return React.createElement('noscript');
+ };
+};
+
+export default wrapStatelessFunction;
diff --git a/test/reactCssModules.js b/test/reactCssModules.js
index b759f76..685988f 100644
--- a/test/reactCssModules.js
+++ b/test/reactCssModules.js
@@ -34,54 +34,100 @@ describe('reactCssModules', () => {
});
});
context('a ReactComponent renders an element with the styleName prop', () => {
- it('that element should contain the equivalent className', () => {
- let Foo,
- component,
- shallowRenderer;
+ context('the component is a class that extends React.Component', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
- shallowRenderer = TestUtils.createRenderer();
+ shallowRenderer = TestUtils.createRenderer();
- Foo = class extends React.Component {
- render () {
- return Hello
;
- }
- };
+ Foo = class extends React.Component {
+ render () {
+ return Hello
;
+ }
+ };
+
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
- Foo = reactCssModules(Foo, {
- foo: 'foo-1'
+ expect(component.props.className).to.equal('foo-1');
});
+ });
+ context('the component is a stateless function component', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = () => Hello
;
- shallowRenderer.render( );
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
- component = shallowRenderer.getRenderOutput();
+ shallowRenderer.render( );
- expect(component.props.className).to.equal('foo-1');
+ component = shallowRenderer.getRenderOutput();
+
+ expect(component.props.className).to.equal('foo-1');
+ });
});
});
context('a ReactComponent renders nothing', () => {
- it('linkClass must not intervene', () => {
- let Foo,
- component,
- shallowRenderer;
+ context('the component is a class that extends React.Component', () => {
+ it('linkClass must not intervene', () => {
+ let Foo,
+ component,
+ shallowRenderer;
- shallowRenderer = TestUtils.createRenderer();
+ shallowRenderer = TestUtils.createRenderer();
- Foo = class extends React.Component {
- render () {
- return null;
- }
- };
+ Foo = class extends React.Component {
+ render () {
+ return null;
+ }
+ };
+
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
- Foo = reactCssModules(Foo, {
- foo: 'foo-1'
+ expect(typeof component).to.equal('object');
});
+ });
+ context('the component is a stateless function component', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = () => null;
- shallowRenderer.render( );
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
- component = shallowRenderer.getRenderOutput();
+ shallowRenderer.render( );
- expect(typeof component).to.equal('object');
+ component = shallowRenderer.getRenderOutput();
+
+ expect(typeof component).to.equal('object');
+ });
});
});
});
From 8857b8c6b338ff0d91400684726ed152a8a904c2 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 12:12:31 +0100
Subject: [PATCH 031/200] 3.3.0
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index a227d02..2ee8505 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.2.3",
+ "version": "3.3.0",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 39b9b66a73879ba70f78f073d4b156065435ed98 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 12:21:42 +0100
Subject: [PATCH 032/200] Include build for the previous release.
---
dist/extendReactClass.js | 70 +++++++++++++++++++++++++++++++++++
dist/wrapStatelessFunction.js | 51 +++++++++++++++++++++++++
2 files changed, 121 insertions(+)
create mode 100644 dist/extendReactClass.js
create mode 100644 dist/wrapStatelessFunction.js
diff --git a/dist/extendReactClass.js b/dist/extendReactClass.js
new file mode 100644
index 0000000..ca8d448
--- /dev/null
+++ b/dist/extendReactClass.js
@@ -0,0 +1,70 @@
+'use strict';
+
+var _lodashLangIsObject2 = require('lodash/lang/isObject');
+
+var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+
+var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
+
+var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var _linkClass = require('./linkClass');
+
+var _linkClass2 = _interopRequireDefault(_linkClass);
+
+var _react = require('react');
+
+var _react2 = _interopRequireDefault(_react);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+var extendReactClass = undefined;
+
+extendReactClass = function (Component, defaultStyles, options) {
+ return (function (_Component) {
+ _inherits(_class, _Component);
+
+ function _class() {
+ _classCallCheck(this, _class);
+
+ _get(Object.getPrototypeOf(_class.prototype), 'constructor', this).apply(this, arguments);
+ }
+
+ _createClass(_class, [{
+ key: 'render',
+ value: function render() {
+ var renderResult = undefined,
+ styles = undefined;
+
+ if (this.props.styles) {
+ styles = this.props.styles;
+ } else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
+ styles = defaultStyles;
+ } else {
+ styles = {};
+ }
+
+ renderResult = _get(Object.getPrototypeOf(_class.prototype), 'render', this).call(this);
+
+ if (renderResult) {
+ return (0, _linkClass2['default'])(renderResult, styles, options);
+ }
+
+ return _react2['default'].createElement('noscript');
+ }
+ }]);
+
+ return _class;
+ })(Component);
+};
+
+exports['default'] = extendReactClass;
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/dist/wrapStatelessFunction.js b/dist/wrapStatelessFunction.js
new file mode 100644
index 0000000..a763d6d
--- /dev/null
+++ b/dist/wrapStatelessFunction.js
@@ -0,0 +1,51 @@
+'use strict';
+
+var _lodashLangIsObject2 = require('lodash/lang/isObject');
+
+var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+
+var _linkClass = require('./linkClass');
+
+var _linkClass2 = _interopRequireDefault(_linkClass);
+
+var _react = require('react');
+
+var _react2 = _interopRequireDefault(_react);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+var wrapStatelessFunction = undefined;
+
+wrapStatelessFunction = function (Component, defaultStyles, options) {
+ return function (props) {
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ var renderResult = undefined,
+ styles = undefined;
+
+ if (props.styles) {
+ styles = props.styles;
+ } else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
+ styles = defaultStyles;
+ } else {
+ styles = {};
+ }
+
+ renderResult = Component.apply(undefined, [props].concat(args));
+
+ if (renderResult) {
+ return (0, _linkClass2['default'])(renderResult, styles, options);
+ }
+
+ return _react2['default'].createElement('noscript');
+ };
+};
+
+exports['default'] = wrapStatelessFunction;
+module.exports = exports['default'];
\ No newline at end of file
From c24fd43bcab4b7a0eabe71ec6f77c3f83b29d408 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 12:22:13 +0100
Subject: [PATCH 033/200] Trim CSS modules declared in styleNames.
---
dist/index.js | 58 +++++------------------------------------------
dist/linkClass.js | 5 ++++
src/linkClass.js | 1 +
test/linkClass.js | 23 +++++++++++++++++--
4 files changed, 33 insertions(+), 54 deletions(-)
diff --git a/dist/index.js b/dist/index.js
index 06bc887..a77cac7 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,30 +1,18 @@
'use strict';
-var _lodashLangIsObject2 = require('lodash/lang/isObject');
-
-var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
-
Object.defineProperty(exports, '__esModule', {
value: true
});
-var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
-
-var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-var _linkClass = require('./linkClass');
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-var _linkClass2 = _interopRequireDefault(_linkClass);
+var _extendReactClass = require('./extendReactClass');
-var _react = require('react');
+var _extendReactClass2 = _interopRequireDefault(_extendReactClass);
-var _react2 = _interopRequireDefault(_react);
+var _wrapStatelessFunction = require('./wrapStatelessFunction');
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+var _wrapStatelessFunction2 = _interopRequireDefault(_wrapStatelessFunction);
var decoratorConstructor = undefined,
functionConstructor = undefined;
@@ -40,41 +28,7 @@ var decoratorConstructor = undefined,
functionConstructor = function (Component, defaultStyles, options) {
var decoratedClass = undefined;
- decoratedClass = (function (_Component) {
- _inherits(_class, _Component);
-
- function _class() {
- _classCallCheck(this, _class);
-
- _get(Object.getPrototypeOf(_class.prototype), 'constructor', this).apply(this, arguments);
- }
-
- _createClass(_class, [{
- key: 'render',
- value: function render() {
- var renderResult = undefined,
- styles = undefined;
-
- if (this.props.styles) {
- styles = this.props.styles;
- } else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
- styles = defaultStyles;
- } else {
- styles = {};
- }
-
- renderResult = _get(Object.getPrototypeOf(_class.prototype), 'render', this).call(this);
-
- if (renderResult) {
- return (0, _linkClass2['default'])(renderResult, styles, options);
- }
-
- return _react2['default'].createElement('noscript');
- }
- }]);
-
- return _class;
- })(Component);
+ decoratedClass = Component.isReactClass ? (0, _extendReactClass2['default'])(Component, defaultStyles, options) : (0, _wrapStatelessFunction2['default'])(Component, defaultStyles, options);
if (Component.displayName) {
decoratedClass.displayName = Component.displayName;
diff --git a/dist/linkClass.js b/dist/linkClass.js
index bcbda87..8d0dc79 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -1,5 +1,9 @@
'use strict';
+var _lodashCollectionFilter2 = require('lodash/collection/filter');
+
+var _lodashCollectionFilter3 = _interopRequireDefault(_lodashCollectionFilter2);
+
var _lodashLangIsArray2 = require('lodash/lang/isArray');
var _lodashLangIsArray3 = _interopRequireDefault(_lodashLangIsArray2);
@@ -42,6 +46,7 @@ linkClass = function (element, styles, userConfiguration) {
if (styleNames) {
styleNames = styleNames.split(' ');
+ styleNames = (0, _lodashCollectionFilter3['default'])(styleNames);
if (configuration.allowMultiple === false && styleNames.length > 1) {
throw new Error('ReactElement styleName property defines multiple module names ("' + element.props.styleName + '").');
diff --git a/src/linkClass.js b/src/linkClass.js
index 6438591..951059c 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -24,6 +24,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
if (styleNames) {
styleNames = styleNames.split(' ');
+ styleNames = _.filter(styleNames);
if (configuration.allowMultiple === false && styleNames.length > 1) {
throw new Error(`ReactElement styleName property defines multiple module names ("${element.props.styleName}").`);
diff --git a/test/linkClass.js b/test/linkClass.js
index 273e4d8..96f2c74 100644
--- a/test/linkClass.js
+++ b/test/linkClass.js
@@ -10,7 +10,7 @@ import jsdom from 'jsdom';
import linkClass from './../src/linkClass';
describe('linkClass', () => {
- context('when ReactElement does not define styleName', () => {
+ context('ReactElement does not define styleName', () => {
it('does not affect element properties', () => {
expect(linkClass(
)).to.deep.equal(
);
});
@@ -64,7 +64,7 @@ describe('linkClass', () => {
});
});
- context('when styleName matches an existing CSS module', () => {
+ context('styleName matches an existing CSS module', () => {
context('when a descendant element has styleName', () => {
it('assigns a generated className', () => {
let subject;
@@ -126,6 +126,25 @@ describe('linkClass', () => {
});
});
+ context('styleName includes multiple whitespace characters', () => {
+ it('resolves CSS modules', () => {
+ let subject;
+
+ subject = ;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1',
+ bar: 'bar-1'
+ }, {
+ allowMultiple: true
+ });
+
+ expect(subject.props.children.props.className).to.equal('foo-1 bar-1');
+ });
+ });
+
describe('options.allowMultiple', () => {
context('when multiple module names are used', () => {
context('when false', () => {
From 5b1a4587d528b974be515ca8165c7ddd48182711 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 12:22:27 +0100
Subject: [PATCH 034/200] 3.3.1
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 2ee8505..fc6b50d 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.3.0",
+ "version": "3.3.1",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 95211f4a52d3b50504336b53f696606c13ed6868 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 12:28:42 +0100
Subject: [PATCH 035/200] A test case for
https://github.com/gajus/react-css-modules/pull/30.
---
src/linkClass.js | 1 +
test/linkClass.js | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/src/linkClass.js b/src/linkClass.js
index 075d092..1c16a57 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -18,6 +18,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
newProps,
styleNames;
+ // @see https://github.com/gajus/react-css-modules/pull/30
if (!element) {
return element;
}
diff --git a/test/linkClass.js b/test/linkClass.js
index 96f2c74..83cbf67 100644
--- a/test/linkClass.js
+++ b/test/linkClass.js
@@ -64,6 +64,16 @@ describe('linkClass', () => {
});
});
+ context('called with null instead of ReactElement', () => {
+ it('returns null', () => {
+ let subject;
+
+ subject = linkClass(null);
+
+ expect(subject).to.equal(null);
+ });
+ });
+
context('styleName matches an existing CSS module', () => {
context('when a descendant element has styleName', () => {
it('assigns a generated className', () => {
From c268a18612a8ce5c506734fd78850217f01c4351 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 12:28:48 +0100
Subject: [PATCH 036/200] 3.4.0
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index fc6b50d..ecd50c3 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.3.1",
+ "version": "3.4.0",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 59f148c4be248fc43bdc45516bfb3790bf956bb5 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 14:11:25 +0100
Subject: [PATCH 037/200] All decorated components inherit styles property that
describes the CSS module and CSS class relation.
---
README.md | 37 +++++++++++++++
dist/extendReactClass.js | 14 ++++++
dist/linkClass.js | 1 +
dist/wrapStatelessFunction.js | 26 ++++++++--
src/extendReactClass.js | 10 ++++
src/wrapStatelessFunction.js | 20 ++++++--
test/extendReactClass.js | 89 +++++++++++++++++++++++++++++++++++
test/wrapStatelessFunction.js | 54 +++++++++++++++++++++
8 files changed, 245 insertions(+), 6 deletions(-)
create mode 100644 test/extendReactClass.js
create mode 100644 test/wrapStatelessFunction.js
diff --git a/README.md b/README.md
index 6d77ca7..1d739a5 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [webpack](#webpack)
- [Browserify](#browserify)
- [Extending Component Styles](#extending-component-styles)
+ - [Inheriting the Styles Object Through Properties](#inheriting-the-styles-object-through-properties)
- [Decorator](#decorator)
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
@@ -218,6 +219,42 @@ In this example, `table-custom-styles.css` selectively extends `table.css` (the
Refer to the [`UsingStylesProperty` example](https://github.com/gajus/react-css-modules-examples/tree/master/src/UsingStylesProperty) for an example of a working implementation.
+### Inheriting the Styles Object Through Properties
+
+`styleNames` cannot be used within a component to define styles of a `ReactElement` that will be generated by another component, e.g.
+
+```js
+class extends React.Component {
+ render () {
+ let itemTemplate;
+
+ itemTemplate = (name) => {
+ return {name} ;
+ };
+
+ return
;
+ }
+}
+```
+
+The original [issue](https://github.com/gajus/react-css-modules/issues/11) describing the use case.
+
+For that purpose, the decorated class inherits `styles` property that you can use just as a regular CSS Modules object. The earlier example can be therefore rewritten to:
+
+```js
+class extends React.Component {
+ render () {
+ let itemTemplate;
+
+ itemTemplate = (name) => {
+ return {name} ;
+ };
+
+ return
;
+ }
+}
+```
+
### Decorator
```js
diff --git a/dist/extendReactClass.js b/dist/extendReactClass.js
index ca8d448..1ab13f4 100644
--- a/dist/extendReactClass.js
+++ b/dist/extendReactClass.js
@@ -4,6 +4,10 @@ var _lodashLangIsObject2 = require('lodash/lang/isObject');
var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
+var _lodashObjectAssign2 = require('lodash/object/assign');
+
+var _lodashObjectAssign3 = _interopRequireDefault(_lodashObjectAssign2);
+
Object.defineProperty(exports, '__esModule', {
value: true
});
@@ -28,6 +32,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
var extendReactClass = undefined;
+/**
+ * @param {ReactClass} Component
+ * @param {Object} defaultStyles
+ * @param {Object} options
+ * @returns {ReactClass}
+ */
extendReactClass = function (Component, defaultStyles, options) {
return (function (_Component) {
_inherits(_class, _Component);
@@ -47,6 +57,10 @@ extendReactClass = function (Component, defaultStyles, options) {
if (this.props.styles) {
styles = this.props.styles;
} else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
+ this.props = (0, _lodashObjectAssign3['default'])({}, this.props, {
+ styles: defaultStyles
+ });
+
styles = defaultStyles;
} else {
styles = {};
diff --git a/dist/linkClass.js b/dist/linkClass.js
index 0778123..7391f96 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -40,6 +40,7 @@ linkClass = function (element, styles, userConfiguration) {
newProps = undefined,
styleNames = undefined;
+ // @see https://github.com/gajus/react-css-modules/pull/30
if (!element) {
return element;
}
diff --git a/dist/wrapStatelessFunction.js b/dist/wrapStatelessFunction.js
index a763d6d..7a9229b 100644
--- a/dist/wrapStatelessFunction.js
+++ b/dist/wrapStatelessFunction.js
@@ -4,6 +4,10 @@ var _lodashLangIsObject2 = require('lodash/lang/isObject');
var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
+var _lodashObjectAssign2 = require('lodash/object/assign');
+
+var _lodashObjectAssign3 = _interopRequireDefault(_lodashObjectAssign2);
+
Object.defineProperty(exports, '__esModule', {
value: true
});
@@ -20,24 +24,40 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
var wrapStatelessFunction = undefined;
+/**
+ * @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components
+ * @param {function} Component
+ * @param {Object} defaultStyles
+ * @param {Object} options
+ * @returns {function}
+ */
wrapStatelessFunction = function (Component, defaultStyles, options) {
- return function (props) {
+ return function () {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
+ var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
+
var renderResult = undefined,
- styles = undefined;
+ styles = undefined,
+ useProps = undefined;
if (props.styles) {
+ useProps = props;
styles = props.styles;
} else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
+ useProps = (0, _lodashObjectAssign3['default'])({}, props, {
+ styles: defaultStyles
+ });
+
styles = defaultStyles;
} else {
+ useProps = props;
styles = {};
}
- renderResult = Component.apply(undefined, [props].concat(args));
+ renderResult = Component.apply(undefined, [useProps].concat(args));
if (renderResult) {
return (0, _linkClass2['default'])(renderResult, styles, options);
diff --git a/src/extendReactClass.js b/src/extendReactClass.js
index a4017bc..4ff5114 100644
--- a/src/extendReactClass.js
+++ b/src/extendReactClass.js
@@ -4,6 +4,12 @@ import _ from 'lodash';
let extendReactClass;
+/**
+ * @param {ReactClass} Component
+ * @param {Object} defaultStyles
+ * @param {Object} options
+ * @returns {ReactClass}
+ */
extendReactClass = (Component, defaultStyles, options) => {
return class extends Component {
render () {
@@ -13,6 +19,10 @@ extendReactClass = (Component, defaultStyles, options) => {
if (this.props.styles) {
styles = this.props.styles;
} else if (_.isObject(defaultStyles)) {
+ this.props = _.assign({}, this.props, {
+ styles: defaultStyles
+ });
+
styles = defaultStyles;
} else {
styles = {};
diff --git a/src/wrapStatelessFunction.js b/src/wrapStatelessFunction.js
index d75b2e1..4860ddf 100644
--- a/src/wrapStatelessFunction.js
+++ b/src/wrapStatelessFunction.js
@@ -4,20 +4,34 @@ import _ from 'lodash';
let wrapStatelessFunction;
+/**
+ * @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components
+ * @param {function} Component
+ * @param {Object} defaultStyles
+ * @param {Object} options
+ * @returns {function}
+ */
wrapStatelessFunction = (Component, defaultStyles, options) => {
- return (props, ...args) => {
+ return (props = {}, ...args) => {
let renderResult,
- styles;
+ styles,
+ useProps;
if (props.styles) {
+ useProps = props;
styles = props.styles;
} else if (_.isObject(defaultStyles)) {
+ useProps = _.assign({}, props, {
+ styles: defaultStyles
+ });
+
styles = defaultStyles;
} else {
+ useProps = props;
styles = {};
}
- renderResult = Component(props, ...args);
+ renderResult = Component(useProps, ...args);
if (renderResult) {
return linkClass(renderResult, styles, options);
diff --git a/test/extendReactClass.js b/test/extendReactClass.js
new file mode 100644
index 0000000..2b32174
--- /dev/null
+++ b/test/extendReactClass.js
@@ -0,0 +1,89 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import jsdom from 'jsdom';
+import extendReactClass from './../src/extendReactClass';
+
+describe('extendReactClass', () => {
+ beforeEach(() => {
+ global.document = jsdom.jsdom(`
+
+
+
+
+
+
+
+ `);
+
+ global.window = document.defaultView;
+ });
+
+ context('using default styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let Component,
+ styles;
+
+ Component = class extends React.Component {
+ render () {
+ expect(this.props.styles).to.equal(styles);
+ done();
+ }
+ };
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = extendReactClass(Component, styles);
+
+ TestUtils.renderIntoDocument( );
+ });
+ it('does not affect the other instance properties', (done) => {
+ let Component,
+ styles;
+
+ Component = class extends React.Component {
+ render () {
+ expect(this.props.bar).to.equal('baz');
+ done();
+ }
+ };
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = extendReactClass(Component, styles);
+
+ TestUtils.renderIntoDocument( );
+ });
+ });
+
+ context('using explicit styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let Component,
+ styles;
+
+ Component = class extends React.Component {
+ render () {
+ expect(this.props.styles).to.equal(styles);
+ done();
+ }
+ };
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = extendReactClass(Component);
+
+ TestUtils.renderIntoDocument( );
+ });
+ });
+});
diff --git a/test/wrapStatelessFunction.js b/test/wrapStatelessFunction.js
new file mode 100644
index 0000000..8ff58d1
--- /dev/null
+++ b/test/wrapStatelessFunction.js
@@ -0,0 +1,54 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import wrapStatelessFunction from './../src/wrapStatelessFunction';
+
+describe('wrapStatelessFunction', () => {
+ context('using default styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ wrapStatelessFunction((props) => {
+ expect(props.styles).to.equal(styles);
+ done();
+ }, styles)();
+ });
+ it('does not affect the other instance properties', (done) => {
+ let styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ wrapStatelessFunction((props) => {
+ expect(props.bar).to.equal('baz');
+ done();
+ }, styles)({
+ bar: 'baz'
+ });
+ });
+ });
+ context('using explicit styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ wrapStatelessFunction((props) => {
+ expect(props.styles).to.equal(styles);
+ done();
+ })({
+ styles
+ });
+ });
+ });
+});
From 300ba1faba0c24cb89748d099f836f98f07460ab Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 14:21:38 +0100
Subject: [PATCH 038/200] `styles` property works with ES6 classes and
stateless function components.
---
README.md | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 1d739a5..362e693 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [webpack](#webpack)
- [Browserify](#browserify)
- [Extending Component Styles](#extending-component-styles)
- - [Inheriting the Styles Object Through Properties](#inheriting-the-styles-object-through-properties)
+ - [Styles Property](#styles-property)
- [Decorator](#decorator)
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
@@ -219,9 +219,13 @@ In this example, `table-custom-styles.css` selectively extends `table.css` (the
Refer to the [`UsingStylesProperty` example](https://github.com/gajus/react-css-modules-examples/tree/master/src/UsingStylesProperty) for an example of a working implementation.
-### Inheriting the Styles Object Through Properties
+### Styles Property
-`styleNames` cannot be used within a component to define styles of a `ReactElement` that will be generated by another component, e.g.
+Decorated components inherit `styles` property that describes the mapping between CSS modules and CSS classes.
+
+`styles` property within the component itself is designed to be used only when `styleNames` cannot be used.
+
+`styleNames` cannot be used within a component to define styles of a `ReactElement` that will be generated by another component (https://github.com/gajus/react-css-modules/issues/11), e.g.
```js
class extends React.Component {
@@ -237,9 +241,7 @@ class extends React.Component {
}
```
-The original [issue](https://github.com/gajus/react-css-modules/issues/11) describing the use case.
-
-For that purpose, the decorated class inherits `styles` property that you can use just as a regular CSS Modules object. The earlier example can be therefore rewritten to:
+For that purpose, the decorated component inherits `styles` property that you can use just as a regular CSS Modules object. The earlier example can be therefore rewritten to:
```js
class extends React.Component {
@@ -255,6 +257,8 @@ class extends React.Component {
}
```
+`styles` property works with ES6 classes and stateless function components.
+
### Decorator
```js
From c6aaeb2d61a82255f9dfa16e9e3a6f8368d3abb4 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 2 Oct 2015 14:22:36 +0100
Subject: [PATCH 039/200] 3.5.0
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index ecd50c3..cc956fe 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.4.0",
+ "version": "3.5.0",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From ed3b28c25d2a0b07dde5fe9de69d1ea4691909de Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Sun, 4 Oct 2015 13:28:38 +0100
Subject: [PATCH 040/200] A smarter way of determining of class is a
React.Component. https://github.com/gajus/react-css-modules/pull/41
---
src/index.js | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/index.js b/src/index.js
index 491e1de..993e79a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -2,7 +2,18 @@ import extendReactClass from './extendReactClass';
import wrapStatelessFunction from './wrapStatelessFunction';
let decoratorConstructor,
- functionConstructor;
+ functionConstructor,
+ isReactComponent;
+
+/**
+ * Determines if the given object has the signature of a class that inherits React.Component.
+ *
+ * @param {*} Component
+ * @return {Boolean}
+ */
+isReactComponent = (Component) => {
+ return 'prototype' in Component && typeof Component.prototype.render === 'function';
+};
/**
* When used as a function.
@@ -15,9 +26,11 @@ let decoratorConstructor,
functionConstructor = (Component, defaultStyles, options) => {
let decoratedClass;
- decoratedClass = Component.isReactClass ?
- extendReactClass(Component, defaultStyles, options) :
- wrapStatelessFunction(Component, defaultStyles, options);
+ if (isReactComponent(Component)) {
+ decoratedClass = extendReactClass(Component, defaultStyles, options);
+ } else {
+ decoratedClass = wrapStatelessFunction(Component, defaultStyles, options);
+ }
if (Component.displayName) {
decoratedClass.displayName = Component.displayName;
From 5983b7715758e2d1385ec3cb69b2d0e2c3f3a2e6 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Sun, 4 Oct 2015 13:28:43 +0100
Subject: [PATCH 041/200] 3.5.1
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index cc956fe..333f2b0 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.5.0",
+ "version": "3.5.1",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 460b969f6f2e35d8619fcbb777d64eef907464ca Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Tue, 6 Oct 2015 12:45:57 +0100
Subject: [PATCH 042/200] Latest release did not include build.
---
dist/index.js | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/dist/index.js b/dist/index.js
index a77cac7..573cdfe 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -15,7 +15,18 @@ var _wrapStatelessFunction = require('./wrapStatelessFunction');
var _wrapStatelessFunction2 = _interopRequireDefault(_wrapStatelessFunction);
var decoratorConstructor = undefined,
- functionConstructor = undefined;
+ functionConstructor = undefined,
+ isReactComponent = undefined;
+
+/**
+ * Determines if the given object has the signature of a class that inherits React.Component.
+ *
+ * @param {*} Component
+ * @return {Boolean}
+ */
+isReactComponent = function (Component) {
+ return 'prototype' in Component && typeof Component.prototype.render === 'function';
+};
/**
* When used as a function.
@@ -28,7 +39,11 @@ var decoratorConstructor = undefined,
functionConstructor = function (Component, defaultStyles, options) {
var decoratedClass = undefined;
- decoratedClass = Component.isReactClass ? (0, _extendReactClass2['default'])(Component, defaultStyles, options) : (0, _wrapStatelessFunction2['default'])(Component, defaultStyles, options);
+ if (isReactComponent(Component)) {
+ decoratedClass = (0, _extendReactClass2['default'])(Component, defaultStyles, options);
+ } else {
+ decoratedClass = (0, _wrapStatelessFunction2['default'])(Component, defaultStyles, options);
+ }
if (Component.displayName) {
decoratedClass.displayName = Component.displayName;
From 1fadab5102a61f0da24e70f3a5645811c395ebb2 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Tue, 6 Oct 2015 12:46:15 +0100
Subject: [PATCH 043/200] 3.5.2
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 333f2b0..959b089 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.5.1",
+ "version": "3.5.2",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From c84d5abd492ccdcfc6643bd86ad6358d432bbd42 Mon Sep 17 00:00:00 2001
From: Luke Westby
Date: Tue, 13 Oct 2015 09:57:19 -0500
Subject: [PATCH 044/200] hoist static properties of stateless functions
---
src/wrapStatelessFunction.js | 8 +++++++-
test/wrapStatelessFunction.js | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/wrapStatelessFunction.js b/src/wrapStatelessFunction.js
index 4860ddf..312238a 100644
--- a/src/wrapStatelessFunction.js
+++ b/src/wrapStatelessFunction.js
@@ -12,7 +12,9 @@ let wrapStatelessFunction;
* @returns {function}
*/
wrapStatelessFunction = (Component, defaultStyles, options) => {
- return (props = {}, ...args) => {
+ let WrappedComponent;
+
+ WrappedComponent = (props = {}, ...args) => {
let renderResult,
styles,
useProps;
@@ -39,6 +41,10 @@ wrapStatelessFunction = (Component, defaultStyles, options) => {
return React.createElement('noscript');
};
+
+ _.assign(WrappedComponent, Component);
+
+ return WrappedComponent;
};
export default wrapStatelessFunction;
diff --git a/test/wrapStatelessFunction.js b/test/wrapStatelessFunction.js
index 8ff58d1..9b0225d 100644
--- a/test/wrapStatelessFunction.js
+++ b/test/wrapStatelessFunction.js
@@ -7,6 +7,23 @@ import {
import wrapStatelessFunction from './../src/wrapStatelessFunction';
describe('wrapStatelessFunction', () => {
+ it('hoists static own properties from the input component to the wrapped component', () => {
+ let Component, WrappedComponent, styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = function InnerComponent () { return null; };
+ Component.propTypes = {};
+ Component.defaultProps = {};
+
+ WrappedComponent = wrapStatelessFunction(Component, styles);
+
+ expect(WrappedComponent.propTypes).to.equal(Component.propTypes);
+ expect(WrappedComponent.defaultProps).to.equal(Component.defaultProps);
+ expect(WrappedComponent.name).not.to.equal(Component.name);
+ });
context('using default styles', () => {
it('exposes styles through styles property', (done) => {
let styles;
From 0b222e6ef44ee8aefbc12d4efd2a0c823a0a1dd9 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Tue, 13 Oct 2015 16:56:05 +0100
Subject: [PATCH 045/200] https://github.com/gajus/react-css-modules/issues/46
---
dist/wrapStatelessFunction.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dist/wrapStatelessFunction.js b/dist/wrapStatelessFunction.js
index 7a9229b..7ede40c 100644
--- a/dist/wrapStatelessFunction.js
+++ b/dist/wrapStatelessFunction.js
@@ -32,7 +32,9 @@ var wrapStatelessFunction = undefined;
* @returns {function}
*/
wrapStatelessFunction = function (Component, defaultStyles, options) {
- return function () {
+ var WrappedComponent = undefined;
+
+ WrappedComponent = function () {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
@@ -65,6 +67,10 @@ wrapStatelessFunction = function (Component, defaultStyles, options) {
return _react2['default'].createElement('noscript');
};
+
+ (0, _lodashObjectAssign3['default'])(WrappedComponent, Component);
+
+ return WrappedComponent;
};
exports['default'] = wrapStatelessFunction;
From bf08aef3389e27146ba488eef402dfe792afaeaa Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Tue, 13 Oct 2015 16:56:10 +0100
Subject: [PATCH 046/200] 3.6.0
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 959b089..3d9f824 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.5.2",
+ "version": "3.6.0",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From 31ec1b44d0bf43b069375d0e3b089558905c99d7 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Mon, 26 Oct 2015 17:49:17 +0000
Subject: [PATCH 047/200] ./test/ is renamed to ./tests/
---
tests/extendReactClass.js | 89 ++++++++++++
tests/linkClass.js | 239 +++++++++++++++++++++++++++++++++
tests/makeConfiguration.js | 45 +++++++
tests/mocha.opts | 1 +
tests/reactCssModules.js | 133 ++++++++++++++++++
tests/wrapStatelessFunction.js | 71 ++++++++++
6 files changed, 578 insertions(+)
create mode 100644 tests/extendReactClass.js
create mode 100644 tests/linkClass.js
create mode 100644 tests/makeConfiguration.js
create mode 100644 tests/mocha.opts
create mode 100644 tests/reactCssModules.js
create mode 100644 tests/wrapStatelessFunction.js
diff --git a/tests/extendReactClass.js b/tests/extendReactClass.js
new file mode 100644
index 0000000..2b32174
--- /dev/null
+++ b/tests/extendReactClass.js
@@ -0,0 +1,89 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import jsdom from 'jsdom';
+import extendReactClass from './../src/extendReactClass';
+
+describe('extendReactClass', () => {
+ beforeEach(() => {
+ global.document = jsdom.jsdom(`
+
+
+
+
+
+
+
+ `);
+
+ global.window = document.defaultView;
+ });
+
+ context('using default styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let Component,
+ styles;
+
+ Component = class extends React.Component {
+ render () {
+ expect(this.props.styles).to.equal(styles);
+ done();
+ }
+ };
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = extendReactClass(Component, styles);
+
+ TestUtils.renderIntoDocument( );
+ });
+ it('does not affect the other instance properties', (done) => {
+ let Component,
+ styles;
+
+ Component = class extends React.Component {
+ render () {
+ expect(this.props.bar).to.equal('baz');
+ done();
+ }
+ };
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = extendReactClass(Component, styles);
+
+ TestUtils.renderIntoDocument( );
+ });
+ });
+
+ context('using explicit styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let Component,
+ styles;
+
+ Component = class extends React.Component {
+ render () {
+ expect(this.props.styles).to.equal(styles);
+ done();
+ }
+ };
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = extendReactClass(Component);
+
+ TestUtils.renderIntoDocument( );
+ });
+ });
+});
diff --git a/tests/linkClass.js b/tests/linkClass.js
new file mode 100644
index 0000000..83cbf67
--- /dev/null
+++ b/tests/linkClass.js
@@ -0,0 +1,239 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import jsdom from 'jsdom';
+import linkClass from './../src/linkClass';
+
+describe('linkClass', () => {
+ context('ReactElement does not define styleName', () => {
+ it('does not affect element properties', () => {
+ expect(linkClass(
)).to.deep.equal(
);
+ });
+
+ it('does not affect element properties with a single element child', () => {
+ expect(linkClass()).to.deep.equal();
+ });
+
+ it('does not affect element properties with a single text child', () => {
+ expect(linkClass(test
)).to.deep.equal(test
);
+ });
+
+ it('does not affect the className', () => {
+ expect(linkClass(
)).to.deep.equal(
);
+ });
+
+ xit('does not affect element with a single children when that children is contained in an array', () => {
+ let outcome,
+ subject;
+
+ subject = React.createElement('div', null, [
+ React.createElement('p')
+ ]);
+ outcome = React.createElement('div', null, [
+ React.createElement('p')
+ ]);
+
+ expect(linkClass(subject)).to.deep.equal(outcome);
+ });
+
+ xit('does not affect element with multiple children', () => {
+ // Using array instead of object causes the following error:
+ // Warning: Each child in an array or iterator should have a unique "key" prop.
+ // Check the render method of _class. See https://fb.me/react-warning-keys for more information.
+ // @see https://github.com/facebook/react/issues/4723#issuecomment-135555277
+ // expect(linkClass()).to.deep.equal();
+
+ let outcome,
+ subject;
+
+ subject = React.createElement('div', null, [
+ React.createElement('p'),
+ React.createElement('p')
+ ]);
+ outcome = React.createElement('div', null, [
+ React.createElement('p'),
+ React.createElement('p')
+ ]);
+
+ expect(linkClass(subject)).to.deep.equal(outcome);
+ });
+ });
+
+ context('called with null instead of ReactElement', () => {
+ it('returns null', () => {
+ let subject;
+
+ subject = linkClass(null);
+
+ expect(subject).to.equal(null);
+ });
+ });
+
+ context('styleName matches an existing CSS module', () => {
+ context('when a descendant element has styleName', () => {
+ it('assigns a generated className', () => {
+ let subject;
+
+ subject = ;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1'
+ });
+
+ expect(subject.props.children.props.className).to.equal('foo-1');
+ });
+ });
+ context('when multiple descendant elements have styleName', () => {
+ it('assigns a generated className', () => {
+ let subject;
+
+ subject = ;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1',
+ bar: 'bar-1'
+ });
+
+ expect(subject.props.children[0].props.className).to.equal('foo-1');
+ expect(subject.props.children[1].props.className).to.equal('bar-1');
+ });
+ });
+ context('when ReactElement does not have an existing className', () => {
+ it('uses the generated class name to set the className property', () => {
+ let subject;
+
+ subject =
;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1'
+ });
+
+ expect(subject.props.className).to.deep.equal('foo-1');
+ });
+ });
+ context('when ReactElement has an existing className', () => {
+ it('appends the generated class name to the className property', () => {
+ let subject;
+
+ subject =
;
+
+ subject = linkClass(subject, {
+ bar: 'bar-1'
+ });
+
+ expect(subject.props.className).to.deep.equal('foo bar-1');
+ });
+ });
+ });
+
+ context('styleName includes multiple whitespace characters', () => {
+ it('resolves CSS modules', () => {
+ let subject;
+
+ subject = ;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1',
+ bar: 'bar-1'
+ }, {
+ allowMultiple: true
+ });
+
+ expect(subject.props.children.props.className).to.equal('foo-1 bar-1');
+ });
+ });
+
+ describe('options.allowMultiple', () => {
+ context('when multiple module names are used', () => {
+ context('when false', () => {
+ it('throws an error', () => {
+ expect(() => {
+ linkClass(
, {}, {allowMultiple: false});
+ }).to.throw(Error, 'ReactElement styleName property defines multiple module names ("foo bar").');
+ });
+ });
+ context('when true', () => {
+ it('appends a generated class name for every referenced CSS module', () => {
+ let subject;
+
+ subject =
;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1',
+ bar: 'bar-1'
+ }, {allowMultiple: true});
+
+ expect(subject.props.className).to.deep.equal('foo-1 bar-1');
+ });
+ });
+ });
+ });
+
+ describe('options.errorWhenNotFound', () => {
+ context('when styleName does not match an existing CSS module', () => {
+ context('when false', () => {
+ it('ignores the missing CSS module', () => {
+ let subject;
+
+ subject =
;
+
+ subject = linkClass(subject, {}, {errorWhenNotFound: false});
+
+ expect(subject.props.className).to.be.an('undefined');
+ });
+ });
+ context('when is true', () => {
+ it('throws an error', () => {
+ expect(() => {
+ linkClass(
, {}, {errorWhenNotFound: true});
+ }).to.throw(Error, '"foo" CSS module is undefined.');
+ });
+ });
+ });
+ });
+
+ context('when ReactElement includes ReactComponent', () => {
+ let Foo,
+ nodeList;
+
+ beforeEach(() => {
+ global.document = jsdom.jsdom(`
+
+
+
+
+
+
+
+ `);
+
+ global.window = document.defaultView;
+
+ Foo = class extends React.Component {
+ render () {
+ return Hello
;
+ }
+ };
+
+ nodeList = TestUtils.renderIntoDocument(linkClass(
, {foo: 'foo-1'}));
+ });
+ it('processes ReactElement nodes', () => {
+ expect(nodeList.className).to.equal('foo-1');
+ });
+ it('does not process ReactComponent nodes', () => {
+ expect(nodeList.firstChild.className).to.equal('');
+ });
+ });
+});
diff --git a/tests/makeConfiguration.js b/tests/makeConfiguration.js
new file mode 100644
index 0000000..3a74ae7
--- /dev/null
+++ b/tests/makeConfiguration.js
@@ -0,0 +1,45 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import makeConfiguration from './../src/makeConfiguration';
+
+describe('makeConfiguration', () => {
+ describe('when using default configuration', () => {
+ let configuration;
+
+ beforeEach(() => {
+ configuration = makeConfiguration();
+ });
+ describe('allowMultiple property', () => {
+ it('defaults to false', () => {
+ expect(configuration.allowMultiple).to.equal(false);
+ });
+ });
+ describe('errorWhenNotFound property', () => {
+ it('defaults to true', () => {
+ expect(configuration.errorWhenNotFound).to.equal(true);
+ });
+ });
+ });
+ describe('when unknown property is provided', () => {
+ it('throws an error', () => {
+ expect(() => {
+ makeConfiguration({
+ unknownProperty: true
+ });
+ }).to.throw(Error, 'Unknown configuration property "unknownProperty".');
+ });
+ });
+ it('does not mutate user configuration', () => {
+ let userConfiguration;
+
+ userConfiguration = {};
+
+ makeConfiguration(userConfiguration);
+
+ expect(userConfiguration).to.deep.equal({});
+ });
+});
diff --git a/tests/mocha.opts b/tests/mocha.opts
new file mode 100644
index 0000000..13374d0
--- /dev/null
+++ b/tests/mocha.opts
@@ -0,0 +1 @@
+--compilers js:babel/register
diff --git a/tests/reactCssModules.js b/tests/reactCssModules.js
new file mode 100644
index 0000000..685988f
--- /dev/null
+++ b/tests/reactCssModules.js
@@ -0,0 +1,133 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import reactCssModules from './../src/index';
+
+describe('reactCssModules', () => {
+ context('a ReactComponent is decorated using react-css-modules', () => {
+ it('inherits displayName', () => {
+ let Foo;
+
+ Foo = class extends React.Component {
+ static displayName = 'Bar';
+ };
+
+ Foo = reactCssModules(Foo);
+
+ expect(Foo.displayName).to.equal('Bar');
+ });
+ context('target component does not name displayName', () => {
+ it('uses name for displayName', () => {
+ let Foo;
+
+ Foo = class Bar extends React.Component {};
+
+ Foo = reactCssModules(Foo);
+
+ expect(Foo.displayName).to.equal('Bar');
+ });
+ });
+ });
+ context('a ReactComponent renders an element with the styleName prop', () => {
+ context('the component is a class that extends React.Component', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = class extends React.Component {
+ render () {
+ return Hello
;
+ }
+ };
+
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
+
+ expect(component.props.className).to.equal('foo-1');
+ });
+ });
+ context('the component is a stateless function component', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = () => Hello
;
+
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
+
+ expect(component.props.className).to.equal('foo-1');
+ });
+ });
+ });
+
+ context('a ReactComponent renders nothing', () => {
+ context('the component is a class that extends React.Component', () => {
+ it('linkClass must not intervene', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = class extends React.Component {
+ render () {
+ return null;
+ }
+ };
+
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
+
+ expect(typeof component).to.equal('object');
+ });
+ });
+ context('the component is a stateless function component', () => {
+ it('that element should contain the equivalent className', () => {
+ let Foo,
+ component,
+ shallowRenderer;
+
+ shallowRenderer = TestUtils.createRenderer();
+
+ Foo = () => null;
+
+ Foo = reactCssModules(Foo, {
+ foo: 'foo-1'
+ });
+
+ shallowRenderer.render( );
+
+ component = shallowRenderer.getRenderOutput();
+
+ expect(typeof component).to.equal('object');
+ });
+ });
+ });
+});
diff --git a/tests/wrapStatelessFunction.js b/tests/wrapStatelessFunction.js
new file mode 100644
index 0000000..9b0225d
--- /dev/null
+++ b/tests/wrapStatelessFunction.js
@@ -0,0 +1,71 @@
+/* eslint-disable max-nested-callbacks */
+
+import {
+ expect
+} from 'chai';
+
+import wrapStatelessFunction from './../src/wrapStatelessFunction';
+
+describe('wrapStatelessFunction', () => {
+ it('hoists static own properties from the input component to the wrapped component', () => {
+ let Component, WrappedComponent, styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ Component = function InnerComponent () { return null; };
+ Component.propTypes = {};
+ Component.defaultProps = {};
+
+ WrappedComponent = wrapStatelessFunction(Component, styles);
+
+ expect(WrappedComponent.propTypes).to.equal(Component.propTypes);
+ expect(WrappedComponent.defaultProps).to.equal(Component.defaultProps);
+ expect(WrappedComponent.name).not.to.equal(Component.name);
+ });
+ context('using default styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ wrapStatelessFunction((props) => {
+ expect(props.styles).to.equal(styles);
+ done();
+ }, styles)();
+ });
+ it('does not affect the other instance properties', (done) => {
+ let styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ wrapStatelessFunction((props) => {
+ expect(props.bar).to.equal('baz');
+ done();
+ }, styles)({
+ bar: 'baz'
+ });
+ });
+ });
+ context('using explicit styles', () => {
+ it('exposes styles through styles property', (done) => {
+ let styles;
+
+ styles = {
+ foo: 'foo-1'
+ };
+
+ wrapStatelessFunction((props) => {
+ expect(props.styles).to.equal(styles);
+ done();
+ })({
+ styles
+ });
+ });
+ });
+});
From a62673369aeefcfe966cd1899202dd7e0bb16569 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Mon, 26 Oct 2015 17:49:26 +0000
Subject: [PATCH 048/200] ./test/ is renamed to ./tests/
---
test/extendReactClass.js | 89 -------------
test/linkClass.js | 239 ----------------------------------
test/makeConfiguration.js | 45 -------
test/mocha.opts | 1 -
test/reactCssModules.js | 133 -------------------
test/wrapStatelessFunction.js | 71 ----------
6 files changed, 578 deletions(-)
delete mode 100644 test/extendReactClass.js
delete mode 100644 test/linkClass.js
delete mode 100644 test/makeConfiguration.js
delete mode 100644 test/mocha.opts
delete mode 100644 test/reactCssModules.js
delete mode 100644 test/wrapStatelessFunction.js
diff --git a/test/extendReactClass.js b/test/extendReactClass.js
deleted file mode 100644
index 2b32174..0000000
--- a/test/extendReactClass.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/* eslint-disable max-nested-callbacks */
-
-import {
- expect
-} from 'chai';
-
-import React from 'react';
-import TestUtils from 'react-addons-test-utils';
-import jsdom from 'jsdom';
-import extendReactClass from './../src/extendReactClass';
-
-describe('extendReactClass', () => {
- beforeEach(() => {
- global.document = jsdom.jsdom(`
-
-
-
-
-
-
-
- `);
-
- global.window = document.defaultView;
- });
-
- context('using default styles', () => {
- it('exposes styles through styles property', (done) => {
- let Component,
- styles;
-
- Component = class extends React.Component {
- render () {
- expect(this.props.styles).to.equal(styles);
- done();
- }
- };
-
- styles = {
- foo: 'foo-1'
- };
-
- Component = extendReactClass(Component, styles);
-
- TestUtils.renderIntoDocument( );
- });
- it('does not affect the other instance properties', (done) => {
- let Component,
- styles;
-
- Component = class extends React.Component {
- render () {
- expect(this.props.bar).to.equal('baz');
- done();
- }
- };
-
- styles = {
- foo: 'foo-1'
- };
-
- Component = extendReactClass(Component, styles);
-
- TestUtils.renderIntoDocument( );
- });
- });
-
- context('using explicit styles', () => {
- it('exposes styles through styles property', (done) => {
- let Component,
- styles;
-
- Component = class extends React.Component {
- render () {
- expect(this.props.styles).to.equal(styles);
- done();
- }
- };
-
- styles = {
- foo: 'foo-1'
- };
-
- Component = extendReactClass(Component);
-
- TestUtils.renderIntoDocument( );
- });
- });
-});
diff --git a/test/linkClass.js b/test/linkClass.js
deleted file mode 100644
index 83cbf67..0000000
--- a/test/linkClass.js
+++ /dev/null
@@ -1,239 +0,0 @@
-/* eslint-disable max-nested-callbacks */
-
-import {
- expect
-} from 'chai';
-
-import React from 'react';
-import TestUtils from 'react-addons-test-utils';
-import jsdom from 'jsdom';
-import linkClass from './../src/linkClass';
-
-describe('linkClass', () => {
- context('ReactElement does not define styleName', () => {
- it('does not affect element properties', () => {
- expect(linkClass(
)).to.deep.equal(
);
- });
-
- it('does not affect element properties with a single element child', () => {
- expect(linkClass()).to.deep.equal();
- });
-
- it('does not affect element properties with a single text child', () => {
- expect(linkClass(test
)).to.deep.equal(test
);
- });
-
- it('does not affect the className', () => {
- expect(linkClass(
)).to.deep.equal(
);
- });
-
- xit('does not affect element with a single children when that children is contained in an array', () => {
- let outcome,
- subject;
-
- subject = React.createElement('div', null, [
- React.createElement('p')
- ]);
- outcome = React.createElement('div', null, [
- React.createElement('p')
- ]);
-
- expect(linkClass(subject)).to.deep.equal(outcome);
- });
-
- xit('does not affect element with multiple children', () => {
- // Using array instead of object causes the following error:
- // Warning: Each child in an array or iterator should have a unique "key" prop.
- // Check the render method of _class. See https://fb.me/react-warning-keys for more information.
- // @see https://github.com/facebook/react/issues/4723#issuecomment-135555277
- // expect(linkClass()).to.deep.equal();
-
- let outcome,
- subject;
-
- subject = React.createElement('div', null, [
- React.createElement('p'),
- React.createElement('p')
- ]);
- outcome = React.createElement('div', null, [
- React.createElement('p'),
- React.createElement('p')
- ]);
-
- expect(linkClass(subject)).to.deep.equal(outcome);
- });
- });
-
- context('called with null instead of ReactElement', () => {
- it('returns null', () => {
- let subject;
-
- subject = linkClass(null);
-
- expect(subject).to.equal(null);
- });
- });
-
- context('styleName matches an existing CSS module', () => {
- context('when a descendant element has styleName', () => {
- it('assigns a generated className', () => {
- let subject;
-
- subject = ;
-
- subject = linkClass(subject, {
- foo: 'foo-1'
- });
-
- expect(subject.props.children.props.className).to.equal('foo-1');
- });
- });
- context('when multiple descendant elements have styleName', () => {
- it('assigns a generated className', () => {
- let subject;
-
- subject = ;
-
- subject = linkClass(subject, {
- foo: 'foo-1',
- bar: 'bar-1'
- });
-
- expect(subject.props.children[0].props.className).to.equal('foo-1');
- expect(subject.props.children[1].props.className).to.equal('bar-1');
- });
- });
- context('when ReactElement does not have an existing className', () => {
- it('uses the generated class name to set the className property', () => {
- let subject;
-
- subject =
;
-
- subject = linkClass(subject, {
- foo: 'foo-1'
- });
-
- expect(subject.props.className).to.deep.equal('foo-1');
- });
- });
- context('when ReactElement has an existing className', () => {
- it('appends the generated class name to the className property', () => {
- let subject;
-
- subject =
;
-
- subject = linkClass(subject, {
- bar: 'bar-1'
- });
-
- expect(subject.props.className).to.deep.equal('foo bar-1');
- });
- });
- });
-
- context('styleName includes multiple whitespace characters', () => {
- it('resolves CSS modules', () => {
- let subject;
-
- subject = ;
-
- subject = linkClass(subject, {
- foo: 'foo-1',
- bar: 'bar-1'
- }, {
- allowMultiple: true
- });
-
- expect(subject.props.children.props.className).to.equal('foo-1 bar-1');
- });
- });
-
- describe('options.allowMultiple', () => {
- context('when multiple module names are used', () => {
- context('when false', () => {
- it('throws an error', () => {
- expect(() => {
- linkClass(
, {}, {allowMultiple: false});
- }).to.throw(Error, 'ReactElement styleName property defines multiple module names ("foo bar").');
- });
- });
- context('when true', () => {
- it('appends a generated class name for every referenced CSS module', () => {
- let subject;
-
- subject =
;
-
- subject = linkClass(subject, {
- foo: 'foo-1',
- bar: 'bar-1'
- }, {allowMultiple: true});
-
- expect(subject.props.className).to.deep.equal('foo-1 bar-1');
- });
- });
- });
- });
-
- describe('options.errorWhenNotFound', () => {
- context('when styleName does not match an existing CSS module', () => {
- context('when false', () => {
- it('ignores the missing CSS module', () => {
- let subject;
-
- subject =
;
-
- subject = linkClass(subject, {}, {errorWhenNotFound: false});
-
- expect(subject.props.className).to.be.an('undefined');
- });
- });
- context('when is true', () => {
- it('throws an error', () => {
- expect(() => {
- linkClass(
, {}, {errorWhenNotFound: true});
- }).to.throw(Error, '"foo" CSS module is undefined.');
- });
- });
- });
- });
-
- context('when ReactElement includes ReactComponent', () => {
- let Foo,
- nodeList;
-
- beforeEach(() => {
- global.document = jsdom.jsdom(`
-
-
-
-
-
-
-
- `);
-
- global.window = document.defaultView;
-
- Foo = class extends React.Component {
- render () {
- return Hello
;
- }
- };
-
- nodeList = TestUtils.renderIntoDocument(linkClass(
, {foo: 'foo-1'}));
- });
- it('processes ReactElement nodes', () => {
- expect(nodeList.className).to.equal('foo-1');
- });
- it('does not process ReactComponent nodes', () => {
- expect(nodeList.firstChild.className).to.equal('');
- });
- });
-});
diff --git a/test/makeConfiguration.js b/test/makeConfiguration.js
deleted file mode 100644
index 3a74ae7..0000000
--- a/test/makeConfiguration.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/* eslint-disable max-nested-callbacks */
-
-import {
- expect
-} from 'chai';
-
-import makeConfiguration from './../src/makeConfiguration';
-
-describe('makeConfiguration', () => {
- describe('when using default configuration', () => {
- let configuration;
-
- beforeEach(() => {
- configuration = makeConfiguration();
- });
- describe('allowMultiple property', () => {
- it('defaults to false', () => {
- expect(configuration.allowMultiple).to.equal(false);
- });
- });
- describe('errorWhenNotFound property', () => {
- it('defaults to true', () => {
- expect(configuration.errorWhenNotFound).to.equal(true);
- });
- });
- });
- describe('when unknown property is provided', () => {
- it('throws an error', () => {
- expect(() => {
- makeConfiguration({
- unknownProperty: true
- });
- }).to.throw(Error, 'Unknown configuration property "unknownProperty".');
- });
- });
- it('does not mutate user configuration', () => {
- let userConfiguration;
-
- userConfiguration = {};
-
- makeConfiguration(userConfiguration);
-
- expect(userConfiguration).to.deep.equal({});
- });
-});
diff --git a/test/mocha.opts b/test/mocha.opts
deleted file mode 100644
index 13374d0..0000000
--- a/test/mocha.opts
+++ /dev/null
@@ -1 +0,0 @@
---compilers js:babel/register
diff --git a/test/reactCssModules.js b/test/reactCssModules.js
deleted file mode 100644
index 685988f..0000000
--- a/test/reactCssModules.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/* eslint-disable max-nested-callbacks */
-
-import {
- expect
-} from 'chai';
-
-import React from 'react';
-import TestUtils from 'react-addons-test-utils';
-import reactCssModules from './../src/index';
-
-describe('reactCssModules', () => {
- context('a ReactComponent is decorated using react-css-modules', () => {
- it('inherits displayName', () => {
- let Foo;
-
- Foo = class extends React.Component {
- static displayName = 'Bar';
- };
-
- Foo = reactCssModules(Foo);
-
- expect(Foo.displayName).to.equal('Bar');
- });
- context('target component does not name displayName', () => {
- it('uses name for displayName', () => {
- let Foo;
-
- Foo = class Bar extends React.Component {};
-
- Foo = reactCssModules(Foo);
-
- expect(Foo.displayName).to.equal('Bar');
- });
- });
- });
- context('a ReactComponent renders an element with the styleName prop', () => {
- context('the component is a class that extends React.Component', () => {
- it('that element should contain the equivalent className', () => {
- let Foo,
- component,
- shallowRenderer;
-
- shallowRenderer = TestUtils.createRenderer();
-
- Foo = class extends React.Component {
- render () {
- return Hello
;
- }
- };
-
- Foo = reactCssModules(Foo, {
- foo: 'foo-1'
- });
-
- shallowRenderer.render( );
-
- component = shallowRenderer.getRenderOutput();
-
- expect(component.props.className).to.equal('foo-1');
- });
- });
- context('the component is a stateless function component', () => {
- it('that element should contain the equivalent className', () => {
- let Foo,
- component,
- shallowRenderer;
-
- shallowRenderer = TestUtils.createRenderer();
-
- Foo = () => Hello
;
-
- Foo = reactCssModules(Foo, {
- foo: 'foo-1'
- });
-
- shallowRenderer.render( );
-
- component = shallowRenderer.getRenderOutput();
-
- expect(component.props.className).to.equal('foo-1');
- });
- });
- });
-
- context('a ReactComponent renders nothing', () => {
- context('the component is a class that extends React.Component', () => {
- it('linkClass must not intervene', () => {
- let Foo,
- component,
- shallowRenderer;
-
- shallowRenderer = TestUtils.createRenderer();
-
- Foo = class extends React.Component {
- render () {
- return null;
- }
- };
-
- Foo = reactCssModules(Foo, {
- foo: 'foo-1'
- });
-
- shallowRenderer.render( );
-
- component = shallowRenderer.getRenderOutput();
-
- expect(typeof component).to.equal('object');
- });
- });
- context('the component is a stateless function component', () => {
- it('that element should contain the equivalent className', () => {
- let Foo,
- component,
- shallowRenderer;
-
- shallowRenderer = TestUtils.createRenderer();
-
- Foo = () => null;
-
- Foo = reactCssModules(Foo, {
- foo: 'foo-1'
- });
-
- shallowRenderer.render( );
-
- component = shallowRenderer.getRenderOutput();
-
- expect(typeof component).to.equal('object');
- });
- });
- });
-});
diff --git a/test/wrapStatelessFunction.js b/test/wrapStatelessFunction.js
deleted file mode 100644
index 9b0225d..0000000
--- a/test/wrapStatelessFunction.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/* eslint-disable max-nested-callbacks */
-
-import {
- expect
-} from 'chai';
-
-import wrapStatelessFunction from './../src/wrapStatelessFunction';
-
-describe('wrapStatelessFunction', () => {
- it('hoists static own properties from the input component to the wrapped component', () => {
- let Component, WrappedComponent, styles;
-
- styles = {
- foo: 'foo-1'
- };
-
- Component = function InnerComponent () { return null; };
- Component.propTypes = {};
- Component.defaultProps = {};
-
- WrappedComponent = wrapStatelessFunction(Component, styles);
-
- expect(WrappedComponent.propTypes).to.equal(Component.propTypes);
- expect(WrappedComponent.defaultProps).to.equal(Component.defaultProps);
- expect(WrappedComponent.name).not.to.equal(Component.name);
- });
- context('using default styles', () => {
- it('exposes styles through styles property', (done) => {
- let styles;
-
- styles = {
- foo: 'foo-1'
- };
-
- wrapStatelessFunction((props) => {
- expect(props.styles).to.equal(styles);
- done();
- }, styles)();
- });
- it('does not affect the other instance properties', (done) => {
- let styles;
-
- styles = {
- foo: 'foo-1'
- };
-
- wrapStatelessFunction((props) => {
- expect(props.bar).to.equal('baz');
- done();
- }, styles)({
- bar: 'baz'
- });
- });
- });
- context('using explicit styles', () => {
- it('exposes styles through styles property', (done) => {
- let styles;
-
- styles = {
- foo: 'foo-1'
- };
-
- wrapStatelessFunction((props) => {
- expect(props.styles).to.equal(styles);
- done();
- })({
- styles
- });
- });
- });
-});
From c776940403422947368cc44cfc000647ba90822e Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Mon, 26 Oct 2015 23:56:27 +0000
Subject: [PATCH 049/200] Using pragmatist.
---
.babelrc | 5 +-
.eslintrc | 393 ------------------------------
.gitignore | 6 +-
.npmignore | 7 +
.travis.yml | 7 +-
dist/extendReactClass.js | 5 +-
dist/extendReactClass.js.map | 1 +
dist/index.js | 5 +-
dist/index.js.map | 1 +
dist/linkClass.js | 3 +-
dist/linkClass.js.map | 1 +
dist/makeConfiguration.js | 7 +-
dist/makeConfiguration.js.map | 1 +
dist/utils.js | 26 --
dist/wrapStatelessFunction.js | 7 +-
dist/wrapStatelessFunction.js.map | 1 +
package.json | 26 +-
src/index.js | 2 +-
src/makeConfiguration.js | 4 +-
src/wrapStatelessFunction.js | 4 +-
tests/wrapStatelessFunction.js | 2 +-
21 files changed, 50 insertions(+), 464 deletions(-)
delete mode 100644 .eslintrc
create mode 100755 .npmignore
create mode 100644 dist/extendReactClass.js.map
create mode 100644 dist/index.js.map
create mode 100644 dist/linkClass.js.map
create mode 100644 dist/makeConfiguration.js.map
delete mode 100644 dist/utils.js
create mode 100644 dist/wrapStatelessFunction.js.map
diff --git a/.babelrc b/.babelrc
index 89c0540..12606a3 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,6 +1,3 @@
{
- "stage": 0,
- "plugins": [
- "lodash"
- ]
+ "stage": 0
}
diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644
index a2a446a..0000000
--- a/.eslintrc
+++ /dev/null
@@ -1,393 +0,0 @@
-{
- "rules": {
- "comma-dangle": [
- 2,
- "never"
- ],
- "no-cond-assign": 2,
- "no-console": 1,
- "no-constant-condition": 1,
- "no-control-regex": 2,
- "no-debugger": 1,
- "no-dupe-args": 2,
- "no-dupe-keys": 2,
- "no-duplicate-case": 2,
- "no-empty-character-class": 2,
- "no-empty": 1,
- "no-ex-assign": 2,
- "no-extra-boolean-cast": 0,
- "no-extra-parens": 2,
- "no-extra-semi": 2,
- "no-func-assign": 2,
- "no-inner-declarations": 2,
- "no-invalid-regexp": 2,
- "no-irregular-whitespace": 2,
- "no-negated-in-lhs": 2,
- "no-obj-calls": 2,
- "no-regex-spaces": 2,
- "no-sparse-arrays": 2,
- "no-unreachable": 1,
- "use-isnan": 2,
- "valid-jsdoc": [
- 2,
- {
- "requireParamDescription": false,
- "requireReturnDescription": false
- }
- ],
- "valid-typeof": 2,
- "no-unexpected-multiline": 2,
- "accessor-pairs": 2,
- "block-scoped-var": 2,
- "complexity": [
- 1,
- 10
- ],
- "consistent-return": 2,
- "curly": 2,
- "default-case": 0,
- "dot-notation": 2,
- "dot-location": [
- 2,
- "property"
- ],
- "eqeqeq": 2,
- "guard-for-in": 2,
- "no-alert": 2,
- "no-caller": 2,
- "no-div-regex": 2,
- "no-else-return": 0,
- "no-empty-label": 2,
- "no-eq-null": 2,
- "no-eval": 2,
- "no-extend-native": 2,
- "no-extra-bind": 2,
- "no-fallthrough": 2,
- "no-floating-decimal": 2,
- "no-implicit-coercion": 2,
- "no-implied-eval": 2,
- "no-invalid-this": 0,
- "no-iterator": 2,
- "no-labels": 2,
- "no-lone-blocks": 2,
- "no-loop-func": 2,
- "no-multi-spaces": 2,
- "no-multi-str": 2,
- "no-native-reassign": 2,
- "no-new-func": 2,
- "no-new-wrappers": 2,
- "no-new": 2,
- "no-octal-escape": 2,
- "no-octal": 2,
- "no-param-reassign": [
- 2,
- {
- "props": false
- }
- ],
- "no-process-env": 2,
- "no-proto": 2,
- "no-redeclare": [
- 2,
- {
- "builtinGlobals": true
- }
- ],
- "no-return-assign": 2,
- "no-script-url": 2,
- "no-self-compare": 2,
- "no-sequences": 2,
- "no-throw-literal": 2,
- "no-unused-expressions": 2,
- "no-useless-call": 2,
- "no-void": 2,
- "no-warning-comments": [
- 1,
- {
- "terms": [
- "todo",
- "@toto"
- ],
- "location": "start"
- }
- ],
- "no-with": 2,
- "radix": 2,
- "vars-on-top": 2,
- "wrap-iife": [
- 2,
- "inside"
- ],
- "yoda": 0,
- "strict": [
- 2,
- "never"
- ],
- "init-declarations": [
- 2,
- "never"
- ],
- "no-catch-shadow": 2,
- "no-delete-var": 2,
- "no-label-var": 2,
- "no-shadow-restricted-names": 2,
- "no-shadow": [
- 2,
- {
- "builtinGlobals": false,
- "hoist": "functions"
- }
- ],
- "no-undef-init": 2,
- "no-undef": 2,
- "no-undefined": 2,
- "no-unused-vars": 2,
- "no-use-before-define": 2,
- "callback-return": 2,
- "handle-callback-err": 2,
- "no-mixed-requires": 0,
- "no-new-require": 2,
- "no-path-concat": 2,
- "no-process-exit": 2,
- "no-sync": 0,
- "array-bracket-spacing": [
- 2,
- "never"
- ],
- "block-spacing": [
- 2,
- "always"
- ],
- "brace-style": [
- 2,
- "1tbs",
- {
- "allowSingleLine": true
- }
- ],
- "camelcase": [
- 2,
- {
- "properties": "always"
- }
- ],
- "comma-spacing": [
- 2,
- {
- "before": false,
- "after": true
- }
- ],
- "comma-style": [
- 2,
- "last"
- ],
- "computed-property-spacing": [
- 2,
- "never"
- ],
- "consistent-this": [
- 2,
- "self"
- ],
- "eol-last": 2,
- "func-names": 0,
- "func-style": [
- 2,
- "expression"
- ],
- "id-length": [
- 2,
- {
- "min": 2,
- "max": 30,
- "exceptions": [
- "_"
- ]
- }
- ],
- "id-match": [
- 2,
- "(^[A-Za-z]+(?:[A-Z][a-z]*)*\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\d$)*$)|(^(_|\\$)$)",
- {
- "properties": true
- }
- ],
- "indent": [
- 2,
- 4
- ],
- "key-spacing": [
- 2,
- {
- "beforeColon": false,
- "afterColon": true
- }
- ],
- "lines-around-comment": [
- 2,
- {
- "beforeBlockComment": true,
- "beforeLineComment": false
- }
- ],
- "linebreak-style": [
- 2,
- "unix"
- ],
- "max-nested-callbacks": [
- 1,
- 3
- ],
- "new-cap": [
- 2,
- {
- "newIsCap": true,
- "capIsNew": false
- }
- ],
- "new-parens": 2,
- "newline-after-var": [
- 2,
- "always"
- ],
- "no-array-constructor": 2,
- "no-continue": 2,
- "no-inline-comments": 2,
- "no-lonely-if": 0,
- "no-mixed-spaces-and-tabs": 2,
- "no-multiple-empty-lines": [
- 2,
- {
- "max": 2
- }
- ],
- "no-nested-ternary": 2,
- "no-new-object": 2,
- "no-spaced-func": 2,
- "no-ternary": 0,
- "no-trailing-spaces": 2,
- "no-underscore-dangle": 2,
- "no-unneeded-ternary": 2,
- "object-curly-spacing": [
- 2,
- "never"
- ],
- "one-var": [
- 2,
- "always"
- ],
- "operator-assignment": [
- 2,
- "always"
- ],
- "operator-linebreak": [
- 2,
- "after"
- ],
- "padded-blocks": [
- 2,
- "never"
- ],
- "quote-props": [
- 2,
- "as-needed"
- ],
- "quotes": [
- 2,
- "single"
- ],
- "semi-spacing": [
- 2,
- {
- "before": false,
- "after": true
- }
- ],
- "semi": [
- 2,
- "always"
- ],
- "sort-vars": 2,
- "space-after-keywords": [
- 2,
- "always"
- ],
- "space-before-blocks": [
- 2,
- "always"
- ],
- "space-before-function-paren": [
- 2,
- "always"
- ],
- "space-in-parens": [
- 2,
- "never"
- ],
- "space-infix-ops": 2,
- "space-return-throw-case": 2,
- "space-unary-ops": [
- 2,
- {
- "words": true,
- "nonwords": false
- }
- ],
- "spaced-comment": [
- 2,
- "always"
- ],
- "wrap-regex": 0,
- "arrow-parens": [
- 2,
- "always"
- ],
- "arrow-spacing": [
- 2,
- {
- "before": true,
- "after": true
- }
- ],
- "constructor-super": 2,
- "generator-star-spacing": [
- 2,
- {
- "before": true,
- "after": false
- }
- ],
- "no-class-assign": 2,
- "no-const-assign": 2,
- "no-dupe-class-members": 2,
- "no-this-before-super": 2,
- "no-var": 2,
- "object-shorthand": [
- 2,
- "always"
- ],
- "prefer-arrow-callback": 2,
- "prefer-const": 0,
- "prefer-spread": 2,
- "prefer-reflect": 2,
- "prefer-template": 2,
- "require-yield": 2
- },
- "ecmaFeatures": {
- "jsx": true,
- "modules": true
- },
- "plugins": [
- "react"
- ],
- "parser": "babel-eslint",
- "globals": {
- "global": true
- },
- "env": {
- "browser": true,
- "mocha": true
- // "node": true
- }
-}
diff --git a/.gitignore b/.gitignore
index e0b6b81..fa88f70 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-/node_modules
-/coverage
-npm-debug.log
+node_modules
+coverage
.coveralls.yml
+*.log
diff --git a/.npmignore b/.npmignore
new file mode 100755
index 0000000..4f341b3
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,7 @@
+src
+tests
+coverage
+.coveralls.yml
+.travis.yml
+.eslintrc
+*.log
diff --git a/.travis.yml b/.travis.yml
index 3ed46a2..e0fced4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,7 @@
language: node_js
node_js:
- - 'iojs-v3.0.0'
- - 'iojs-v2.5.0'
-install:
- - npm install
+ - '4.1'
+ - '4.0'
notifications:
email: false
+sudo: false
diff --git a/dist/extendReactClass.js b/dist/extendReactClass.js
index 1ab13f4..bec936c 100644
--- a/dist/extendReactClass.js
+++ b/dist/extendReactClass.js
@@ -14,7 +14,7 @@ Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
-var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
+var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
@@ -81,4 +81,5 @@ extendReactClass = function (Component, defaultStyles, options) {
};
exports['default'] = extendReactClass;
-module.exports = exports['default'];
\ No newline at end of file
+module.exports = exports['default'];
+//# sourceMappingURL=extendReactClass.js.map
diff --git a/dist/extendReactClass.js.map b/dist/extendReactClass.js.map
new file mode 100644
index 0000000..63c37a9
--- /dev/null
+++ b/dist/extendReactClass.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["extendReactClass.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;yBAAsB,aAAa;;;;qBACjB,OAAO;;;;;;AAGzB,IAAI,gBAAgB,YAAA,CAAC;;;;;;;;AAQrB,gBAAgB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AACtD;;;;;;;;;;;mBACW,kBAAG;AACN,oBAAI,YAAY,YAAA;oBACZ,MAAM,YAAA,CAAC;;AAEX,oBAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;AACnB,0BAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;iBAC9B,MAAM,IAAI,qCAAW,aAAa,CAAC,EAAE;AAClC,wBAAI,CAAC,KAAK,GAAG,qCAAS,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE;AAClC,8BAAM,EAAE,aAAa;qBACxB,CAAC,CAAC;;AAEH,0BAAM,GAAG,aAAa,CAAC;iBAC1B,MAAM;AACH,0BAAM,GAAG,EAAE,CAAC;iBACf;;AAED,4BAAY,2EAAiB,CAAC;;AAE9B,oBAAI,YAAY,EAAE;AACd,2BAAO,4BAAU,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;iBACnD;;AAED,uBAAO,mBAAM,aAAa,CAAC,UAAU,CAAC,CAAC;aAC1C;;;;OAxBgB,SAAS,EAyB5B;CACL,CAAC;;qBAEa,gBAAgB","file":"extendReactClass.js","sourcesContent":["import linkClass from './linkClass';\nimport React from 'react';\nimport _ from 'lodash';\n\nlet extendReactClass;\n\n/**\n * @param {ReactClass} Component\n * @param {Object} defaultStyles\n * @param {Object} options\n * @returns {ReactClass}\n */\nextendReactClass = (Component, defaultStyles, options) => {\n return class extends Component {\n render () {\n let renderResult,\n styles;\n\n if (this.props.styles) {\n styles = this.props.styles;\n } else if (_.isObject(defaultStyles)) {\n this.props = _.assign({}, this.props, {\n styles: defaultStyles\n });\n\n styles = defaultStyles;\n } else {\n styles = {};\n }\n\n renderResult = super.render();\n\n if (renderResult) {\n return linkClass(renderResult, styles, options);\n }\n\n return React.createElement('noscript');\n }\n };\n};\n\nexport default extendReactClass;\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
index 573cdfe..ef6b8b4 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -22,7 +22,7 @@ var decoratorConstructor = undefined,
* Determines if the given object has the signature of a class that inherits React.Component.
*
* @param {*} Component
- * @return {Boolean}
+ * @return {boolean}
*/
isReactComponent = function (Component) {
return 'prototype' in Component && typeof Component.prototype.render === 'function';
@@ -75,4 +75,5 @@ exports['default'] = function () {
}
};
-module.exports = exports['default'];
\ No newline at end of file
+module.exports = exports['default'];
+//# sourceMappingURL=index.js.map
diff --git a/dist/index.js.map b/dist/index.js.map
new file mode 100644
index 0000000..161c75a
--- /dev/null
+++ b/dist/index.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;gCAA6B,oBAAoB;;;;qCACf,yBAAyB;;;;AAE3D,IAAI,oBAAoB,YAAA;IACpB,mBAAmB,YAAA;IACnB,gBAAgB,YAAA,CAAC;;;;;;;;AAQrB,gBAAgB,GAAG,UAAC,SAAS,EAAK;AAC9B,WAAO,WAAW,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,KAAK,UAAU,CAAC;CACvF,CAAC;;;;;;;;;;AAUF,mBAAmB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AACzD,QAAI,cAAc,YAAA,CAAC;;AAEnB,QAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;AAC7B,sBAAc,GAAG,mCAAiB,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACxE,MAAM;AACH,sBAAc,GAAG,wCAAsB,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KAC7E;;AAED,QAAI,SAAS,CAAC,WAAW,EAAE;AACvB,sBAAc,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;KACtD,MAAM;AACH,sBAAc,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;KAC/C;;AAED,WAAO,cAAc,CAAC;CACzB,CAAC;;;;;;;;;AASF,oBAAoB,GAAG,UAAC,aAAa,EAAE,OAAO,EAAK;AAC/C,WAAO,UAAC,SAAS,EAAK;AAClB,eAAO,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACjE,CAAC;CACL,CAAC;;qBAEa,YAAa;AACxB,QAAI,OAAO,UAAK,CAAC,CAAC,KAAK,UAAU,EAAE;AAC/B,eAAO,mBAAmB,CAAC,UAAK,CAAC,CAAC,EAAE,UAAK,CAAC,CAAC,EAAE,UAAK,CAAC,CAAC,CAAC,CAAC;KACzD,MAAM;AACH,eAAO,oBAAoB,CAAC,UAAK,CAAC,CAAC,EAAE,UAAK,CAAC,CAAC,CAAC,CAAC;KACjD;CACJ","file":"index.js","sourcesContent":["import extendReactClass from './extendReactClass';\nimport wrapStatelessFunction from './wrapStatelessFunction';\n\nlet decoratorConstructor,\n functionConstructor,\n isReactComponent;\n\n/**\n * Determines if the given object has the signature of a class that inherits React.Component.\n *\n * @param {*} Component\n * @return {boolean}\n */\nisReactComponent = (Component) => {\n return 'prototype' in Component && typeof Component.prototype.render === 'function';\n};\n\n/**\n * When used as a function.\n *\n * @param {Function} Component\n * @param {Object} defaultStyles CSS Modules class map.\n * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}\n * @return {Function}\n */\nfunctionConstructor = (Component, defaultStyles, options) => {\n let decoratedClass;\n\n if (isReactComponent(Component)) {\n decoratedClass = extendReactClass(Component, defaultStyles, options);\n } else {\n decoratedClass = wrapStatelessFunction(Component, defaultStyles, options);\n }\n\n if (Component.displayName) {\n decoratedClass.displayName = Component.displayName;\n } else {\n decoratedClass.displayName = Component.name;\n }\n\n return decoratedClass;\n};\n\n/**\n * When used as a ES7 decorator.\n *\n * @param {Object} defaultStyles CSS Modules class map.\n * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}\n * @return {Function}\n */\ndecoratorConstructor = (defaultStyles, options) => {\n return (Component) => {\n return functionConstructor(Component, defaultStyles, options);\n };\n};\n\nexport default (...args) => {\n if (typeof args[0] === 'function') {\n return functionConstructor(args[0], args[1], args[2]);\n } else {\n return decoratorConstructor(args[0], args[1]);\n }\n};\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/linkClass.js b/dist/linkClass.js
index 7391f96..7b48e71 100644
--- a/dist/linkClass.js
+++ b/dist/linkClass.js
@@ -121,4 +121,5 @@ linkClass = function (element, styles, userConfiguration) {
};
exports['default'] = linkClass;
-module.exports = exports['default'];
\ No newline at end of file
+module.exports = exports['default'];
+//# sourceMappingURL=linkClass.js.map
diff --git a/dist/linkClass.js.map b/dist/linkClass.js.map
new file mode 100644
index 0000000..3367091
--- /dev/null
+++ b/dist/linkClass.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["linkClass.js"],"names":[],"mappings":";;;;;;;;;;;;;;qBAAkB,OAAO;;;;iCACK,qBAAqB;;;;;;AAGnD,IAAI,SAAS,YAAA,CAAC;;;;;;;;AAQd,SAAS,GAAG,UAAC,OAAO,EAAE,MAAM,EAAO,iBAAiB,EAAK;QAAnC,MAAM,gBAAN,MAAM,GAAG,EAAE;;AAC7B,QAAI,eAAe,YAAA;QACf,aAAa,YAAA;QACb,aAAa,YAAA;QACb,WAAW,YAAA;QACX,QAAQ,YAAA;QACR,UAAU,YAAA,CAAC;;;AAGf,QAAI,CAAC,OAAO,EAAE;AACV,eAAO,OAAO,CAAC;KAClB;;AAED,iBAAa,GAAG,oCAAkB,iBAAiB,CAAC,CAAC;;AAErD,cAAU,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;;AAErC,QAAI,UAAU,EAAE;AACZ,kBAAU,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnC,kBAAU,GAAG,yCAAS,UAAU,CAAC,CAAC;;AAElC,YAAI,aAAa,CAAC,aAAa,KAAK,KAAK,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;AAChE,kBAAM,IAAI,KAAK,sEAAoE,OAAO,CAAC,KAAK,CAAC,SAAS,SAAM,CAAC;SACpH;;AAED,uBAAe,GAAG,UAAU,CAAC,GAAG,CAAC,UAAC,SAAS,EAAK;AAC5C,gBAAI,MAAM,CAAC,SAAS,CAAC,EAAE;AACnB,uBAAO,MAAM,CAAC,SAAS,CAAC,CAAC;aAC5B,MAAM;AACH,oBAAI,aAAa,CAAC,iBAAiB,KAAK,IAAI,EAAE;AAC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AAG,mBAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KACzD;;AAED,WAAO,aAAa,CAAC;CACxB,CAAC;;qBAEa,SAAS","file":"linkClass.js","sourcesContent":["import React from 'react';\nimport makeConfiguration from './makeConfiguration';\nimport _ from 'lodash';\n\nlet linkClass;\n\n/**\n * @param {ReactElement} element\n * @param {Object} styles CSS modules class map.\n * @param {CSSModules~Options} userConfiguration\n * @return {ReactElement}\n */\nlinkClass = (element, styles = {}, userConfiguration) => {\n let appendClassName,\n clonedElement,\n configuration,\n newChildren,\n newProps,\n styleNames;\n\n // @see https://github.com/gajus/react-css-modules/pull/30\n if (!element) {\n return element;\n }\n\n configuration = makeConfiguration(userConfiguration);\n\n styleNames = element.props.styleName;\n\n if (styleNames) {\n styleNames = styleNames.split(' ');\n styleNames = _.filter(styleNames);\n\n if (configuration.allowMultiple === false && styleNames.length > 1) {\n throw new Error(`ReactElement styleName property defines multiple module names (\"${element.props.styleName}\").`);\n }\n\n appendClassName = styleNames.map((styleName) => {\n if (styles[styleName]) {\n return styles[styleName];\n } else {\n if (configuration.errorWhenNotFound === true) {\n throw new Error(`\"${styleName}\" CSS module is undefined.`);\n }\n\n return '';\n }\n });\n\n appendClassName = appendClassName.filter((className) => {\n return className.length;\n });\n\n appendClassName = appendClassName.join(' ');\n }\n\n // element.props.children can be one of the following:\n // 'text'\n // ['text']\n // [ReactElement, 'text']\n // ReactElement\n\n // console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));\n\n if (React.isValidElement(element.props.children)) {\n newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);\n } else if (_.isArray(element.props.children)) {\n newChildren = React.Children.map(element.props.children, (node) => {\n if (React.isValidElement(node)) {\n return linkClass(node, styles, configuration);\n } else {\n return node;\n }\n });\n\n // https://github.com/facebook/react/issues/4723#issuecomment-135555277\n // Forcing children into an array produces the following error:\n // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.\n // newChildren = _.values(newChildren);\n }\n\n if (appendClassName) {\n if (element.props.className) {\n appendClassName = `${element.props.className} ${appendClassName}`;\n }\n\n newProps = {\n className: appendClassName\n };\n }\n\n if (newChildren) {\n clonedElement = React.cloneElement(element, newProps, newChildren);\n } else {\n clonedElement = React.cloneElement(element, newProps);\n }\n\n return clonedElement;\n};\n\nexport default linkClass;\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/makeConfiguration.js b/dist/makeConfiguration.js
index b528fa5..178a574 100644
--- a/dist/makeConfiguration.js
+++ b/dist/makeConfiguration.js
@@ -13,8 +13,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
/**
* @typedef CSSModules~Options
* @see {@link https://github.com/gajus/react-css-modules#options}
- * @property {Boolean} allowMultiple
- * @property {Boolean} errorWhenNotFound
+ * @property {boolean} allowMultiple
+ * @property {boolean} errorWhenNotFound
*/
/**
@@ -47,4 +47,5 @@ exports['default'] = function () {
return configuration;
};
-module.exports = exports['default'];
\ No newline at end of file
+module.exports = exports['default'];
+//# sourceMappingURL=makeConfiguration.js.map
diff --git a/dist/makeConfiguration.js.map b/dist/makeConfiguration.js.map
new file mode 100644
index 0000000..dd0546d
--- /dev/null
+++ b/dist/makeConfiguration.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["makeConfiguration.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBAae,YAA4B;QAA3B,iBAAiB,yDAAG,EAAE;;AAClC,QAAI,aAAa,YAAA,CAAC;;AAElB,iBAAa,GAAG;AACZ,qBAAa,EAAE,KAAK;AACpB,yBAAiB,EAAE,IAAI;KAC1B,CAAC;;AAEF,8CAAU,iBAAiB,EAAE,UAAC,KAAK,EAAE,IAAI,EAAK;AAC1C,YAAI,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE;AAC5C,kBAAM,IAAI,KAAK,sCAAoC,IAAI,QAAK,CAAC;SAChE;;AAED,YAAI,OAAO,KAAK,KAAK,SAAS,EAAE;AAC5B,kBAAM,IAAI,KAAK,OAAK,IAAI,yCAAsC,CAAC;SAClE;;AAED,qBAAa,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;KAC/B,CAAC,CAAC;;AAEH,WAAO,aAAa,CAAC;CACxB","file":"makeConfiguration.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * @typedef CSSModules~Options\n * @see {@link https://github.com/gajus/react-css-modules#options}\n * @property {boolean} allowMultiple\n * @property {boolean} errorWhenNotFound\n */\n\n/**\n * @param {CSSModules~Options} userConfiguration\n * @return {CSSModules~Options}\n */\nexport default (userConfiguration = {}) => {\n let configuration;\n\n configuration = {\n allowMultiple: false,\n errorWhenNotFound: true\n };\n\n _.forEach(userConfiguration, (value, name) => {\n if (typeof configuration[name] === 'undefined') {\n throw new Error(`Unknown configuration property \"${name}\".`);\n }\n\n if (typeof value !== 'boolean') {\n throw new Error(`\"${name}\" property value must be a boolean.`);\n }\n\n configuration[name] = value;\n });\n\n return configuration;\n};\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/utils.js b/dist/utils.js
deleted file mode 100644
index 651f52c..0000000
--- a/dist/utils.js
+++ /dev/null
@@ -1,26 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-var _lodashCollectionForEach = require('lodash/collection/forEach');
-
-var _lodashCollectionForEach2 = _interopRequireDefault(_lodashCollectionForEach);
-
-var _lodashObjectValues = require('lodash/object/values');
-
-var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
-
-var _lodashLangIsArray = require('lodash/lang/isArray');
-
-var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
-
-exports['default'] = {
- forEach: _lodashCollectionForEach2['default'],
- values: _lodashObjectValues2['default'],
- isArray: _lodashLangIsArray2['default']
-};
-module.exports = exports['default'];
\ No newline at end of file
diff --git a/dist/wrapStatelessFunction.js b/dist/wrapStatelessFunction.js
index 7ede40c..7723dfa 100644
--- a/dist/wrapStatelessFunction.js
+++ b/dist/wrapStatelessFunction.js
@@ -26,10 +26,10 @@ var wrapStatelessFunction = undefined;
/**
* @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components
- * @param {function} Component
+ * @param {Function} Component
* @param {Object} defaultStyles
* @param {Object} options
- * @returns {function}
+ * @returns {Function}
*/
wrapStatelessFunction = function (Component, defaultStyles, options) {
var WrappedComponent = undefined;
@@ -74,4 +74,5 @@ wrapStatelessFunction = function (Component, defaultStyles, options) {
};
exports['default'] = wrapStatelessFunction;
-module.exports = exports['default'];
\ No newline at end of file
+module.exports = exports['default'];
+//# sourceMappingURL=wrapStatelessFunction.js.map
diff --git a/dist/wrapStatelessFunction.js.map b/dist/wrapStatelessFunction.js.map
new file mode 100644
index 0000000..78ef1e4
--- /dev/null
+++ b/dist/wrapStatelessFunction.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["wrapStatelessFunction.js"],"names":[],"mappings":";;;;;;;;;;;;;;yBAAsB,aAAa;;;;qBACjB,OAAO;;;;;;AAGzB,IAAI,qBAAqB,YAAA,CAAC;;;;;;;;;AAS1B,qBAAqB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AAC3D,QAAI,gBAAgB,YAAA,CAAC;;AAErB,oBAAgB,GAAG,YAAyB;0CAAT,IAAI;AAAJ,gBAAI;;;YAAnB,KAAK,yDAAG,EAAE;;AAC1B,YAAI,YAAY,YAAA;YACZ,MAAM,YAAA;YACN,QAAQ,YAAA,CAAC;;AAEb,YAAI,KAAK,CAAC,MAAM,EAAE;AACd,oBAAQ,GAAG,KAAK,CAAC;AACjB,kBAAM,GAAG,KAAK,CAAC,MAAM,CAAC;SACzB,MAAM,IAAI,qCAAW,aAAa,CAAC,EAAE;AAClC,oBAAQ,GAAG,qCAAS,EAAE,EAAE,KAAK,EAAE;AAC3B,sBAAM,EAAE,aAAa;aACxB,CAAC,CAAC;;AAEH,kBAAM,GAAG,aAAa,CAAC;SAC1B,MAAM;AACH,oBAAQ,GAAG,KAAK,CAAC;AACjB,kBAAM,GAAG,EAAE,CAAC;SACf;;AAED,oBAAY,GAAG,SAAS,mBAAC,QAAQ,SAAK,IAAI,EAAC,CAAC;;AAE5C,YAAI,YAAY,EAAE;AACd,mBAAO,4BAAU,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;SACnD;;AAED,eAAO,mBAAM,aAAa,CAAC,UAAU,CAAC,CAAC;KAC1C,CAAC;;AAEF,yCAAS,gBAAgB,EAAE,SAAS,CAAC,CAAC;;AAEtC,WAAO,gBAAgB,CAAC;CAC3B,CAAC;;qBAEa,qBAAqB","file":"wrapStatelessFunction.js","sourcesContent":["import linkClass from './linkClass';\nimport React from 'react';\nimport _ from 'lodash';\n\nlet wrapStatelessFunction;\n\n/**\n * @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components\n * @param {Function} Component\n * @param {Object} defaultStyles\n * @param {Object} options\n * @returns {Function}\n */\nwrapStatelessFunction = (Component, defaultStyles, options) => {\n let WrappedComponent;\n\n WrappedComponent = (props = {}, ...args) => {\n let renderResult,\n styles,\n useProps;\n\n if (props.styles) {\n useProps = props;\n styles = props.styles;\n } else if (_.isObject(defaultStyles)) {\n useProps = _.assign({}, props, {\n styles: defaultStyles\n });\n\n styles = defaultStyles;\n } else {\n useProps = props;\n styles = {};\n }\n\n renderResult = Component(useProps, ...args);\n\n if (renderResult) {\n return linkClass(renderResult, styles, options);\n }\n\n return React.createElement('noscript');\n };\n\n _.assign(WrappedComponent, Component);\n\n return WrappedComponent;\n};\n\nexport default wrapStatelessFunction;\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/package.json b/package.json
index 3d9f824..73634d3 100644
--- a/package.json
+++ b/package.json
@@ -23,25 +23,17 @@
"lodash": "^3.10.1"
},
"devDependencies": {
- "babel": "^5.8.23",
- "babel-eslint": "^4.1.2",
- "babel-istanbul": "^0.3.20",
- "babel-plugin-lodash": "^0.2.0",
- "chai": "^3.2.0",
+ "chai": "^3.4.0",
"coveralls": "^2.11.4",
- "eslint": "^1.4.3",
- "eslint-plugin-react": "^3.3.2",
- "jsdom": "^6.5.0",
- "mocha": "^2.3.2",
- "mocha-lcov-reporter": "^0.0.2",
- "react": "^0.14.0-rc1",
- "react-addons-test-utils": "^0.14.0-rc1"
+ "jsdom": "^7.0.2",
+ "pragmatist": "^1.1.5",
+ "react": "^0.14.0",
+ "react-addons-test-utils": "^0.14.0"
},
"scripts": {
- "lint": "./node_modules/.bin/eslint ./src/ ./test/",
- "quick-test": "npm run lint && node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha",
- "test": "npm run quick-test && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
- "build": "babel ./src/ --out-dir ./dist/",
- "watch": "babel --watch ./src/ --out-dir ./dist/"
+ "pragmatist": "node ./node_modules/.bin/pragmatist",
+ "lint": "npm run pragmatist lint",
+ "build": "npm run pragmatist build",
+ "test": "npm run pragmatist test && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
}
}
diff --git a/src/index.js b/src/index.js
index 993e79a..9f1ff1e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -9,7 +9,7 @@ let decoratorConstructor,
* Determines if the given object has the signature of a class that inherits React.Component.
*
* @param {*} Component
- * @return {Boolean}
+ * @return {boolean}
*/
isReactComponent = (Component) => {
return 'prototype' in Component && typeof Component.prototype.render === 'function';
diff --git a/src/makeConfiguration.js b/src/makeConfiguration.js
index 6889c75..dae8ca5 100644
--- a/src/makeConfiguration.js
+++ b/src/makeConfiguration.js
@@ -3,8 +3,8 @@ import _ from 'lodash';
/**
* @typedef CSSModules~Options
* @see {@link https://github.com/gajus/react-css-modules#options}
- * @property {Boolean} allowMultiple
- * @property {Boolean} errorWhenNotFound
+ * @property {boolean} allowMultiple
+ * @property {boolean} errorWhenNotFound
*/
/**
diff --git a/src/wrapStatelessFunction.js b/src/wrapStatelessFunction.js
index 312238a..cacf1e4 100644
--- a/src/wrapStatelessFunction.js
+++ b/src/wrapStatelessFunction.js
@@ -6,10 +6,10 @@ let wrapStatelessFunction;
/**
* @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components
- * @param {function} Component
+ * @param {Function} Component
* @param {Object} defaultStyles
* @param {Object} options
- * @returns {function}
+ * @returns {Function}
*/
wrapStatelessFunction = (Component, defaultStyles, options) => {
let WrappedComponent;
diff --git a/tests/wrapStatelessFunction.js b/tests/wrapStatelessFunction.js
index 9b0225d..44d027f 100644
--- a/tests/wrapStatelessFunction.js
+++ b/tests/wrapStatelessFunction.js
@@ -64,7 +64,7 @@ describe('wrapStatelessFunction', () => {
expect(props.styles).to.equal(styles);
done();
})({
- styles
+ styles: styles
});
});
});
From d15d37d685ae3569070267e532846e3280d91be0 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Mon, 26 Oct 2015 23:56:33 +0000
Subject: [PATCH 050/200] 3.6.1
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 73634d3..ca140d3 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.6.0",
+ "version": "3.6.1",
"author": {
"name": "Gajus Kuizinas",
"email": "gk@anuary.com",
From ff2bc9a505ea998eab7ea640cd2cefd337ecc68e Mon Sep 17 00:00:00 2001
From: Bryan Germann
Date: Sat, 14 Nov 2015 17:50:21 -0500
Subject: [PATCH 051/200] Add support for iterable children.
React 0.13 added support for iterable children, making it possible to use
Immutable.js for supplying your react chidlren to a container. This code
commit supports that change.
---
src/isIterable.js | 10 ++++++++++
src/linkClass.js | 12 ++++++++----
tests/linkClass.js | 22 ++++++++++++++++++++++
3 files changed, 40 insertions(+), 4 deletions(-)
create mode 100644 src/isIterable.js
diff --git a/src/isIterable.js b/src/isIterable.js
new file mode 100644
index 0000000..2a5b74c
--- /dev/null
+++ b/src/isIterable.js
@@ -0,0 +1,10 @@
+import { isObject } from 'lodash';
+
+const ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
+const OLD_ITERATOR_SYMBOL = '@@iterator';
+
+export default function isIterable(obj) {
+ return isObject(obj) &&
+ typeof ((ITERATOR_SYMBOL && obj[ITERATOR_SYMBOL])
+ || obj[OLD_ITERATOR_SYMBOL]) === 'function';
+}
diff --git a/src/linkClass.js b/src/linkClass.js
index 1c16a57..58dd47a 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -1,5 +1,6 @@
import React from 'react';
import makeConfiguration from './makeConfiguration';
+import isIterable from './isIterable';
import _ from 'lodash';
let linkClass;
@@ -12,6 +13,7 @@ let linkClass;
*/
linkClass = (element, styles = {}, userConfiguration) => {
let appendClassName,
+ children,
clonedElement,
configuration,
newChildren,
@@ -62,10 +64,12 @@ linkClass = (element, styles = {}, userConfiguration) => {
// console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));
- if (React.isValidElement(element.props.children)) {
- newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
- } else if (_.isArray(element.props.children)) {
- newChildren = React.Children.map(element.props.children, (node) => {
+ children = element.props.children;
+
+ if (React.isValidElement(children)) {
+ newChildren = linkClass(React.Children.only(children), styles, configuration);
+ } else if (_.isArray(children) || isIterable(children)) {
+ newChildren = React.Children.map(children, (node) => {
if (React.isValidElement(node)) {
return linkClass(node, styles, configuration);
} else {
diff --git a/tests/linkClass.js b/tests/linkClass.js
index 83cbf67..e0778a8 100644
--- a/tests/linkClass.js
+++ b/tests/linkClass.js
@@ -108,6 +108,28 @@ describe('linkClass', () => {
expect(subject.props.children[1].props.className).to.equal('bar-1');
});
});
+ context('when multiple descendants have styleName and are iterable', () => {
+ it('assigns a generated className', () => {
+ let subject, iterable;
+
+ iterable = {
+ 0:
,
+ 1:
,
+ length: 2,
+ [Symbol.iterator]: Array.prototype[Symbol.iterator]
+ };
+
+ subject = {iterable}
;
+
+ subject = linkClass(subject, {
+ foo: 'foo-1',
+ bar: 'bar-1'
+ });
+
+ expect(subject.props.children[0].props.className).to.equal('foo-1');
+ expect(subject.props.children[1].props.className).to.equal('bar-1');
+ });
+ });
context('when ReactElement does not have an existing className', () => {
it('uses the generated class name to set the className property', () => {
let subject;
From 21fe57393c0d05892efb8a186b987dbaba413fb6 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 11:02:43 +0000
Subject: [PATCH 052/200] Updated ignore definition.
---
.gitignore | 7 ++++++-
.npmignore | 4 +---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index fa88f70..14e7b61 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,9 @@
node_modules
coverage
-.coveralls.yml
+dist
*.log
+.*
+!.gitignore
+!.npmignore
+!.babelrc
+!.travis.yml
diff --git a/.npmignore b/.npmignore
index 4f341b3..e8add85 100755
--- a/.npmignore
+++ b/.npmignore
@@ -1,7 +1,5 @@
src
tests
coverage
-.coveralls.yml
-.travis.yml
-.eslintrc
+.*
*.log
From 2c24b61ee55edd3f49da8db6e3071be7c6dfad5b Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 11:38:45 +0000
Subject: [PATCH 053/200] Meeting the updated linting requirements.
---
.babelrc | 3 ---
README.md | 1 -
package.json | 21 +++++++++++---------
src/extendReactClass.js | 2 ++
src/index.js | 5 +++--
src/isIterable.js | 35 ++++++++++++++++++++++++++--------
src/linkClass.js | 16 +++++++---------
src/makeConfiguration.js | 8 ++++----
src/wrapStatelessFunction.js | 2 ++
tests/extendReactClass.js | 10 +---------
tests/linkClass.js | 18 +++++------------
tests/mocha.opts | 1 -
tests/reactCssModules.js | 17 +++++++++++------
tests/wrapStatelessFunction.js | 7 +++++--
14 files changed, 79 insertions(+), 67 deletions(-)
delete mode 100644 .babelrc
delete mode 100644 tests/mocha.opts
diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index 12606a3..0000000
--- a/.babelrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "stage": 0
-}
diff --git a/README.md b/README.md
index 362e693..3d3a19b 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,6 @@
[](https://travis-ci.org/gajus/react-css-modules)
[](https://www.npmjs.org/package/react-css-modules)
-[](https://coveralls.io/github/gajus/react-css-modules?branch=master)
diff --git a/package.json b/package.json
index ca140d3..5c519f5 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "react-css-modules",
"description": "Seamless mapping of class names to CSS modules inside of React components.",
- "main": "./dist/index.js",
+ "main": "./dist/",
"repository": {
"type": "git",
"url": "https://github.com/gajus/react-css-modules"
@@ -15,7 +15,7 @@
"version": "3.6.1",
"author": {
"name": "Gajus Kuizinas",
- "email": "gk@anuary.com",
+ "email": "gajus@gajus.com",
"url": "http://gajus.com"
},
"license": "BSD-3-Clause",
@@ -23,17 +23,20 @@
"lodash": "^3.10.1"
},
"devDependencies": {
- "chai": "^3.4.0",
- "coveralls": "^2.11.4",
- "jsdom": "^7.0.2",
- "pragmatist": "^1.1.5",
- "react": "^0.14.0",
- "react-addons-test-utils": "^0.14.0"
+ "chai": "^3.4.1",
+ "jsdom": "^7.1.1",
+ "pragmatist": "^1.9.4",
+ "react": "^0.14.3",
+ "react-addons-test-utils": "^0.14.3"
},
"scripts": {
"pragmatist": "node ./node_modules/.bin/pragmatist",
"lint": "npm run pragmatist lint",
+ "test": "npm run pragmatist test",
"build": "npm run pragmatist build",
- "test": "npm run pragmatist test && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
+ "watch": "npm run pragmatist watch",
+ "watch-lint": "npm run pragmatist watch-lint",
+ "watch-test": "npm run pragmatist watch-test",
+ "watch-build": "npm run pragmatist watch-build"
}
}
diff --git a/src/extendReactClass.js b/src/extendReactClass.js
index 4ff5114..556334d 100644
--- a/src/extendReactClass.js
+++ b/src/extendReactClass.js
@@ -1,3 +1,5 @@
+/* eslint-disable react/prop-types */
+
import linkClass from './linkClass';
import React from 'react';
import _ from 'lodash';
diff --git a/src/index.js b/src/index.js
index 9f1ff1e..9e8c274 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,3 +1,4 @@
+import _ from 'lodash';
import extendReactClass from './extendReactClass';
import wrapStatelessFunction from './wrapStatelessFunction';
@@ -12,7 +13,7 @@ let decoratorConstructor,
* @return {boolean}
*/
isReactComponent = (Component) => {
- return 'prototype' in Component && typeof Component.prototype.render === 'function';
+ return 'prototype' in Component && _.isFunction(Component.prototype.render);
};
/**
@@ -55,7 +56,7 @@ decoratorConstructor = (defaultStyles, options) => {
};
export default (...args) => {
- if (typeof args[0] === 'function') {
+ if (_.isFunction(args[0])) {
return functionConstructor(args[0], args[1], args[2]);
} else {
return decoratorConstructor(args[0], args[1]);
diff --git a/src/isIterable.js b/src/isIterable.js
index 2a5b74c..9e4c449 100644
--- a/src/isIterable.js
+++ b/src/isIterable.js
@@ -1,10 +1,29 @@
-import { isObject } from 'lodash';
+import _ from 'lodash';
-const ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
-const OLD_ITERATOR_SYMBOL = '@@iterator';
+let ITERATOR_SYMBOL,
+ OLD_ITERATOR_SYMBOL;
-export default function isIterable(obj) {
- return isObject(obj) &&
- typeof ((ITERATOR_SYMBOL && obj[ITERATOR_SYMBOL])
- || obj[OLD_ITERATOR_SYMBOL]) === 'function';
-}
+ITERATOR_SYMBOL = _.isFunction(Symbol) && Symbol.iterator;
+OLD_ITERATOR_SYMBOL = '@@iterator';
+
+/**
+ * @see https://github.com/lodash/lodash/issues/1668
+ * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols
+ * @param {Object} target
+ * @returns {boolean}
+ */
+export default (target) => {
+ let iterator;
+
+ if (!_.isObject(target)) {
+ return false;
+ }
+
+ if (ITERATOR_SYMBOL) {
+ iterator = target[ITERATOR_SYMBOL];
+ } else {
+ iterator = target[OLD_ITERATOR_SYMBOL];
+ }
+
+ return _.isFunction(iterator);
+};
diff --git a/src/linkClass.js b/src/linkClass.js
index 58dd47a..ce824e2 100644
--- a/src/linkClass.js
+++ b/src/linkClass.js
@@ -34,24 +34,22 @@ linkClass = (element, styles = {}, userConfiguration) => {
styleNames = _.filter(styleNames);
if (configuration.allowMultiple === false && styleNames.length > 1) {
- throw new Error(`ReactElement styleName property defines multiple module names ("${element.props.styleName}").`);
+ throw new Error('ReactElement styleName property defines multiple module names ("' + element.props.styleName + '").');
}
- appendClassName = styleNames.map((styleName) => {
+ appendClassName = _.map(styleNames, (styleName) => {
if (styles[styleName]) {
return styles[styleName];
} else {
if (configuration.errorWhenNotFound === true) {
- throw new Error(`"${styleName}" CSS module is undefined.`);
+ throw new Error('"' + styleName + '" CSS module is undefined.');
}
return '';
}
});
- appendClassName = appendClassName.filter((className) => {
- return className.length;
- });
+ appendClassName = _.filter(appendClassName, 'length');
appendClassName = appendClassName.join(' ');
}
@@ -62,14 +60,14 @@ linkClass = (element, styles = {}, userConfiguration) => {
// [ReactElement, 'text']
// ReactElement
- // console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));
-
children = element.props.children;
if (React.isValidElement(children)) {
newChildren = linkClass(React.Children.only(children), styles, configuration);
} else if (_.isArray(children) || isIterable(children)) {
+ /* eslint-disable lodash3/prefer-lodash-method */
newChildren = React.Children.map(children, (node) => {
+ /* eslint-enable lodash3/prefer-lodash-method */
if (React.isValidElement(node)) {
return linkClass(node, styles, configuration);
} else {
@@ -85,7 +83,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
if (appendClassName) {
if (element.props.className) {
- appendClassName = `${element.props.className} ${appendClassName}`;
+ appendClassName = element.props.className + ' ' + appendClassName;
}
newProps = {
diff --git a/src/makeConfiguration.js b/src/makeConfiguration.js
index dae8ca5..292e2f1 100644
--- a/src/makeConfiguration.js
+++ b/src/makeConfiguration.js
@@ -20,12 +20,12 @@ export default (userConfiguration = {}) => {
};
_.forEach(userConfiguration, (value, name) => {
- if (typeof configuration[name] === 'undefined') {
- throw new Error(`Unknown configuration property "${name}".`);
+ if (_.isUndefined(configuration[name])) {
+ throw new Error('Unknown configuration property "' + name + '".');
}
- if (typeof value !== 'boolean') {
- throw new Error(`"${name}" property value must be a boolean.`);
+ if (!_.isBoolean(value)) {
+ throw new Error('"' + name + '" property value must be a boolean.');
}
configuration[name] = value;
diff --git a/src/wrapStatelessFunction.js b/src/wrapStatelessFunction.js
index cacf1e4..342d724 100644
--- a/src/wrapStatelessFunction.js
+++ b/src/wrapStatelessFunction.js
@@ -1,3 +1,5 @@
+/* eslint-disable react/prop-types */
+
import linkClass from './linkClass';
import React from 'react';
import _ from 'lodash';
diff --git a/tests/extendReactClass.js b/tests/extendReactClass.js
index 2b32174..7f269dc 100644
--- a/tests/extendReactClass.js
+++ b/tests/extendReactClass.js
@@ -11,15 +11,7 @@ import extendReactClass from './../src/extendReactClass';
describe('extendReactClass', () => {
beforeEach(() => {
- global.document = jsdom.jsdom(`
-
-
-
-
-
-
-
- `);
+ global.document = jsdom.jsdom('');
global.window = document.defaultView;
});
diff --git a/tests/linkClass.js b/tests/linkClass.js
index e0778a8..1aa28f3 100644
--- a/tests/linkClass.js
+++ b/tests/linkClass.js
@@ -110,11 +110,12 @@ describe('linkClass', () => {
});
context('when multiple descendants have styleName and are iterable', () => {
it('assigns a generated className', () => {
- let subject, iterable;
+ let iterable,
+ subject;
iterable = {
- 0:
,
- 1:
,
+ 0:
,
+ 1:
,
length: 2,
[Symbol.iterator]: Array.prototype[Symbol.iterator]
};
@@ -231,16 +232,7 @@ describe('linkClass', () => {
nodeList;
beforeEach(() => {
- global.document = jsdom.jsdom(`
-
-
-
-
-
-
-
- `);
-
+ global.document = jsdom.jsdom('');
global.window = document.defaultView;
Foo = class extends React.Component {
diff --git a/tests/mocha.opts b/tests/mocha.opts
deleted file mode 100644
index 13374d0..0000000
--- a/tests/mocha.opts
+++ /dev/null
@@ -1 +0,0 @@
---compilers js:babel/register
diff --git a/tests/reactCssModules.js b/tests/reactCssModules.js
index 685988f..3e911c8 100644
--- a/tests/reactCssModules.js
+++ b/tests/reactCssModules.js
@@ -1,4 +1,4 @@
-/* eslint-disable max-nested-callbacks */
+/* eslint-disable max-nested-callbacks, react/no-multi-comp */
import {
expect
@@ -13,9 +13,10 @@ describe('reactCssModules', () => {
it('inherits displayName', () => {
let Foo;
- Foo = class extends React.Component {
- static displayName = 'Bar';
- };
+ Foo = class extends React.Component {};
+
+ // @todo https://phabricator.babeljs.io/T2779
+ Foo.displayName = 'Bar';
Foo = reactCssModules(Foo);
@@ -67,7 +68,9 @@ describe('reactCssModules', () => {
shallowRenderer = TestUtils.createRenderer();
- Foo = () => Hello
;
+ Foo = () => {
+ return Hello
;
+ };
Foo = reactCssModules(Foo, {
foo: 'foo-1'
@@ -116,7 +119,9 @@ describe('reactCssModules', () => {
shallowRenderer = TestUtils.createRenderer();
- Foo = () => null;
+ Foo = () => {
+ return null;
+ };
Foo = reactCssModules(Foo, {
foo: 'foo-1'
diff --git a/tests/wrapStatelessFunction.js b/tests/wrapStatelessFunction.js
index 44d027f..f66c43e 100644
--- a/tests/wrapStatelessFunction.js
+++ b/tests/wrapStatelessFunction.js
@@ -14,7 +14,10 @@ describe('wrapStatelessFunction', () => {
foo: 'foo-1'
};
- Component = function InnerComponent () { return null; };
+ Component = function InnerComponent () {
+ return null;
+ };
+
Component.propTypes = {};
Component.defaultProps = {};
@@ -64,7 +67,7 @@ describe('wrapStatelessFunction', () => {
expect(props.styles).to.equal(styles);
done();
})({
- styles: styles
+ styles
});
});
});
From b15ef858242e0e183d74ea31e02890a37d76c976 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 11:38:50 +0000
Subject: [PATCH 054/200] 3.6.2
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 5c519f5..6af34c4 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.6.1",
+ "version": "3.6.2",
"author": {
"name": "Gajus Kuizinas",
"email": "gajus@gajus.com",
From ddb8828e08f2d9376bb724d918fe997c6ae5a5fd Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 11:40:10 +0000
Subject: [PATCH 055/200] Do not include coveralls config.
---
.coveralls.yml | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 .coveralls.yml
diff --git a/.coveralls.yml b/.coveralls.yml
deleted file mode 100644
index 65bf7c7..0000000
--- a/.coveralls.yml
+++ /dev/null
@@ -1 +0,0 @@
-repo_token: bqiXmaOA0xarSUociqxGKJ72bp8SSHlQC
From 6917304d1c7ac4e86898b766fccf8d87dcd30798 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 11:42:36 +0000
Subject: [PATCH 056/200] Icon style.
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 3d3a19b..88a335c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# React CSS Modules
-[](https://travis-ci.org/gajus/react-css-modules)
-[](https://www.npmjs.org/package/react-css-modules)
+[](https://travis-ci.org/gajus/react-css-modules)
+[](https://www.npmjs.org/package/react-css-modules)
From 55bef97d8ac32aa04afc205f86f8a9154bd02b56 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 15:33:50 +0000
Subject: [PATCH 057/200] Do not include ./dist in github.
---
dist/extendReactClass.js | 85 --------------------
dist/extendReactClass.js.map | 1 -
dist/index.js | 79 -------------------
dist/index.js.map | 1 -
dist/linkClass.js | 125 ------------------------------
dist/linkClass.js.map | 1 -
dist/makeConfiguration.js | 51 ------------
dist/makeConfiguration.js.map | 1 -
dist/wrapStatelessFunction.js | 78 -------------------
dist/wrapStatelessFunction.js.map | 1 -
10 files changed, 423 deletions(-)
delete mode 100644 dist/extendReactClass.js
delete mode 100644 dist/extendReactClass.js.map
delete mode 100644 dist/index.js
delete mode 100644 dist/index.js.map
delete mode 100644 dist/linkClass.js
delete mode 100644 dist/linkClass.js.map
delete mode 100644 dist/makeConfiguration.js
delete mode 100644 dist/makeConfiguration.js.map
delete mode 100644 dist/wrapStatelessFunction.js
delete mode 100644 dist/wrapStatelessFunction.js.map
diff --git a/dist/extendReactClass.js b/dist/extendReactClass.js
deleted file mode 100644
index bec936c..0000000
--- a/dist/extendReactClass.js
+++ /dev/null
@@ -1,85 +0,0 @@
-'use strict';
-
-var _lodashLangIsObject2 = require('lodash/lang/isObject');
-
-var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
-
-var _lodashObjectAssign2 = require('lodash/object/assign');
-
-var _lodashObjectAssign3 = _interopRequireDefault(_lodashObjectAssign2);
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
-
-var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-var _linkClass = require('./linkClass');
-
-var _linkClass2 = _interopRequireDefault(_linkClass);
-
-var _react = require('react');
-
-var _react2 = _interopRequireDefault(_react);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-var extendReactClass = undefined;
-
-/**
- * @param {ReactClass} Component
- * @param {Object} defaultStyles
- * @param {Object} options
- * @returns {ReactClass}
- */
-extendReactClass = function (Component, defaultStyles, options) {
- return (function (_Component) {
- _inherits(_class, _Component);
-
- function _class() {
- _classCallCheck(this, _class);
-
- _get(Object.getPrototypeOf(_class.prototype), 'constructor', this).apply(this, arguments);
- }
-
- _createClass(_class, [{
- key: 'render',
- value: function render() {
- var renderResult = undefined,
- styles = undefined;
-
- if (this.props.styles) {
- styles = this.props.styles;
- } else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
- this.props = (0, _lodashObjectAssign3['default'])({}, this.props, {
- styles: defaultStyles
- });
-
- styles = defaultStyles;
- } else {
- styles = {};
- }
-
- renderResult = _get(Object.getPrototypeOf(_class.prototype), 'render', this).call(this);
-
- if (renderResult) {
- return (0, _linkClass2['default'])(renderResult, styles, options);
- }
-
- return _react2['default'].createElement('noscript');
- }
- }]);
-
- return _class;
- })(Component);
-};
-
-exports['default'] = extendReactClass;
-module.exports = exports['default'];
-//# sourceMappingURL=extendReactClass.js.map
diff --git a/dist/extendReactClass.js.map b/dist/extendReactClass.js.map
deleted file mode 100644
index 63c37a9..0000000
--- a/dist/extendReactClass.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["extendReactClass.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;yBAAsB,aAAa;;;;qBACjB,OAAO;;;;;;AAGzB,IAAI,gBAAgB,YAAA,CAAC;;;;;;;;AAQrB,gBAAgB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AACtD;;;;;;;;;;;mBACW,kBAAG;AACN,oBAAI,YAAY,YAAA;oBACZ,MAAM,YAAA,CAAC;;AAEX,oBAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;AACnB,0BAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;iBAC9B,MAAM,IAAI,qCAAW,aAAa,CAAC,EAAE;AAClC,wBAAI,CAAC,KAAK,GAAG,qCAAS,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE;AAClC,8BAAM,EAAE,aAAa;qBACxB,CAAC,CAAC;;AAEH,0BAAM,GAAG,aAAa,CAAC;iBAC1B,MAAM;AACH,0BAAM,GAAG,EAAE,CAAC;iBACf;;AAED,4BAAY,2EAAiB,CAAC;;AAE9B,oBAAI,YAAY,EAAE;AACd,2BAAO,4BAAU,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;iBACnD;;AAED,uBAAO,mBAAM,aAAa,CAAC,UAAU,CAAC,CAAC;aAC1C;;;;OAxBgB,SAAS,EAyB5B;CACL,CAAC;;qBAEa,gBAAgB","file":"extendReactClass.js","sourcesContent":["import linkClass from './linkClass';\nimport React from 'react';\nimport _ from 'lodash';\n\nlet extendReactClass;\n\n/**\n * @param {ReactClass} Component\n * @param {Object} defaultStyles\n * @param {Object} options\n * @returns {ReactClass}\n */\nextendReactClass = (Component, defaultStyles, options) => {\n return class extends Component {\n render () {\n let renderResult,\n styles;\n\n if (this.props.styles) {\n styles = this.props.styles;\n } else if (_.isObject(defaultStyles)) {\n this.props = _.assign({}, this.props, {\n styles: defaultStyles\n });\n\n styles = defaultStyles;\n } else {\n styles = {};\n }\n\n renderResult = super.render();\n\n if (renderResult) {\n return linkClass(renderResult, styles, options);\n }\n\n return React.createElement('noscript');\n }\n };\n};\n\nexport default extendReactClass;\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
deleted file mode 100644
index ef6b8b4..0000000
--- a/dist/index.js
+++ /dev/null
@@ -1,79 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-var _extendReactClass = require('./extendReactClass');
-
-var _extendReactClass2 = _interopRequireDefault(_extendReactClass);
-
-var _wrapStatelessFunction = require('./wrapStatelessFunction');
-
-var _wrapStatelessFunction2 = _interopRequireDefault(_wrapStatelessFunction);
-
-var decoratorConstructor = undefined,
- functionConstructor = undefined,
- isReactComponent = undefined;
-
-/**
- * Determines if the given object has the signature of a class that inherits React.Component.
- *
- * @param {*} Component
- * @return {boolean}
- */
-isReactComponent = function (Component) {
- return 'prototype' in Component && typeof Component.prototype.render === 'function';
-};
-
-/**
- * When used as a function.
- *
- * @param {Function} Component
- * @param {Object} defaultStyles CSS Modules class map.
- * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
- * @return {Function}
- */
-functionConstructor = function (Component, defaultStyles, options) {
- var decoratedClass = undefined;
-
- if (isReactComponent(Component)) {
- decoratedClass = (0, _extendReactClass2['default'])(Component, defaultStyles, options);
- } else {
- decoratedClass = (0, _wrapStatelessFunction2['default'])(Component, defaultStyles, options);
- }
-
- if (Component.displayName) {
- decoratedClass.displayName = Component.displayName;
- } else {
- decoratedClass.displayName = Component.name;
- }
-
- return decoratedClass;
-};
-
-/**
- * When used as a ES7 decorator.
- *
- * @param {Object} defaultStyles CSS Modules class map.
- * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}
- * @return {Function}
- */
-decoratorConstructor = function (defaultStyles, options) {
- return function (Component) {
- return functionConstructor(Component, defaultStyles, options);
- };
-};
-
-exports['default'] = function () {
- if (typeof arguments[0] === 'function') {
- return functionConstructor(arguments[0], arguments[1], arguments[2]);
- } else {
- return decoratorConstructor(arguments[0], arguments[1]);
- }
-};
-
-module.exports = exports['default'];
-//# sourceMappingURL=index.js.map
diff --git a/dist/index.js.map b/dist/index.js.map
deleted file mode 100644
index 161c75a..0000000
--- a/dist/index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;gCAA6B,oBAAoB;;;;qCACf,yBAAyB;;;;AAE3D,IAAI,oBAAoB,YAAA;IACpB,mBAAmB,YAAA;IACnB,gBAAgB,YAAA,CAAC;;;;;;;;AAQrB,gBAAgB,GAAG,UAAC,SAAS,EAAK;AAC9B,WAAO,WAAW,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,KAAK,UAAU,CAAC;CACvF,CAAC;;;;;;;;;;AAUF,mBAAmB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AACzD,QAAI,cAAc,YAAA,CAAC;;AAEnB,QAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;AAC7B,sBAAc,GAAG,mCAAiB,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACxE,MAAM;AACH,sBAAc,GAAG,wCAAsB,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KAC7E;;AAED,QAAI,SAAS,CAAC,WAAW,EAAE;AACvB,sBAAc,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;KACtD,MAAM;AACH,sBAAc,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;KAC/C;;AAED,WAAO,cAAc,CAAC;CACzB,CAAC;;;;;;;;;AASF,oBAAoB,GAAG,UAAC,aAAa,EAAE,OAAO,EAAK;AAC/C,WAAO,UAAC,SAAS,EAAK;AAClB,eAAO,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACjE,CAAC;CACL,CAAC;;qBAEa,YAAa;AACxB,QAAI,OAAO,UAAK,CAAC,CAAC,KAAK,UAAU,EAAE;AAC/B,eAAO,mBAAmB,CAAC,UAAK,CAAC,CAAC,EAAE,UAAK,CAAC,CAAC,EAAE,UAAK,CAAC,CAAC,CAAC,CAAC;KACzD,MAAM;AACH,eAAO,oBAAoB,CAAC,UAAK,CAAC,CAAC,EAAE,UAAK,CAAC,CAAC,CAAC,CAAC;KACjD;CACJ","file":"index.js","sourcesContent":["import extendReactClass from './extendReactClass';\nimport wrapStatelessFunction from './wrapStatelessFunction';\n\nlet decoratorConstructor,\n functionConstructor,\n isReactComponent;\n\n/**\n * Determines if the given object has the signature of a class that inherits React.Component.\n *\n * @param {*} Component\n * @return {boolean}\n */\nisReactComponent = (Component) => {\n return 'prototype' in Component && typeof Component.prototype.render === 'function';\n};\n\n/**\n * When used as a function.\n *\n * @param {Function} Component\n * @param {Object} defaultStyles CSS Modules class map.\n * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}\n * @return {Function}\n */\nfunctionConstructor = (Component, defaultStyles, options) => {\n let decoratedClass;\n\n if (isReactComponent(Component)) {\n decoratedClass = extendReactClass(Component, defaultStyles, options);\n } else {\n decoratedClass = wrapStatelessFunction(Component, defaultStyles, options);\n }\n\n if (Component.displayName) {\n decoratedClass.displayName = Component.displayName;\n } else {\n decoratedClass.displayName = Component.name;\n }\n\n return decoratedClass;\n};\n\n/**\n * When used as a ES7 decorator.\n *\n * @param {Object} defaultStyles CSS Modules class map.\n * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}\n * @return {Function}\n */\ndecoratorConstructor = (defaultStyles, options) => {\n return (Component) => {\n return functionConstructor(Component, defaultStyles, options);\n };\n};\n\nexport default (...args) => {\n if (typeof args[0] === 'function') {\n return functionConstructor(args[0], args[1], args[2]);\n } else {\n return decoratorConstructor(args[0], args[1]);\n }\n};\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/linkClass.js b/dist/linkClass.js
deleted file mode 100644
index 7b48e71..0000000
--- a/dist/linkClass.js
+++ /dev/null
@@ -1,125 +0,0 @@
-'use strict';
-
-var _lodashCollectionFilter2 = require('lodash/collection/filter');
-
-var _lodashCollectionFilter3 = _interopRequireDefault(_lodashCollectionFilter2);
-
-var _lodashLangIsArray2 = require('lodash/lang/isArray');
-
-var _lodashLangIsArray3 = _interopRequireDefault(_lodashLangIsArray2);
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-var _react = require('react');
-
-var _react2 = _interopRequireDefault(_react);
-
-var _makeConfiguration = require('./makeConfiguration');
-
-var _makeConfiguration2 = _interopRequireDefault(_makeConfiguration);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-var linkClass = undefined;
-
-/**
- * @param {ReactElement} element
- * @param {Object} styles CSS modules class map.
- * @param {CSSModules~Options} userConfiguration
- * @return {ReactElement}
- */
-linkClass = function (element, styles, userConfiguration) {
- if (styles === undefined) styles = {};
-
- var appendClassName = undefined,
- clonedElement = undefined,
- configuration = undefined,
- newChildren = undefined,
- newProps = undefined,
- styleNames = undefined;
-
- // @see https://github.com/gajus/react-css-modules/pull/30
- if (!element) {
- return element;
- }
-
- configuration = (0, _makeConfiguration2['default'])(userConfiguration);
-
- styleNames = element.props.styleName;
-
- if (styleNames) {
- styleNames = styleNames.split(' ');
- styleNames = (0, _lodashCollectionFilter3['default'])(styleNames);
-
- if (configuration.allowMultiple === false && styleNames.length > 1) {
- throw new Error('ReactElement styleName property defines multiple module names ("' + element.props.styleName + '").');
- }
-
- appendClassName = styleNames.map(function (styleName) {
- if (styles[styleName]) {
- return styles[styleName];
- } else {
- if (configuration.errorWhenNotFound === true) {
- throw new Error('"' + styleName + '" CSS module is undefined.');
- }
-
- return '';
- }
- });
-
- appendClassName = appendClassName.filter(function (className) {
- return className.length;
- });
-
- appendClassName = appendClassName.join(' ');
- }
-
- // element.props.children can be one of the following:
- // 'text'
- // ['text']
- // [ReactElement, 'text']
- // ReactElement
-
- // console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));
-
- if (_react2['default'].isValidElement(element.props.children)) {
- newChildren = linkClass(_react2['default'].Children.only(element.props.children), styles, configuration);
- } else if ((0, _lodashLangIsArray3['default'])(element.props.children)) {
- newChildren = _react2['default'].Children.map(element.props.children, function (node) {
- if (_react2['default'].isValidElement(node)) {
- return linkClass(node, styles, configuration);
- } else {
- return node;
- }
- });
-
- // https://github.com/facebook/react/issues/4723#issuecomment-135555277
- // Forcing children into an array produces the following error:
- // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.
- // newChildren = _.values(newChildren);
- }
-
- if (appendClassName) {
- if (element.props.className) {
- appendClassName = element.props.className + ' ' + appendClassName;
- }
-
- newProps = {
- className: appendClassName
- };
- }
-
- if (newChildren) {
- clonedElement = _react2['default'].cloneElement(element, newProps, newChildren);
- } else {
- clonedElement = _react2['default'].cloneElement(element, newProps);
- }
-
- return clonedElement;
-};
-
-exports['default'] = linkClass;
-module.exports = exports['default'];
-//# sourceMappingURL=linkClass.js.map
diff --git a/dist/linkClass.js.map b/dist/linkClass.js.map
deleted file mode 100644
index 3367091..0000000
--- a/dist/linkClass.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["linkClass.js"],"names":[],"mappings":";;;;;;;;;;;;;;qBAAkB,OAAO;;;;iCACK,qBAAqB;;;;;;AAGnD,IAAI,SAAS,YAAA,CAAC;;;;;;;;AAQd,SAAS,GAAG,UAAC,OAAO,EAAE,MAAM,EAAO,iBAAiB,EAAK;QAAnC,MAAM,gBAAN,MAAM,GAAG,EAAE;;AAC7B,QAAI,eAAe,YAAA;QACf,aAAa,YAAA;QACb,aAAa,YAAA;QACb,WAAW,YAAA;QACX,QAAQ,YAAA;QACR,UAAU,YAAA,CAAC;;;AAGf,QAAI,CAAC,OAAO,EAAE;AACV,eAAO,OAAO,CAAC;KAClB;;AAED,iBAAa,GAAG,oCAAkB,iBAAiB,CAAC,CAAC;;AAErD,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Q,EAAE,UAAC,IAAI,EAAK;AAC/D,gBAAI,mBAAM,cAAc,CAAC,IAAI,CAAC,EAAE;AAC5B,uBAAO,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;aACjD,MAAM;AACH,uBAAO,IAAI,CAAC;aACf;SACJ,CAAC,CAAC;;;;;;KAMN;;AAED,QAAI,eAAe,EAAE;AACjB,YAAI,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE;AACzB,2BAAe,GAAM,OAAO,CAAC,KAAK,CAAC,SAAS,SAAI,eAAe,AAAE,CAAC;SACrE;;AAED,gBAAQ,GAAG;AACP,qBAAS,EAAE,eAAe;SAC7B,CAAC;KACL;;AAED,QAAI,WAAW,EAAE;AACb,qBAAa,GAAG,mBAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;KACtE,MAAM;AACH,qBAAa,GAAG,mBAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KACzD;;AAED,WAAO,aAAa,CAAC;CACxB,CAAC;;qBAEa,SAAS","file":"linkClass.js","sourcesContent":["import React from 'react';\nimport makeConfiguration from './makeConfiguration';\nimport _ from 'lodash';\n\nlet linkClass;\n\n/**\n * @param {ReactElement} element\n * @param {Object} styles CSS modules class map.\n * @param {CSSModules~Options} userConfiguration\n * @return {ReactElement}\n */\nlinkClass = (element, styles = {}, userConfiguration) => {\n let appendClassName,\n clonedElement,\n configuration,\n newChildren,\n newProps,\n styleNames;\n\n // @see https://github.com/gajus/react-css-modules/pull/30\n if (!element) {\n return element;\n }\n\n configuration = makeConfiguration(userConfiguration);\n\n styleNames = element.props.styleName;\n\n if (styleNames) {\n styleNames = styleNames.split(' ');\n styleNames = _.filter(styleNames);\n\n if (configuration.allowMultiple === false && styleNames.length > 1) {\n throw new Error(`ReactElement styleName property defines multiple module names (\"${element.props.styleName}\").`);\n }\n\n appendClassName = styleNames.map((styleName) => {\n if (styles[styleName]) {\n return styles[styleName];\n } else {\n if (configuration.errorWhenNotFound === true) {\n throw new Error(`\"${styleName}\" CSS module is undefined.`);\n }\n\n return '';\n }\n });\n\n appendClassName = appendClassName.filter((className) => {\n return className.length;\n });\n\n appendClassName = appendClassName.join(' ');\n }\n\n // element.props.children can be one of the following:\n // 'text'\n // ['text']\n // [ReactElement, 'text']\n // ReactElement\n\n // console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));\n\n if (React.isValidElement(element.props.children)) {\n newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);\n } else if (_.isArray(element.props.children)) {\n newChildren = React.Children.map(element.props.children, (node) => {\n if (React.isValidElement(node)) {\n return linkClass(node, styles, configuration);\n } else {\n return node;\n }\n });\n\n // https://github.com/facebook/react/issues/4723#issuecomment-135555277\n // Forcing children into an array produces the following error:\n // Warning: A ReactFragment is an opaque type. Accessing any of its properties is deprecated. Pass it to one of the React.Children helpers.\n // newChildren = _.values(newChildren);\n }\n\n if (appendClassName) {\n if (element.props.className) {\n appendClassName = `${element.props.className} ${appendClassName}`;\n }\n\n newProps = {\n className: appendClassName\n };\n }\n\n if (newChildren) {\n clonedElement = React.cloneElement(element, newProps, newChildren);\n } else {\n clonedElement = React.cloneElement(element, newProps);\n }\n\n return clonedElement;\n};\n\nexport default linkClass;\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/makeConfiguration.js b/dist/makeConfiguration.js
deleted file mode 100644
index 178a574..0000000
--- a/dist/makeConfiguration.js
+++ /dev/null
@@ -1,51 +0,0 @@
-'use strict';
-
-var _lodashCollectionForEach2 = require('lodash/collection/forEach');
-
-var _lodashCollectionForEach3 = _interopRequireDefault(_lodashCollectionForEach2);
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-/**
- * @typedef CSSModules~Options
- * @see {@link https://github.com/gajus/react-css-modules#options}
- * @property {boolean} allowMultiple
- * @property {boolean} errorWhenNotFound
- */
-
-/**
- * @param {CSSModules~Options} userConfiguration
- * @return {CSSModules~Options}
- */
-
-exports['default'] = function () {
- var userConfiguration = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
-
- var configuration = undefined;
-
- configuration = {
- allowMultiple: false,
- errorWhenNotFound: true
- };
-
- (0, _lodashCollectionForEach3['default'])(userConfiguration, function (value, name) {
- if (typeof configuration[name] === 'undefined') {
- throw new Error('Unknown configuration property "' + name + '".');
- }
-
- if (typeof value !== 'boolean') {
- throw new Error('"' + name + '" property value must be a boolean.');
- }
-
- configuration[name] = value;
- });
-
- return configuration;
-};
-
-module.exports = exports['default'];
-//# sourceMappingURL=makeConfiguration.js.map
diff --git a/dist/makeConfiguration.js.map b/dist/makeConfiguration.js.map
deleted file mode 100644
index dd0546d..0000000
--- a/dist/makeConfiguration.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["makeConfiguration.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBAae,YAA4B;QAA3B,iBAAiB,yDAAG,EAAE;;AAClC,QAAI,aAAa,YAAA,CAAC;;AAElB,iBAAa,GAAG;AACZ,qBAAa,EAAE,KAAK;AACpB,yBAAiB,EAAE,IAAI;KAC1B,CAAC;;AAEF,8CAAU,iBAAiB,EAAE,UAAC,KAAK,EAAE,IAAI,EAAK;AAC1C,YAAI,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE;AAC5C,kBAAM,IAAI,KAAK,sCAAoC,IAAI,QAAK,CAAC;SAChE;;AAED,YAAI,OAAO,KAAK,KAAK,SAAS,EAAE;AAC5B,kBAAM,IAAI,KAAK,OAAK,IAAI,yCAAsC,CAAC;SAClE;;AAED,qBAAa,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;KAC/B,CAAC,CAAC;;AAEH,WAAO,aAAa,CAAC;CACxB","file":"makeConfiguration.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * @typedef CSSModules~Options\n * @see {@link https://github.com/gajus/react-css-modules#options}\n * @property {boolean} allowMultiple\n * @property {boolean} errorWhenNotFound\n */\n\n/**\n * @param {CSSModules~Options} userConfiguration\n * @return {CSSModules~Options}\n */\nexport default (userConfiguration = {}) => {\n let configuration;\n\n configuration = {\n allowMultiple: false,\n errorWhenNotFound: true\n };\n\n _.forEach(userConfiguration, (value, name) => {\n if (typeof configuration[name] === 'undefined') {\n throw new Error(`Unknown configuration property \"${name}\".`);\n }\n\n if (typeof value !== 'boolean') {\n throw new Error(`\"${name}\" property value must be a boolean.`);\n }\n\n configuration[name] = value;\n });\n\n return configuration;\n};\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/wrapStatelessFunction.js b/dist/wrapStatelessFunction.js
deleted file mode 100644
index 7723dfa..0000000
--- a/dist/wrapStatelessFunction.js
+++ /dev/null
@@ -1,78 +0,0 @@
-'use strict';
-
-var _lodashLangIsObject2 = require('lodash/lang/isObject');
-
-var _lodashLangIsObject3 = _interopRequireDefault(_lodashLangIsObject2);
-
-var _lodashObjectAssign2 = require('lodash/object/assign');
-
-var _lodashObjectAssign3 = _interopRequireDefault(_lodashObjectAssign2);
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-var _linkClass = require('./linkClass');
-
-var _linkClass2 = _interopRequireDefault(_linkClass);
-
-var _react = require('react');
-
-var _react2 = _interopRequireDefault(_react);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-var wrapStatelessFunction = undefined;
-
-/**
- * @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components
- * @param {Function} Component
- * @param {Object} defaultStyles
- * @param {Object} options
- * @returns {Function}
- */
-wrapStatelessFunction = function (Component, defaultStyles, options) {
- var WrappedComponent = undefined;
-
- WrappedComponent = function () {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
-
- var renderResult = undefined,
- styles = undefined,
- useProps = undefined;
-
- if (props.styles) {
- useProps = props;
- styles = props.styles;
- } else if ((0, _lodashLangIsObject3['default'])(defaultStyles)) {
- useProps = (0, _lodashObjectAssign3['default'])({}, props, {
- styles: defaultStyles
- });
-
- styles = defaultStyles;
- } else {
- useProps = props;
- styles = {};
- }
-
- renderResult = Component.apply(undefined, [useProps].concat(args));
-
- if (renderResult) {
- return (0, _linkClass2['default'])(renderResult, styles, options);
- }
-
- return _react2['default'].createElement('noscript');
- };
-
- (0, _lodashObjectAssign3['default'])(WrappedComponent, Component);
-
- return WrappedComponent;
-};
-
-exports['default'] = wrapStatelessFunction;
-module.exports = exports['default'];
-//# sourceMappingURL=wrapStatelessFunction.js.map
diff --git a/dist/wrapStatelessFunction.js.map b/dist/wrapStatelessFunction.js.map
deleted file mode 100644
index 78ef1e4..0000000
--- a/dist/wrapStatelessFunction.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["wrapStatelessFunction.js"],"names":[],"mappings":";;;;;;;;;;;;;;yBAAsB,aAAa;;;;qBACjB,OAAO;;;;;;AAGzB,IAAI,qBAAqB,YAAA,CAAC;;;;;;;;;AAS1B,qBAAqB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AAC3D,QAAI,gBAAgB,YAAA,CAAC;;AAErB,oBAAgB,GAAG,YAAyB;0CAAT,IAAI;AAAJ,gBAAI;;;YAAnB,KAAK,yDAAG,EAAE;;AAC1B,YAAI,YAAY,YAAA;YACZ,MAAM,YAAA;YACN,QAAQ,YAAA,CAAC;;AAEb,YAAI,KAAK,CAAC,MAAM,EAAE;AACd,oBAAQ,GAAG,KAAK,CAAC;AACjB,kBAAM,GAAG,KAAK,CAAC,MAAM,CAAC;SACzB,MAAM,IAAI,qCAAW,aAAa,CAAC,EAAE;AAClC,oBAAQ,GAAG,qCAAS,EAAE,EAAE,KAAK,EAAE;AAC3B,sBAAM,EAAE,aAAa;aACxB,CAAC,CAAC;;AAEH,kBAAM,GAAG,aAAa,CAAC;SAC1B,MAAM;AACH,oBAAQ,GAAG,KAAK,CAAC;AACjB,kBAAM,GAAG,EAAE,CAAC;SACf;;AAED,oBAAY,GAAG,SAAS,mBAAC,QAAQ,SAAK,IAAI,EAAC,CAAC;;AAE5C,YAAI,YAAY,EAAE;AACd,mBAAO,4BAAU,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;SACnD;;AAED,eAAO,mBAAM,aAAa,CAAC,UAAU,CAAC,CAAC;KAC1C,CAAC;;AAEF,yCAAS,gBAAgB,EAAE,SAAS,CAAC,CAAC;;AAEtC,WAAO,gBAAgB,CAAC;CAC3B,CAAC;;qBAEa,qBAAqB","file":"wrapStatelessFunction.js","sourcesContent":["import linkClass from './linkClass';\nimport React from 'react';\nimport _ from 'lodash';\n\nlet wrapStatelessFunction;\n\n/**\n * @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components\n * @param {Function} Component\n * @param {Object} defaultStyles\n * @param {Object} options\n * @returns {Function}\n */\nwrapStatelessFunction = (Component, defaultStyles, options) => {\n let WrappedComponent;\n\n WrappedComponent = (props = {}, ...args) => {\n let renderResult,\n styles,\n useProps;\n\n if (props.styles) {\n useProps = props;\n styles = props.styles;\n } else if (_.isObject(defaultStyles)) {\n useProps = _.assign({}, props, {\n styles: defaultStyles\n });\n\n styles = defaultStyles;\n } else {\n useProps = props;\n styles = {};\n }\n\n renderResult = Component(useProps, ...args);\n\n if (renderResult) {\n return linkClass(renderResult, styles, options);\n }\n\n return React.createElement('noscript');\n };\n\n _.assign(WrappedComponent, Component);\n\n return WrappedComponent;\n};\n\nexport default wrapStatelessFunction;\n"],"sourceRoot":"/source/"}
\ No newline at end of file
From f65bad27dab80a88c835122d704715f876a9d749 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 4 Dec 2015 15:33:59 +0000
Subject: [PATCH 058/200] 3.6.3
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 6af34c4..124ba62 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.6.2",
+ "version": "3.6.3",
"author": {
"name": "Gajus Kuizinas",
"email": "gajus@gajus.com",
From 64eff397a49d648167e7a3e85a795321babd27c2 Mon Sep 17 00:00:00 2001
From: Gianluca Esposito
Date: Fri, 18 Dec 2015 10:47:42 +0100
Subject: [PATCH 059/200] Update README.md
Fixed Module Bundler fragment
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 88a335c..3a0b467 100644
--- a/README.md
+++ b/README.md
@@ -122,7 +122,7 @@ Using `react-css-modules`:
Setup consists of:
-* Setting up a [module bundler](#modulebundler) to load the [Interoperable CSS](https://github.com/css-modules/icss).
+* Setting up a [module bundler](#module-bundler) to load the [Interoperable CSS](https://github.com/css-modules/icss).
* [Decorating](#decorator) your component using `react-css-modules`.
### Module Bundler
From 85fc0194b962afc0d296630e0c024fd2e56f38af Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 18 Dec 2015 11:50:18 +0000
Subject: [PATCH 060/200] Added documentation about HMR.
---
README.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/README.md b/README.md
index 3a0b467..1c95255 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
- [`errorWhenNotFound`](#errorwhennotfound)
+– [React Hot Module Replacement](#react-hot-module-replacement)
- [Class Composition](#class-composition)
- [What Problems does Class Composition Solve?](#what-problems-does-class-composition-solve)
- [Class Composition Using CSS Preprocessors](#class-composition-using-css-preprocessors)
@@ -366,6 +367,16 @@ Throws an error when `styleName` cannot be mapped to an existing CSS Module.
}
```
+## React Hot Module Replacement
+
+Hot module reloading does to reload the CSS (see https://github.com/gajus/react-css-modules/issues/51).
+
+To enable CSS reloading, my advise is to wrap your webpack setup using [BrowserSync](https://www.browsersync.io/). BrowserSync enables CSS reloading when it detects a file change.
+
+[React CSS Modules examples](https://github.com/gajus/react-css-modules-examples) repository includes a configuration example using [BrowserSync](https://github.com/gajus/react-css-modules-examples/blob/master/webpack.config.browsersync.js).
+
+Note that `webpackk-dev-server` program [does not write bundle files to the disk](https://github.com/webpack/webpack-dev-server/issues/62). You need to use a [write-file-webpack-plugin](https://github.com/gajus/write-file-webpack-plugin) plugin to force writing to the disk to enable BrowserSync to detect changes.
+
## Class Composition
CSS Modules promote composition pattern, i.e. every CSS Module that is used in a component should define all properties required to describe an element, e.g.
From a9d92b0647c240010cddd5fdfe72ff19ee54ef68 Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 18 Dec 2015 12:47:27 +0000
Subject: [PATCH 061/200] React Hot Module Replacement docs.
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 1c95255..18f6f30 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
- [`errorWhenNotFound`](#errorwhennotfound)
-– [React Hot Module Replacement](#react-hot-module-replacement)
+- [React Hot Module Replacement](#react-hot-module-replacement)
- [Class Composition](#class-composition)
- [What Problems does Class Composition Solve?](#what-problems-does-class-composition-solve)
- [Class Composition Using CSS Preprocessors](#class-composition-using-css-preprocessors)
@@ -369,13 +369,13 @@ Throws an error when `styleName` cannot be mapped to an existing CSS Module.
## React Hot Module Replacement
-Hot module reloading does to reload the CSS (see https://github.com/gajus/react-css-modules/issues/51).
+[Hot module reloading](https://github.com/gaearon/react-transform-hmr) (HMR) does to reload the CSS document (see https://github.com/gajus/react-css-modules/issues/51). It only reloads the `class` HTML attribute value.
-To enable CSS reloading, my advise is to wrap your webpack setup using [BrowserSync](https://www.browsersync.io/). BrowserSync enables CSS reloading when it detects a file change.
+To enable CSS reloading, wrap [`webpack-dev-server`](https://webpack.github.io/docs/webpack-dev-server.html) configuration using [BrowserSync](https://www.browsersync.io/). BrowserSync enables CSS reloading when it detects a file change.
-[React CSS Modules examples](https://github.com/gajus/react-css-modules-examples) repository includes a configuration example using [BrowserSync](https://github.com/gajus/react-css-modules-examples/blob/master/webpack.config.browsersync.js).
+[React CSS Modules examples](https://github.com/gajus/react-css-modules-examples) repository includes a configuration example using [BrowserSync configuration using webpack-dev-server](https://github.com/gajus/react-css-modules-examples/blob/master/webpack.config.browsersync.js).
-Note that `webpackk-dev-server` program [does not write bundle files to the disk](https://github.com/webpack/webpack-dev-server/issues/62). You need to use a [write-file-webpack-plugin](https://github.com/gajus/write-file-webpack-plugin) plugin to force writing to the disk to enable BrowserSync to detect changes.
+Note that `webpackk-dev-server` program [does not write bundle files to the disk](https://github.com/webpack/webpack-dev-server/issues/62). Use [write-file-webpack-plugin](https://github.com/gajus/write-file-webpack-plugin) plugin to force writing to the disk. This will enable BrowserSync to detect changes.
## Class Composition
From 6359a4c030e0ac7aeef8c341255bfaba025c8649 Mon Sep 17 00:00:00 2001
From: Tieme van Veen
Date: Mon, 21 Dec 2015 11:44:22 +0100
Subject: [PATCH 062/200] Fix typo in readme
HMR does *to* reload the css -> HMR does *not* reload the css
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 18f6f30..60da45f 100644
--- a/README.md
+++ b/README.md
@@ -369,7 +369,7 @@ Throws an error when `styleName` cannot be mapped to an existing CSS Module.
## React Hot Module Replacement
-[Hot module reloading](https://github.com/gaearon/react-transform-hmr) (HMR) does to reload the CSS document (see https://github.com/gajus/react-css-modules/issues/51). It only reloads the `class` HTML attribute value.
+[Hot module reloading](https://github.com/gaearon/react-transform-hmr) (HMR) does not reload the CSS document (see https://github.com/gajus/react-css-modules/issues/51). It only reloads the `class` HTML attribute value.
To enable CSS reloading, wrap [`webpack-dev-server`](https://webpack.github.io/docs/webpack-dev-server.html) configuration using [BrowserSync](https://www.browsersync.io/). BrowserSync enables CSS reloading when it detects a file change.
From 170a78380ec8cefb2a3c1e527df00f56463a931d Mon Sep 17 00:00:00 2001
From: Tieme van Veen
Date: Tue, 29 Dec 2015 18:01:19 +0100
Subject: [PATCH 063/200] Sourcemaps documentation
---
README.md | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/README.md b/README.md
index 60da45f..59e2104 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,8 @@ React CSS Modules implement automatic mapping of CSS modules. Every CSS class is
- [Options](#options)
- [`allowMultiple`](#allowmultiple)
- [`errorWhenNotFound`](#errorwhennotfound)
+- [SASS, SCSS, LESS and other CSS Preprocessors](#sass-scss-less-and-other-css-preprocessors)
+ - [Enable Sourcemaps](#enable-sourcemaps)
- [React Hot Module Replacement](#react-hot-module-replacement)
- [Class Composition](#class-composition)
- [What Problems does Class Composition Solve?](#what-problems-does-class-composition-solve)
@@ -367,6 +369,17 @@ Throws an error when `styleName` cannot be mapped to an existing CSS Module.
}
```
+### Enable Sourcemaps
+
+To enable CSS Source maps, you'll need to pass the sourceMap-option to the css-loader:
+
+```js
+{
+ test: /\.scss$/,
+ loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!sass')
+}
+```
+
## React Hot Module Replacement
[Hot module reloading](https://github.com/gaearon/react-transform-hmr) (HMR) does not reload the CSS document (see https://github.com/gajus/react-css-modules/issues/51). It only reloads the `class` HTML attribute value.
From 43690c1b0d6909515c4bd284f945b9619ed00ddb Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 8 Jan 2016 15:46:51 +0000
Subject: [PATCH 064/200] Bumped dependencies.
---
package.json | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 124ba62..2dca1be 100644
--- a/package.json
+++ b/package.json
@@ -24,13 +24,13 @@
},
"devDependencies": {
"chai": "^3.4.1",
- "jsdom": "^7.1.1",
- "pragmatist": "^1.9.4",
- "react": "^0.14.3",
- "react-addons-test-utils": "^0.14.3"
+ "jsdom": "^7.2.2",
+ "pragmatist": "^2.3.71",
+ "react": "^0.14.6",
+ "react-addons-test-utils": "^0.14.6"
},
"scripts": {
- "pragmatist": "node ./node_modules/.bin/pragmatist",
+ "pragmatist": "node ./node_modules/.bin/pragmatist --browser",
"lint": "npm run pragmatist lint",
"test": "npm run pragmatist test",
"build": "npm run pragmatist build",
From f094ec0de2ce8157e1383d2eca9b42ce54e3ba0f Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 8 Jan 2016 15:58:14 +0000
Subject: [PATCH 065/200] 3.6.4
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 2dca1be..89b360b 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"css",
"modules"
],
- "version": "3.6.3",
+ "version": "3.6.4",
"author": {
"name": "Gajus Kuizinas",
"email": "gajus@gajus.com",
From 9ef21b68cc55324ed96c38535bc5778f710a5b9e Mon Sep 17 00:00:00 2001
From: Gajus Kuizinas
Date: Fri, 8 Jan 2016 16:06:26 +0000
Subject: [PATCH 066/200] Update README file path.
---
README.md | 2 +-
README/react-css-modules.png | Bin 46508 -> 0 bytes
README/react-css-modules.sketch | Bin 90112 -> 0 bytes
3 files changed, 1 insertion(+), 1 deletion(-)
delete mode 100644 README/react-css-modules.png
delete mode 100644 README/react-css-modules.sketch
diff --git a/README.md b/README.md
index 60da45f..f9a297a 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[](https://travis-ci.org/gajus/react-css-modules)
[](https://www.npmjs.org/package/react-css-modules)
-
+
React CSS Modules implement automatic mapping of CSS modules. Every CSS class is assigned a local-scoped identifier with a global unique name. CSS Modules enable a modular and reusable CSS!
diff --git a/README/react-css-modules.png b/README/react-css-modules.png
deleted file mode 100644
index 2614951ab7b6ec971422202f5b4424e5d263514f..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 46508
zcmeFZ^;eYN_dYC$q9TGIAdOPe(j9`7q#)fA1H#bVA)<7*bVzp$F@Q)jARR+V4BZSh
z#P?z?=Aa@iey4PRZ2it1u{*MF-+XXI+nRmos;36o+pmckp#u*`
z$KN;4q|L-=&hpRFcvHfckxo<}{x}c^czqA#^>CZDhT0XqXay1)N|(?{HU1h3S}
zzDj)GMoW(8$*tzfw3yBj?zx()RI7UM8|M~LmFnB~%ZSPVOpZxEbxMCUF7&7IBrg_Bl|BP}w9t~?GX?~EO
z-P|hpzh>Zx|J&*Q{Rxsi7M{hP`c}<{zzl^dN
zUO}>DSkjbr|7HVEq6=6H^duDZh=qOyOTGEZTV@+S!HOd$d4q_DI|b8)7XgwcsjBA>
zZV1}?S@)L@KBL72!#9=B+y~1^4%#yKttKrm{?1oy5q&;<$s&S;)5kc7KliulB-{QI
z>Gh0EhB{lbDhT44@ecJLl6&70p6;nGfbqtaf&!geE-sFZ%J!+z2kvp$-QVoxD~*v8
zJ&xTJ;}Ik}`0<8#K7Q6DG@5`2K{CR7Xt1=MAg8k&oVaCe@NH=}pO{+XxEw+lIiH>8
z_P)B)sZpec{#t}fiP%0#6Heqo_UmVqG7-*tSZ;FkSkHo;lWUi0}S+E)f^F=sLrscV0BJ7w$+NYEe9
z&_{m5*nDa{VAW5=suG|uV%kaHR}Je5L3n%ewD~p
z`~&In$Ukf+0Ya;X*R)(lJiC0d%6s;c6Q3M=7X>cDVKLL_EwDT8dcA}t5Y}X
zd5Lo-9+P$2c&;)~?44yh&eEBhd%d$Wr|xq_6bjM2`aZkXZlaF5#_~$Mdv>Afov%>h
ziQ6vhlh!w`+|p}y*_3vRVy5)qO*>j?G!ywn068gJ92*J~^N&&M
z{MRLhmL2YdUat@N=B`(CYT18Q`rq-7I7hRudQ}QSFBhd83Tdq4cJBPH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