Skip to content

Commit

Permalink
ignore events in compare props
Browse files Browse the repository at this point in the history
  • Loading branch information
MicheleBertoli committed Mar 5, 2016
1 parent 477cd9c commit 956ffd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/utils/compare-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports['default'] = function (props, nextProps) {

for (var i = 0; i < propsKeys.length; i++) {
var key = propsKeys[i];
if (key !== 'children' && (!nextProps.hasOwnProperty(key) || props[key] !== nextProps[key])) {
if (key !== 'children' && key.indexOf('on') !== 0 && (!nextProps.hasOwnProperty(key) || props[key] !== nextProps[key])) {
return false;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/utils/__tests__/compare-props-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ describe('compareProps', () => {
});

it('ignores the `children` property', () => {
const result = compareProps({a: 1, children: 1}, {a: 1, children: 2});
const result = compareProps({children: 1}, {children: 2});
expect(result).toBe(true);
});

it('ignores the `on*` properties', () => {
const result = compareProps({onClick: () => {}}, {onClick: () => {}});
expect(result).toBe(true);
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/compare-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default (props, nextProps) => {

for (let i = 0; i < propsKeys.length; i++) {
const key = propsKeys[i];
if (key !== 'children' &&
if ((key !== 'children' && key.indexOf('on') !== 0) &&
(!nextProps.hasOwnProperty(key) || props[key] !== nextProps[key])) {
return false;
}
Expand Down

0 comments on commit 956ffd9

Please sign in to comment.