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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"babel-preset-react": "6.3.13",
"coveralls": "2.11.6",
"eslint": "1.10.3",
"eslint-config-airbnb": "2.1.1",
"eslint-config-airbnb": "3.0.0",
"eslint-plugin-react": "3.14.0",
"istanbul": "0.4.1",
"mocha": "2.3.4",
Expand Down
15 changes: 10 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ const flavourComponent = stampit()
/* eslint-disable no-use-before-define */
const reduceChildren =
function (parentComponent, reactClass, parentIndx, childMap, child, indx) {
const thisMap = _.assign({}, childMap);
const childIsElement = TestUtils.isElement(child);
const id = parseInt(parentIndx, 10) >= 0 ? parentIndx + '.' + indx : indx;

if (childIsElement) {
childMap[id] = flavourComponent(_.assign({}, child, { parentComponent, reactClass }));
thisMap[id] = flavourComponent(_.assign({}, child, { parentComponent, reactClass }));

_.assign(
childMap,
thisMap,
convertAndReduce(
parentComponent,
reactClass,
Expand All @@ -73,12 +74,12 @@ const reduceChildren =
)
);
} else {
childMap[id] = {
thisMap[id] = {
value: child,
};
}

return childMap;
return thisMap;
};
/* eslint-enable no-use-before-define */

Expand Down Expand Up @@ -114,7 +115,11 @@ const flavourInit = function (opts) {
}

this.type = output.type;
this.childMap = convertAndReduce(this.component, opts.instance.reactClass, output.props.children);
this.childMap = convertAndReduce(
this.component,
opts.instance.reactClass,
output.props.children
);
} else {
this.type = output;
this.childMap = [];
Expand Down
4 changes: 3 additions & 1 deletion tests/components/stamp/stamp-smart.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default class StampSmartComponent extends Component {
this.state = props.state || {
type: stampTypes.NONE,
};

this.handleOnClick = this.handleOnClick.bind(this);
}

getNextStampType(types, currentType) {
Expand Down Expand Up @@ -44,7 +46,7 @@ export default class StampSmartComponent extends Component {
<Stamp
types={stampTypes}
type={this.state.type}
onClick={this.handleOnClick.bind(this)}
onClick={this.handleOnClick}
/>
);
}
Expand Down
15 changes: 10 additions & 5 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import ReactDOM from 'react-dom';
import App from './components/app/app';

const comingFrom = 'Welcome from some sort of React holiday';
const message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec commodo venenatis tortor, ' +
'in viverra libero ullamcorper quis. Nam blandit volutpat ante sit amet sagittis. Cras ultrices augue sem, ' +
'id congue felis efficitur a. Mauris luctus, nisl eu dignissim molestie, sem libero fringilla ex, ' +
'id faucibus ligula justo et nibh. Donec posuere rhoncus leo eget fringilla. Nulla ex arcu, ' +
'gravida nec malesuada sit amet, faucibus ut lectus. Donec elementum sapien a lorem tristique egestas. ' +
const message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' +
'Donec commodo venenatis tortor, ' +
'in viverra libero ullamcorper quis. Nam blandit volutpat ante sit amet sagittis. ' +
'Cras ultrices augue sem, ' +
'id congue felis efficitur a. Mauris luctus, nisl eu dignissim molestie, ' +
'sem libero fringilla ex, ' +
'id faucibus ligula justo et nibh. Donec posuere rhoncus leo eget fringilla. ' +
'Nulla ex arcu, ' +
'gravida nec malesuada sit amet, faucibus ut lectus. ' +
'Donec elementum sapien a lorem tristique egestas. ' +
'Etiam a orci tincidunt, interdum leo blandit, consequat risus.';
const signature = 'John Smith';
const addressee = 'Mrs. Joanne Bloggs';
Expand Down
10 changes: 7 additions & 3 deletions tests/stand-alone/link-list/link-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Link from './link';
export default class LinkListComponent extends Component {
constructor(props) {
super(props);

this.handleLink1Click = this.handleLink1Click.bind(this);
this.handleLink2Click = this.handleLink2Click.bind(this);
this.handleLink3Click = this.handleLink3Click.bind(this);
}

handleLink1Click() {
Expand All @@ -22,13 +26,13 @@ export default class LinkListComponent extends Component {
const { links } = this.props;
return (
<ul>
<li key="0" onClick={this.handleLink1Click.bind(this)}>
<li key="0" onClick={this.handleLink1Click}>
<Link text={links[0].text}/>
</li>
<li key="1" onClick={this.handleLink2Click.bind(this)}>
<li key="1" onClick={this.handleLink2Click}>
<Link text={links[1].text}/>
</li>
<li key="2" onClick={this.handleLink3Click.bind(this)}>
<li key="2" onClick={this.handleLink3Click}>
<Link text={links[2].text}/>
</li>
</ul>
Expand Down
12 changes: 10 additions & 2 deletions tests/stand-alone/unordered-list/unordered-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,21 @@ export default class UnorderedListComponent extends Component {
}

render() {
const { i18n = {}, links = [], rlinks = [], drlinkssrc = [], randomString = '', email = '' } = this.props;
const {
i18n = {},
links = [],
rlinks = [],
drlinkssrc = [],
randomString = '',
email = '',
} = this.props;
const drlinks = email ? this.getDrlinks(i18n, email, drlinkssrc, randomString) : [];

return (
<ul className="class-1" onClick={this.handleOnClick}>
<li className="class-2">
<a href="some-href-1"
<a
href="some-href-1"
title={i18n.help}
target="_blank"
rel="help"
Expand Down
2 changes: 1 addition & 1 deletion tests/webpack.config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('development'),
NODE_ENV: JSON.stringify('development'),
},
}),
],
Expand Down