detect-passive-events
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -5,15 +5,17 @@ // adapted from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md | ||
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') { | ||
var options = Object.defineProperty({}, 'passive', { | ||
get: function get() { | ||
supportsPassiveEvents = true; | ||
var options = { | ||
get passive() { | ||
return supportsPassiveEvents = true; | ||
} | ||
}); // note: have to set and remove a no-op listener instead of null | ||
}; // have to set and remove a no-op listener instead of null | ||
// (which was used previously), because Edge v15 throws an error | ||
// when providing a null callback. | ||
// https://github.com/rafgraph/detect-passive-events/pull/3 | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
var noop = function noop() {}; | ||
var noop = function () {}; | ||
window.addEventListener('testPassive', noop, options); | ||
window.removeEventListener('testPassive', noop, options); | ||
window.addEventListener('p', noop, options); | ||
window.removeEventListener('p', noop, false); | ||
} | ||
@@ -20,0 +22,0 @@ |
{ | ||
"name": "detect-passive-events", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Detect if the browser supports passive events", | ||
"source": "src/index.ts", | ||
"main": "dist/detect-passive-events.js", | ||
"umd:main": "dist/detect-passive-events.umd.min.js", | ||
"main": "dist/detect-passive-events.cjs.js", | ||
"module": "dist/detect-passive-events.esm.js", | ||
@@ -12,7 +10,7 @@ "types": "dist/index.d.ts", | ||
"scripts": { | ||
"dev": "npm link && npm run watch && npm unlink", | ||
"watch": "rm -rf dist && trap 'exit 0' SIGINT; microbundle watch --format esm,cjs --no-compress --strict & microbundle watch --format umd --compress --strict", | ||
"build": "rm -rf dist && microbundle build --format esm,cjs --no-compress --strict && microbundle build --format umd --compress --strict", | ||
"prepublishOnly": "npm run test && npm run build", | ||
"tsc": "tsc --watch", | ||
"dev": "npm link && npm run watch && npm unlink -g", | ||
"build": "rollpkg build", | ||
"watch": "rollpkg watch", | ||
"prepublishOnly": "npm run lint && npm test && npm run build", | ||
"lint": "eslint src", | ||
"test": "jest", | ||
@@ -23,4 +21,3 @@ "test:watch": "jest --watchAll", | ||
"files": [ | ||
"dist", | ||
"src" | ||
"dist" | ||
], | ||
@@ -43,14 +40,14 @@ "repository": { | ||
"devDependencies": { | ||
"@types/jest": "^26.0.14", | ||
"jest": "^26.5.3", | ||
"microbundle": "^0.12.4", | ||
"prettier": "^2.1.2", | ||
"ts-jest": "^26.4.1", | ||
"typescript": "^4.0.3" | ||
"rollpkg": "^0.1.1", | ||
"typescript": "^4.1.2" | ||
}, | ||
"prettier": { | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100 | ||
"prettier": "rollpkg/configs/prettier.json", | ||
"eslintConfig": { | ||
"extends": [ | ||
"./node_modules/rollpkg/configs/eslint" | ||
] | ||
}, | ||
"jest": { | ||
"preset": "rollpkg" | ||
} | ||
} |
@@ -35,8 +35,8 @@ # Detect Passive Events | ||
```html | ||
<script src="https://unpkg.com/detect-passive-events/dist/detect-passive-events.umd.min.js"></script> | ||
<script src="https://unpkg.com/detect-passive-events/dist/detect-passive-events.umd.production.js"></script> | ||
``` | ||
```js | ||
// it will be available on the window as detectPassiveEvents | ||
if (window.detectPassiveEvents.supportsPassiveEvents) { | ||
// it will be available on the window as DetectPassiveEvents | ||
if (window.DetectPassiveEvents.supportsPassiveEvents) { | ||
document.addEventListener('scroll', handleScroll, { capture: false, passive: true }); | ||
@@ -43,0 +43,0 @@ } else { |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
15050
2
15
73
1