catiline icon indicating copy to clipboard operation
catiline copied to clipboard

Use `window.addEventListener` instead of `addEventListener`

Open cadorn opened this issue 9 years ago • 4 comments

Having addEventListener dangle as a global is not ideal.

Please use window.addEventListener to provide more context to static analysis tooling.

cadorn avatar Jan 30 '15 06:01 cadorn

do you have a specific issue that it is causing

calvinmetcalf avatar Jan 30 '15 10:01 calvinmetcalf

My static analysis tooling expects all access to global functions via window. I can fix that but it would be a hack on my side.

Having to inject only window as a global when executing this in a different context than browser makes things a lot cleaner than having to inject all the window globals in the to VM container as well.

Also, when looking at the code and you see just addEventListener you don't know what object you are registering events on so you have to see if addEventListener is declared elsewhere in the file before knowing its the window one.

cadorn avatar Jan 30 '15 18:01 cadorn

And this one: https://github.com/calvinmetcalf/catiline/blob/e4ca4fb9bece9dae72f1b48659c5f0117799a178/src/nextTick.js#L24

cadorn avatar Jan 30 '15 19:01 cadorn