Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
The crossvent npm package is a utility for handling cross-browser events. It provides a simple API to add, remove, and handle events in a way that works consistently across different browsers.
Adding Event Listeners
This feature allows you to add event listeners to DOM elements. The code sample demonstrates how to add a 'click' event listener to an element with the ID 'myElement'.
const crossvent = require('crossvent');
const element = document.getElementById('myElement');
function handleClick(event) {
console.log('Element clicked!', event);
}
crossvent.add(element, 'click', handleClick);
Removing Event Listeners
This feature allows you to remove event listeners from DOM elements. The code sample shows how to add and then remove a 'click' event listener from an element with the ID 'myElement'.
const crossvent = require('crossvent');
const element = document.getElementById('myElement');
function handleClick(event) {
console.log('Element clicked!', event);
}
crossvent.add(element, 'click', handleClick);
crossvent.remove(element, 'click', handleClick);
Triggering Events
This feature allows you to programmatically trigger events on DOM elements. The code sample demonstrates how to trigger a 'click' event on an element with the ID 'myElement'.
const crossvent = require('crossvent');
const element = document.getElementById('myElement');
function handleClick(event) {
console.log('Element clicked!', event);
}
crossvent.add(element, 'click', handleClick);
crossvent.fabricate(element, 'click');
EventEmitter3 is a high-performance event emitter for Node.js and the browser. It provides a similar API for adding, removing, and triggering events but is more focused on custom event handling rather than DOM events.
Mitt is a tiny (~200 bytes) functional event emitter. It provides a simple and fast way to handle custom events in both Node.js and the browser. Unlike crossvent, it does not specifically target DOM events but can be used for general event handling.
Component-emitter is a simple event emitter component for the browser and Node.js. It offers a similar API for event handling but is more lightweight and focused on custom events rather than cross-browser DOM events.
Cross-platform browser event handling
The event handler API used by dominus.
Using Bower
bower install -S crossvent
Using npm
npm install -S crossvent
The API exposes a few methods that let you deal with event handling in a consistent manner across browsers.
crossvent.add(el, type, fn, capturing?)
Adds an event listener fn
of type type
to DOM element el
.
crossvent.add(document.body, 'click', function (e) {
console.log('clicked document body');
});
crossvent.remove(el, type, fn, capturing?)
Removes an event listener fn
of type type
from DOM element el
.
crossvent.add(document.body, 'click', clicked);
crossvent.remove(document.body, 'click', clicked);
function clicked (e) {
console.log('clicked document body');
}
crossvent.fabricate(el, type, model?)
Creates a synthetic custom event of type type
and dispatches it on el
. You can provide a custom model
which will be accessible as e.detail
.
crossvent.add(document.body, 'sugar', sugary);
crossvent.fabricate(document.body, 'sugar', { onTop: true });
function sugary (e) {
console.log('synthetic sugar' + e.detail.onTop ? ' on top' : '');
}
MIT
FAQs
Cross-platform browser event handling
The npm package crossvent receives a total of 212,598 weekly downloads. As such, crossvent popularity was classified as popular.
We found that crossvent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.