Comparing version 1.0.0 to 1.0.1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.consign=e()}}(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){ | ||
module.exports = consign; | ||
function findMatches() { | ||
@@ -12,14 +10,31 @@ var matches, candidates = ['matchesSelector', 'mozMatchesSelector', | ||
matches = candidate; | ||
break; | ||
} | ||
} | ||
return matches; | ||
} | ||
}; | ||
var matchesSelector = findMatches(); | ||
function consign(parent, evnt, selector, fn) { | ||
function contains(parent, element) { | ||
if (element.parentNode) { | ||
if (element.parentNode === parent) { | ||
return true | ||
} else { | ||
return contains(parent, element.parentNode); | ||
} | ||
} else { | ||
return false; | ||
} | ||
}; | ||
function consign(parent, evnt, selector, fn, ctx) { | ||
parent.addEventListener(evnt, function(event) { | ||
var element = function find(el) { | ||
if (el[matchesSelector](selector)) { | ||
return el; | ||
if (contains(parent, el)) { | ||
return el; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -35,7 +50,10 @@ | ||
if (element) { | ||
fn.apply(element, arguments); | ||
ctx = ctx || element; | ||
fn.apply(ctx, arguments); | ||
} | ||
}, false); | ||
} | ||
}; | ||
module.exports = consign; | ||
},{}]},{},[1])(1) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module){module.exports=a()}else{if("function"==typeof define&&define.amd){define([],a)}else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.consign=a()}}}(function(){var d,b,a;return(function c(f,k,h){function g(q,n){if(!k[q]){if(!f[q]){var m=typeof require=="function"&&require;if(!n&&m){return m(q,!0)}if(e){return e(q,!0)}var p=new Error("Cannot find module '"+q+"'");throw p.code="MODULE_NOT_FOUND",p}var i=k[q]={exports:{}};f[q][0].call(i.exports,function(l){var o=f[q][1][l];return g(o?o:l)},i,i.exports,c,f,k,h)}return k[q].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(g,h,f){h.exports=i;function j(){var p,o=["matchesSelector","mozMatchesSelector","webkitMatchesSelector","oMatchesSelector","msMatchesSelector"];for(var m=0,k=o.length;m<k;m++){var n=o[m];if(n in document.documentElement){p=n}}return p}var e=j();function i(m,n,k,l){m.addEventListener(n,function(p){var o=function q(r){if(r[e](k)){return r}if(r.parentNode!==m){return q(r.parentNode)}return false}(p.target);if(o){l.apply(o,arguments)}},false)}},{}]},{},[1])(1)}); | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module){module.exports=a()}else{if("function"==typeof define&&define.amd){define([],a)}else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.consign=a()}}}(function(){var d,b,a;return(function c(f,k,h){function g(q,n){if(!k[q]){if(!f[q]){var m=typeof require=="function"&&require;if(!n&&m){return m(q,!0)}if(e){return e(q,!0)}var p=new Error("Cannot find module '"+q+"'");throw p.code="MODULE_NOT_FOUND",p}var i=k[q]={exports:{}};f[q][0].call(i.exports,function(l){var o=f[q][1][l];return g(o?o:l)},i,i.exports,c,f,k,h)}return k[q].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(g,i,f){function k(){var q,p=["matchesSelector","mozMatchesSelector","webkitMatchesSelector","oMatchesSelector","msMatchesSelector"];for(var n=0,m=p.length;n<m;n++){var o=p[n];if(o in document.documentElement){q=o;break}}return q}var e=k();function h(m,l){if(l.parentNode){if(l.parentNode===m){return true}else{return h(m,l.parentNode)}}else{return false}}function j(o,p,l,n,m){o.addEventListener(p,function(r){var q=function s(t){if(t[e](l)){if(h(o,t)){return t}else{return false}}if(t.parentNode!==o){return s(t.parentNode)}return false}(r.target);if(q){m=m||q;n.apply(m,arguments)}},false)}i.exports=j},{}]},{},[1])(1)}); |
26
index.js
@@ -9,14 +9,31 @@ function findMatches() { | ||
matches = candidate; | ||
break; | ||
} | ||
} | ||
return matches; | ||
} | ||
}; | ||
var matchesSelector = findMatches(); | ||
function consign(parent, evnt, selector, fn) { | ||
function contains(parent, element) { | ||
if (element.parentNode) { | ||
if (element.parentNode === parent) { | ||
return true | ||
} else { | ||
return contains(parent, element.parentNode); | ||
} | ||
} else { | ||
return false; | ||
} | ||
}; | ||
function consign(parent, evnt, selector, fn, ctx) { | ||
parent.addEventListener(evnt, function(event) { | ||
var element = function find(el) { | ||
if (el[matchesSelector](selector)) { | ||
return el; | ||
if (contains(parent, el)) { | ||
return el; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -32,3 +49,4 @@ | ||
if (element) { | ||
fn.apply(element, arguments); | ||
ctx = ctx || element; | ||
fn.apply(ctx, arguments); | ||
} | ||
@@ -35,0 +53,0 @@ }, false); |
{ | ||
"name": "consign", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "dom event delegation", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6514
98