prevent-unload
Advanced tools
Comparing version 1.1.13 to 2.0.0
@@ -7,4 +7,3 @@ 'use strict'; | ||
function preventUnload(message) { | ||
var handler = makeHandler(message); | ||
var handler = createHandler(message); | ||
window.addEventListener('beforeunload', handler); | ||
@@ -17,3 +16,3 @@ | ||
if (typeof handler !== 'function') { | ||
throw new Error('handler must be a function'); | ||
throw new Error('`handler` must be a function'); | ||
} | ||
@@ -24,3 +23,3 @@ | ||
function makeHandler() { | ||
function createHandler() { | ||
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
@@ -31,3 +30,4 @@ | ||
// https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload | ||
event.returnValue = message; // eslint-disable-line no-param-reassign | ||
// eslint-disable-next-line no-param-reassign | ||
event.returnValue = message; | ||
@@ -34,0 +34,0 @@ return message; |
{ | ||
"name": "prevent-unload", | ||
"version": "1.1.13", | ||
"version": "2.0.0", | ||
"description": "Prevent page unloading from the user's action", | ||
@@ -10,4 +10,3 @@ "author": "Plusb Preco <plusb21@gmail.com>", | ||
"prebuild": "npm run clean", | ||
"test": "npm run lint && ava", | ||
"lint": "eslint .", | ||
"test": "eslint . && ava", | ||
"build": "babel --out-dir lib src", | ||
@@ -33,15 +32,15 @@ "clean": "rimraf lib" | ||
"devDependencies": { | ||
"ava": "^0.17.0", | ||
"babel-cli": "^6.18.0", | ||
"babel-eslint": "^7.1.0", | ||
"ava": "^0.18.1", | ||
"babel-cli": "^6.24.0", | ||
"babel-eslint": "^7.2.1", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-preset-env": "^0.0.9", | ||
"babel-register": "^6.18.0", | ||
"eslint": "^3.9.1", | ||
"eslint-config-prev": "^3.1.0", | ||
"eslint-plugin-babel": "^4.0.0", | ||
"babel-preset-env": "^1.3.2", | ||
"babel-register": "^6.24.0", | ||
"eslint": "^3.14.1", | ||
"eslint-config-prev": "^4.0.1", | ||
"eslint-plugin-babel": "^4.1.1", | ||
"eslint-plugin-import": "^2.0.1", | ||
"jsdom": "^9.8.3", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^1.17.6" | ||
"jsdom": "^9.12.0", | ||
"rimraf": "^2.6.1", | ||
"sinon": "^2.1.0" | ||
}, | ||
@@ -48,0 +47,0 @@ "ava": { |
@@ -18,4 +18,2 @@ # prevent-unload | ||
Example: | ||
```javascript | ||
@@ -30,3 +28,3 @@ import preventUnload, {cancel} from 'prevent-unload'; | ||
### `preventUnload([message])` | ||
### preventUnload([message]) | ||
@@ -39,3 +37,3 @@ * `message` String (optional) - Message to display on confirm popup. Default is platform specified. | ||
### `preventUnload.cancel(handler)` | ||
### preventUnload.cancel(handler) | ||
@@ -42,0 +40,0 @@ * `handler` Function - Handler reference to cancel event. |
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
26
4596
44