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

event-plugin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-plugin - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"name": "event-plugin",
"description": "Declaratively add event listeners to your views.",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/flams/event-plugin",

@@ -6,0 +6,0 @@ "licenses": [

@@ -22,4 +22,46 @@ Event plugin

doc is coming...
Init event plugin and define event handlers:
```js
var eventPlugin = new EventPlugin({
toggle: function (event, node) {
// do something with...
// event is the original event
// node is the dom node that was clicked
}
});
```
```html
<!-- The toggle function will be called on click, on the propagation phase -->
<button data-event="listen: click, toggle, true">Change route</button>
```
When ready, attach the behavior to the dom via Seam:
```js
var Seam = require("seam");
var seam = new Seam({
event: eventPlugin
});
seam.apply(document.querySelector("button"));
```
You can also use the delegation method from event to delegate events to a parent DOM element.
This improves performance are less event listeners are bound to the DOM. This is especially
relevant to lists.
```html
<!-- The ul will listen to click event and call the toggle handler if an element matching 'a' is targeted.
The bubbling phase will be listened to in this case -->
<ul data-event="delegate: a, click, toggle, false">
<li><a href="#link1">link1</a></li>
<li><a href="#link2">link2</a></li>
<li><a href="#link3">link3</a></li>
</ul>
```
LICENSE

@@ -26,0 +68,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