Socket
Socket
Sign inDemoInstall

react-onclickoutside

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-onclickoutside - npm Package Compare versions

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');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc