+1
-1
| { | ||
| "name": "delegate", | ||
| "version": "2.0.2", | ||
| "version": "2.0.3", | ||
| "description": "Lightweight event delegation", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -10,7 +10,7 @@ <!DOCTYPE html> | ||
| <ul> | ||
| <li><a href="#">Item 1</a></li> | ||
| <li><a href="#">Item 2</a></li> | ||
| <li><a href="#">Item 3</a></li> | ||
| <li><a href="#">Item 4</a></li> | ||
| <li><a href="#">Item 5</a></li> | ||
| <li><button>Item 1</button></li> | ||
| <li><button>Item 2</button></li> | ||
| <li><button>Item 3</button></li> | ||
| <li><button>Item 4</button></li> | ||
| <li><button>Item 5</button></li> | ||
| </ul> | ||
@@ -25,3 +25,3 @@ | ||
| delegate(ul, 'a', 'click', function(e) { | ||
| delegate(ul, 'button', 'click', function(e) { | ||
| console.log(e.target); | ||
@@ -28,0 +28,0 @@ }); |
@@ -10,11 +10,11 @@ <!DOCTYPE html> | ||
| <ul> | ||
| <li><a href="#">Item 1</a></li> | ||
| <li><a href="#">Item 2</a></li> | ||
| <li><a href="#">Item 3</a></li> | ||
| <li><a href="#">Item 4</a></li> | ||
| <li><a href="#">Item 5</a></li> | ||
| <li><button>Item 1</button></li> | ||
| <li><button>Item 2</button></li> | ||
| <li><button>Item 3</button></li> | ||
| <li><button>Item 4</button></li> | ||
| <li><button>Item 5</button></li> | ||
| </ul> | ||
| <ul> | ||
| <li><p>Item 6</p></li> | ||
| <li><p>Item 7</p></li> | ||
| <li><span>Item 6</span></li> | ||
| <li><span>Item 7</span></li> | ||
| </ul> | ||
@@ -29,7 +29,7 @@ | ||
| delegate(ul, 'a', 'click', function(e) { | ||
| delegate(ul, 'button', 'click', function(e) { | ||
| console.log(e.target); | ||
| }); | ||
| delegate(document.body, 'p', 'click', function(e) { | ||
| delegate(document.body, 'span', 'click', function(e) { | ||
| console.log(e.target); | ||
@@ -36,0 +36,0 @@ }); |
@@ -10,7 +10,7 @@ <!DOCTYPE html> | ||
| <ul> | ||
| <li><a href="#">Item 1</a></li> | ||
| <li><a href="#">Item 2</a></li> | ||
| <li><a href="#">Item 3</a></li> | ||
| <li><a href="#">Item 4</a></li> | ||
| <li><a href="#">Item 5</a></li> | ||
| <li><button>Item 1</button></li> | ||
| <li><button>Item 2</button></li> | ||
| <li><button>Item 3</button></li> | ||
| <li><button>Item 4</button></li> | ||
| <li><button>Item 5</button></li> | ||
| </ul> | ||
@@ -25,3 +25,3 @@ | ||
| var delegation = delegate(ul, 'li a', 'click', function(e) { | ||
| var delegation = delegate(ul, 'li button', 'click', function(e) { | ||
| console.log(e.target); | ||
@@ -28,0 +28,0 @@ }); |
+2
-6
@@ -89,9 +89,5 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.delegate = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
| return function(e) { | ||
| var delegateTarget = closest(e.target, selector, true); | ||
| e.delegateTarget = closest(e.target, selector, true); | ||
| if (delegateTarget) { | ||
| Object.defineProperty(e, 'target', { | ||
| value: delegateTarget | ||
| }); | ||
| if (e.delegateTarget) { | ||
| callback.call(element, e); | ||
@@ -98,0 +94,0 @@ } |
+1
-1
| { | ||
| "name": "delegate", | ||
| "description": "Lightweight event delegation", | ||
| "version": "2.0.2", | ||
| "version": "2.0.3", | ||
| "repository": "zenorocha/delegate", | ||
@@ -6,0 +6,0 @@ "main": "src/delegate.js", |
+6
-0
@@ -55,4 +55,10 @@ # delegate | ||
| ## Browser Support | ||
| | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/chrome/chrome_64x64.png" width="48px" height="48px" alt="Chrome logo"> | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/firefox/firefox_64x64.png" width="48px" height="48px" alt="Firefox logo"> | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/internet-explorer/internet-explorer_64x64.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/opera/opera_64x64.png" width="48px" height="48px" alt="Opera logo"> | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/safari/safari_64x64.png" width="48px" height="48px" alt="Safari logo"> | | ||
| |:---:|:---:|:---:|:---:|:---:| | ||
| | Latest ✔ | Latest ✔ | IE 9+ ✔ | Latest ✔ | Latest ✔ | | ||
| ## License | ||
| [MIT License](http://zenorocha.mit-license.org/) © Zeno Rocha |
+2
-6
@@ -35,9 +35,5 @@ var closest = require('closest'); | ||
| return function(e) { | ||
| var delegateTarget = closest(e.target, selector, true); | ||
| e.delegateTarget = closest(e.target, selector, true); | ||
| if (delegateTarget) { | ||
| Object.defineProperty(e, 'target', { | ||
| value: delegateTarget | ||
| }); | ||
| if (e.delegateTarget) { | ||
| callback.call(element, e); | ||
@@ -44,0 +40,0 @@ } |
+5
-5
@@ -7,7 +7,7 @@ var delegate = require('../src/delegate'); | ||
| var html = '<ul>' + | ||
| '<li><a href="#">Item 1</a></li>' + | ||
| '<li><a href="#">Item 2</a></li>' + | ||
| '<li><a href="#">Item 3</a></li>' + | ||
| '<li><a href="#">Item 4</a></li>' + | ||
| '<li><a href="#">Item 5</a></li>' + | ||
| '<li><a>Item 1</a></li>' + | ||
| '<li><a>Item 2</a></li>' + | ||
| '<li><a>Item 3</a></li>' + | ||
| '<li><a>Item 4</a></li>' + | ||
| '<li><a>Item 5</a></li>' + | ||
| '</ul>'; | ||
@@ -14,0 +14,0 @@ |
11034
6.42%64
10.34%184
-3.16%