Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-event-listener

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-event-listener - npm Package Compare versions

Comparing version 0.5.9 to 0.6.0

39

dist/react-event-listener.cjs.js

@@ -16,3 +16,2 @@ 'use strict';

var PropTypes = _interopDefault(require('prop-types'));
var shallowEqual = _interopDefault(require('fbjs/lib/shallowEqual'));
var warning = _interopDefault(require('warning'));

@@ -119,4 +118,4 @@

/*#__PURE__*/
function (_React$Component) {
_inherits(EventListener, _React$Component);
function (_React$PureComponent) {
_inherits(EventListener, _React$PureComponent);

@@ -132,18 +131,9 @@ function EventListener() {

value: function componentDidMount() {
this.addListeners();
this.applyListeners(on);
}
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
return !shallowEqual(this.props, nextProps);
}
}, {
key: "componentWillUpdate",
value: function componentWillUpdate() {
this.removeListeners();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
this.addListeners();
value: function componentDidUpdate(prevProps) {
this.applyListeners(off, prevProps);
this.applyListeners(on);
}

@@ -153,12 +143,2 @@ }, {

value: function componentWillUnmount() {
this.removeListeners();
}
}, {
key: "addListeners",
value: function addListeners() {
this.applyListeners(on);
}
}, {
key: "removeListeners",
value: function removeListeners() {
this.applyListeners(off);

@@ -169,3 +149,4 @@ }

value: function applyListeners(onOrOff) {
var target = this.props.target;
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props;
var target = props.target;

@@ -179,3 +160,3 @@ if (target) {

forEachListener(this.props, onOrOff.bind(null, element));
forEachListener(props, onOrOff.bind(null, element));
}

@@ -191,3 +172,3 @@ }

return EventListener;
}(React.Component);
}(React.PureComponent);

@@ -194,0 +175,0 @@ EventListener.propTypes = process.env.NODE_ENV !== "production" ? {

@@ -143,64 +143,2 @@ (function (global, factory) {

/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @typechecks
*
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
// Added the nonzero y check to make Flow happy, but it is redundant
return x !== 0 || y !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
}
/**
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA, objB) {
if (is(objA, objB)) {
return true;
}
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
var shallowEqual_1 = shallowEqual;
/**
* Copyright 2014-2015, Facebook, Inc.

@@ -356,4 +294,4 @@ * All rights reserved.

/*#__PURE__*/
function (_React$Component) {
_inherits(EventListener, _React$Component);
function (_React$PureComponent) {
_inherits(EventListener, _React$PureComponent);

@@ -369,18 +307,9 @@ function EventListener() {

value: function componentDidMount() {
this.addListeners();
this.applyListeners(on);
}
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
return !shallowEqual_1(this.props, nextProps);
}
}, {
key: "componentWillUpdate",
value: function componentWillUpdate() {
this.removeListeners();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
this.addListeners();
value: function componentDidUpdate(prevProps) {
this.applyListeners(off, prevProps);
this.applyListeners(on);
}

@@ -390,12 +319,2 @@ }, {

value: function componentWillUnmount() {
this.removeListeners();
}
}, {
key: "addListeners",
value: function addListeners() {
this.applyListeners(on);
}
}, {
key: "removeListeners",
value: function removeListeners() {
this.applyListeners(off);

@@ -406,3 +325,4 @@ }

value: function applyListeners(onOrOff) {
var target = this.props.target;
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props;
var target = props.target;

@@ -416,3 +336,3 @@ if (target) {

forEachListener(this.props, onOrOff.bind(null, element));
forEachListener(props, onOrOff.bind(null, element));
}

@@ -428,3 +348,3 @@ }

return EventListener;
}(React.Component);
}(React.PureComponent);

@@ -431,0 +351,0 @@ EventListener.propTypes = {

{
"name": "react-event-listener",
"version": "0.5.9",
"version": "0.6.0",
"description": "A React component that allow to bind events on the global scope",

@@ -74,3 +74,2 @@ "main": "dist/react-event-listener.cjs.js",

"@babel/runtime": "^7.0.0-beta.42",
"fbjs": "^0.8.16",
"prop-types": "^15.6.0",

@@ -80,4 +79,4 @@ "warning": "^3.0.0"

"peerDependencies": {
"react": "^15.3.0 || ^16.0.0"
"react": "^16.3.0"
}
}
import React from 'react';
import PropTypes from 'prop-types';
import shallowEqual from 'fbjs/lib/shallowEqual';
import warning from 'warning';

@@ -74,33 +73,18 @@ import { passiveOption } from './supports';

class EventListener extends React.Component {
class EventListener extends React.PureComponent {
componentDidMount() {
this.addListeners();
this.applyListeners(on);
}
shouldComponentUpdate(nextProps) {
return !shallowEqual(this.props, nextProps);
componentDidUpdate(prevProps) {
this.applyListeners(off, prevProps);
this.applyListeners(on);
}
componentWillUpdate() {
this.removeListeners();
}
componentDidUpdate() {
this.addListeners();
}
componentWillUnmount() {
this.removeListeners();
}
addListeners() {
this.applyListeners(on);
}
removeListeners() {
this.applyListeners(off);
}
applyListeners(onOrOff) {
const { target } = this.props;
applyListeners(onOrOff, props = this.props) {
const { target } = props;

@@ -114,3 +98,3 @@ if (target) {

forEachListener(this.props, onOrOff.bind(null, element));
forEachListener(props, onOrOff.bind(null, element));
}

@@ -117,0 +101,0 @@ }

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