react-onclickoutside
Advanced tools
Comparing version 5.4.1 to 5.5.0
11
index.js
@@ -110,8 +110,9 @@ /** | ||
} | ||
} else if(typeof instance.handleClickOutside === 'function') { | ||
clickOutsideHandler = instance.handleClickOutside; | ||
} else if(typeof instance.props.handleClickOutside === 'function') { | ||
clickOutsideHandler = instance.props.handleClickOutside; | ||
} else { | ||
if(typeof instance.handleClickOutside !== 'function') { | ||
throw new Error('Component lacks a handleClickOutside(event) function for processing outside click events.'); | ||
} | ||
clickOutsideHandler = instance.handleClickOutside; | ||
} | ||
throw new Error('Component lacks a handleClickOutside(event) function for processing outside click events.'); | ||
} | ||
@@ -118,0 +119,0 @@ var fn = this.__outsideClickHandler = generateOutsideCheck( |
{ | ||
"name": "react-onclickoutside", | ||
"version": "5.4.1", | ||
"version": "5.5.0", | ||
"description": "An onClickOutside mixin for React components", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
"test": "npm run lint && karma start test/karma.conf.js --single-run", | ||
"lint": "eslint index.js test/*.js", | ||
"lint": "eslint index.js ./test", | ||
"precommit": "npm run lint" | ||
@@ -29,0 +29,0 @@ }, |
@@ -9,3 +9,3 @@ /** | ||
handleClickOutside: function(evt) { | ||
handleClickOutside: function() { | ||
this.setState({ highlight: false }); | ||
@@ -20,4 +20,4 @@ }, | ||
render: function() { | ||
var className = "concentric" + (this.state.highlight? " highlight" : ''); | ||
return React.createElement("div", { | ||
var className = 'concentric' + (this.state.highlight? ' highlight' : ''); | ||
return React.createElement('div', { | ||
className: className, | ||
@@ -30,4 +30,5 @@ children: this.props.children, | ||
Nested = onClickOutside(Nested); | ||
Nested = onClickOutside(Nested); /* global onClickOutside */ | ||
var App = React.createClass({ | ||
@@ -44,3 +45,3 @@ render: function() { | ||
stopPropagation: true, | ||
children: React.createElement("div", { className: "label", children: ["test"] }) | ||
children: React.createElement('div', { className: 'label', children: ['test'] }) | ||
}) | ||
@@ -47,0 +48,0 @@ }) |
@@ -151,2 +151,32 @@ var React = require('react'); | ||
}); | ||
it('should fallback to call component.props.handleClickOutside when no component.handleClickOutside is defined', function() { | ||
var StatelessComponent = React.createClass({ | ||
render: function() { | ||
return React.createElement('div'); | ||
} | ||
}); | ||
var clickOutsideHandled = false; | ||
var WrappedStatelessComponent = wrapComponent(StatelessComponent); | ||
var element = React.createElement( | ||
WrappedStatelessComponent, | ||
{ | ||
handleClickOutside: function(event) { | ||
if (event === undefined) { | ||
throw new Error('event cannot be undefined'); | ||
} | ||
clickOutsideHandled = true; | ||
} | ||
} | ||
); | ||
assert(element, 'element can be created'); | ||
var component = TestUtils.renderIntoDocument(element); | ||
assert(component, 'component renders correctly'); | ||
document.dispatchEvent(new Event('mousedown')); | ||
component.getInstance(); | ||
assert(clickOutsideHandled, 'clickOutsideHandled got flipped'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27746
479