react-event-listener
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "react-event-listener", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A React component that allow to bind events on the global scope", | ||
@@ -8,6 +8,7 @@ "main": "lib/index.js", | ||
"build": "rimraf lib && babel src --out-dir lib --ignore spec.js", | ||
"lint": "eslint src test", | ||
"lint": "eslint . && echo \"eslint: no lint errors\"", | ||
"test:unit": "mocha", | ||
"test:watch": "mocha -w", | ||
"test": "npm run lint && npm run test:unit && npm run flow", | ||
"prettier": "find . -name \"*.js\" | grep -v -f .eslintignore | xargs prettier --write --single-quote --trailing-comma all --print-width 100", | ||
"flow": "flow", | ||
@@ -35,5 +36,5 @@ "version": "npm run build && pkgfiles" | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^7.2.3", | ||
"babel-eslint": "^8.0.1", | ||
"babel-plugin-transform-dev-warning": "^0.1.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.8", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.9", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
@@ -43,32 +44,34 @@ "babel-preset-es2015": "^6.24.1", | ||
"babel-preset-stage-1": "^6.24.1", | ||
"chai": "^4.1.1", | ||
"enzyme": "^2.9.1", | ||
"eslint": "^4.5.0", | ||
"chai": "^4.1.2", | ||
"enzyme": "^3.1.0", | ||
"enzyme-adapter-react-16": "^1.0.1", | ||
"eslint": "^4.8.0", | ||
"eslint-config-airbnb": "^15.1.0", | ||
"eslint-plugin-babel": "^4.1.2", | ||
"eslint-plugin-flowtype": "^2.35.0", | ||
"eslint-plugin-flowtype": "^2.38.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jsx-a11y": "^5.1.1", | ||
"eslint-plugin-mocha": "^4.11.0", | ||
"eslint-plugin-react": "^7.3.0", | ||
"expect": "^1.20.2", | ||
"flow-bin": "^0.53.1", | ||
"jsdom": "^11.2.0", | ||
"mocha": "^3.5.0", | ||
"eslint-plugin-prettier": "^2.3.1", | ||
"eslint-plugin-react": "^7.4.0", | ||
"flow-bin": "^0.56.0", | ||
"jsdom": "^11.3.0", | ||
"mocha": "^4.0.0", | ||
"pkgfiles": "^2.3.2", | ||
"react": "^15.6.1", | ||
"react-dom": "^15.6.1", | ||
"react-test-renderer": "^15.6.1", | ||
"rimraf": "^2.6.1", | ||
"sinon": "^3.2.1" | ||
"prettier": "^1.7.4", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react-test-renderer": "^16.0.0", | ||
"rimraf": "^2.6.2", | ||
"sinon": "^4.0.1" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"fbjs": "^0.8.14", | ||
"prop-types": "^15.5.10", | ||
"fbjs": "^0.8.16", | ||
"prop-types": "^15.6.0", | ||
"warning": "^3.0.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^15.3.0 || ^16.0.0-beta.5" | ||
"react": "^15.3.0 || ^16.0.0" | ||
} | ||
} |
@@ -12,4 +12,4 @@ // @flow | ||
type EventOptions = { | ||
capture: boolean; | ||
passive: boolean; | ||
capture: boolean, | ||
passive: boolean, | ||
}; | ||
@@ -26,3 +26,7 @@ | ||
function getEventListenerArgs(eventName: string, callback: Function, options: EventOptions): Array<any> { | ||
function getEventListenerArgs( | ||
eventName: string, | ||
callback: Function, | ||
options: EventOptions, | ||
): Array<any> { | ||
const args = [eventName, callback]; | ||
@@ -36,3 +40,4 @@ args.push(supports.passiveOption ? options : options.capture); | ||
target.addEventListener.apply(target, getEventListenerArgs(eventName, callback, options)); | ||
} else if (supports.attachEvent) { // IE8+ Support | ||
} else if (supports.attachEvent) { | ||
// IE8+ Support | ||
target.attachEvent(`on${eventName}`, () => { | ||
@@ -47,3 +52,4 @@ callback.call(target); | ||
target.removeEventListener.apply(target, getEventListenerArgs(eventName, callback, options)); | ||
} else if (supports.detachEvent) { // IE8+ Support | ||
} else if (supports.detachEvent) { | ||
// IE8+ Support | ||
target.detachEvent(`on${eventName}`, callback); | ||
@@ -56,3 +62,3 @@ } | ||
target?: EventTarget, | ||
[event: string]: Function | ||
[event: string]: Function, | ||
}; | ||
@@ -70,3 +76,3 @@ | ||
Object.keys(eventProps).forEach((name) => { | ||
Object.keys(eventProps).forEach(name => { | ||
if (name.substring(0, 2) !== 'on') { | ||
@@ -97,5 +103,8 @@ return; | ||
export function withOptions(handler: Function, options: EventOptions): { | ||
export function withOptions( | ||
handler: Function, | ||
options: EventOptions | ||
options: EventOptions, | ||
): { | ||
handler: Function, | ||
options: EventOptions, | ||
} { | ||
@@ -119,6 +128,3 @@ warning(options, 'react-event-listener: Should be specified options in withOptions.'); | ||
*/ | ||
target: PropTypes.oneOfType([ | ||
PropTypes.object, | ||
PropTypes.string, | ||
]).isRequired, | ||
target: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired, | ||
}; | ||
@@ -155,5 +161,3 @@ | ||
applyListeners(onOrOff: Function): void { | ||
const { | ||
target, | ||
} = this.props; | ||
const { target } = this.props; | ||
@@ -160,0 +164,0 @@ if (target) { |
@@ -32,7 +32,11 @@ // @flow | ||
try { | ||
window.addEventListener('test', null, defineProperty({}, 'passive', { | ||
get() { | ||
supportsPassiveOption = true; | ||
}, | ||
})); | ||
window.addEventListener( | ||
'test', | ||
null, | ||
defineProperty({}, 'passive', { | ||
get() { | ||
supportsPassiveOption = true; | ||
}, | ||
}), | ||
); | ||
} catch (e) {} // eslint-disable-line no-empty | ||
@@ -39,0 +43,0 @@ |
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
20882
395
31
Updatedfbjs@^0.8.16
Updatedprop-types@^15.6.0