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

passive-events-support

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

passive-events-support - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

index.html

2

dist/main.js

@@ -1,1 +0,1 @@

(()=>{"use strict";function e(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}return e}window.passiveSupported=e(),function(t=null){const n=t||["scroll","wheel","touchstart","touchmove","touchenter","touchend","touchleave","mouseout","mouseleave","mouseup","mousedown","mousemove","mouseenter","mousewheel","mouseover"],o=EventTarget.prototype.addEventListener;EventTarget.prototype.addEventListener=function(...t){!n.includes(t[0])||t[2]&&void 0!==t[2].passive||(t[2]={...t[2]||{},...e()&&{passive:!t[1].toString().includes("preventDefault")}}),o.call(this,...t)}}(window.passiveEvents)})();
(()=>{"use strict";function e(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}return e}window.passiveSupported=e(),function(t=null){const n=t||["scroll","wheel","touchstart","touchmove","touchenter","touchend","touchleave","mouseout","mouseleave","mouseup","mousedown","mousemove","mouseenter","mousewheel","mouseover"],o=EventTarget.prototype.addEventListener;EventTarget.prototype.addEventListener=function(...t){if(n.includes(t[0])&&(!t[2]||void 0===t[2].passive)){const n=t[1].toString(),[o,...s]=n.split("{"),i=o.replace(/(function|=>)/,"").trim(),u=s.join("{"),r=(i.match(/\(([^)]+)\)/)||[`(${i})`])[0].replace(/[()]/g,""),c=!(!r||!u.includes("preventDefault()")&&!u.includes(`(${r})`));t[2]={...t[2]||{},...e()&&{passive:!c}}}o.call(this,...t)}}(window.passiveEvents)})();
{
"name": "passive-events-support",
"version": "1.0.5",
"version": "1.0.6",
"description": "Passive Events Support",

@@ -11,3 +11,3 @@ "main": "src/index.js",

"repository": "git+https://github.com/ignasdamunskis/passive-events-support.git",
"author": "Ignas Damunskis <ignas.damunskis@esl-asia.com>",
"author": "Ignas Damunskis <ignas3run@gmail.com>",
"license": "MIT",

@@ -14,0 +14,0 @@ "bugs": {

@@ -40,5 +40,15 @@ export function passiveSupported() {

if (events.includes(args[0]) && (!args[2] || args[2].passive === undefined)) {
const fn = args[1].toString()
const [fnDeclaration, ...fnContents] = fn.split('{')
const fnName = fnDeclaration.replace(/(function|=>)/, '').trim()
const fnContent = fnContents.join('{')
const fnEvent = (fnName.match(/\(([^)]+)\)/) || [`(${fnName})`])[0].replace(/[()]/g, '')
const fnPrevented = !!(fnEvent && (
fnContent.includes('preventDefault()') ||
fnContent.includes(`(${fnEvent})`)
))
args[2] = {
...(args[2] || {}),
...(passiveSupported() && { passive: !args[1].toString().includes('preventDefault') })
...(passiveSupported() && { passive: !fnPrevented })
}

@@ -45,0 +55,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