Socket
Socket
Sign inDemoInstall

dom-delegate

Package Overview
Dependencies
0
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

origami.json

22

build/dom-delegate.js

@@ -184,2 +184,14 @@ (function(e){if("function"==typeof bootstrap)bootstrap("delegate",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeDelegate=e}else"undefined"!=typeof window?window.Delegate=e():global.Delegate=e()})(function(){var define,ses,bootstrap,module,exports;

matcher = matchesId;
} else if (/^\s*[>](.*)$/.test(selector)) {
matcherParam = RegExp.$1;
// COMPLEX - scopedDirectMatches needs to have access to
// this.rootElement, so bind the function to this.
matcher = scopedDirectMatches.bind(this);
} else if (/^\s*[&](.*)$/.test(selector)) {
matcherParam = RegExp.$1;
// COMPLEX - scopedMatches needs to have access to
// this.rootElement, so bind the function to this.
matcher = scopedMatches.bind(this);
} else {

@@ -409,2 +421,12 @@ matcherParam = selector;

function scopedDirectMatches(selector, element) {
/*jshint validthis:true*/
return Array.prototype.some.call(this.rootElement.children, function(el) { return el === element; }) && matches.call(element, selector, element);
}
function scopedMatches(selector, element) {
/*jshint validthis:true*/
return this.rootElement.contains(element) && matches.call(element, selector, element);
}
/**

@@ -411,0 +433,0 @@ * Check whether the ID of

2

build/dom-delegate.min.js

@@ -1,1 +0,1 @@

(function(e){if("function"==typeof bootstrap)bootstrap("delegate",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeDelegate=e}else"undefined"!=typeof window?window.Delegate=e():global.Delegate=e()})(function(){return function(e,t,r){function n(r,i){if(!t[r]){if(!e[r]){var s="function"==typeof require&&require;if(!i&&s)return s(r,!0);if(o)return o(r,!0);throw Error("Cannot find module '"+r+"'")}var a=t[r]={exports:{}};e[r][0].call(a.exports,function(t){var o=e[r][1][t];return n(o?o:t)},a,a.exports)}return t[r].exports}for(var o="function"==typeof require&&require,i=0;r.length>i;i++)n(r[i]);return n}({1:[function(e,t){(function(){"use strict";function e(t){this.listenerMap=[{},{}],t&&this.root(t),this.handle=e.prototype.handle.bind(this)}function r(e,t){return e.toLowerCase()===t.tagName.toLowerCase()}function n(e,t){return this.rootElement===window?t===document:this.rootElement===t}function o(e,t){return e===t.id}t.exports=e,e.prototype.root=function(e){var t,r=this.listenerMap;if("string"==typeof e&&(e=document.querySelector(e)),this.rootElement){for(t in r[1])r[1].hasOwnProperty(t)&&this.rootElement.removeEventListener(t,this.handle,!0);for(t in r[0])r[0].hasOwnProperty(t)&&this.rootElement.removeEventListener(t,this.handle,!1)}if(!e||!e.addEventListener)return this.rootElement&&delete this.rootElement,this;this.rootElement=e;for(t in r[1])r[1].hasOwnProperty(t)&&this.rootElement.addEventListener(t,this.handle,!0);for(t in r[0])r[0].hasOwnProperty(t)&&this.rootElement.addEventListener(t,this.handle,!1);return this},e.prototype.captureForType=function(e){return-1!==["error","blur","focus","scroll","resize"].indexOf(e)},e.prototype.on=function(e,t,s,a){var f,h,l,p;if(!e)throw new TypeError("Invalid event type: "+e);if("function"==typeof t&&(a=s,s=t,t=null),void 0===a&&(a=this.captureForType(e)),"function"!=typeof s)throw new TypeError("Handler must be a type of Function");return f=this.rootElement,h=this.listenerMap[a?1:0],h[e]||(f&&f.addEventListener(e,this.handle,a),h[e]=[]),t?/^[a-z]+$/i.test(t)?(p=t,l=r):/^#[a-z0-9\-_]+$/i.test(t)?(p=t.slice(1),l=o):(p=t,l=i):(p=null,l=n.bind(this)),h[e].push({selector:t,handler:s,matcher:l,matcherParam:p}),this},e.prototype.off=function(e,t,r,n){var o,i,s,a,f;if("function"==typeof t&&(n=r,r=t,t=null),void 0===n)return this.off(e,t,r,!0),this.off(e,t,r,!1),this;if(s=this.listenerMap[n?1:0],!e){for(f in s)s.hasOwnProperty(f)&&this.off(f,t,r);return this}if(a=s[e],!a||!a.length)return this;for(o=a.length-1;o>=0;o--)i=a[o],t&&t!==i.selector||r&&r!==i.handler||a.splice(o,1);return a.length||(delete s[e],this.rootElement&&this.rootElement.removeEventListener(e,this.handle,n)),this},e.prototype.handle=function(e){var t,r,n,o,i,s,a=e.type,f=[],h="ftLabsDelegateIgnore";if(e[h]!==!0){switch(s=e.target,s.nodeType===Node.TEXT_NODE&&(s=s.parentNode),n=this.rootElement,e.eventPhase){case Event.CAPTURING_PHASE:f=this.listenerMap[1][a];break;case Event.AT_TARGET:this.listenerMap[0]&&this.listenerMap[0][a]&&(f=f.concat(this.listenerMap[0][a])),this.listenerMap[1]&&this.listenerMap[1][a]&&(f=f.concat(this.listenerMap[1][a]));break;case Event.BUBBLING_PHASE:f=this.listenerMap[0][a]}for(r=f.length;s&&r;){for(t=0;r>t&&(o=f[t],o);t++)if(o.matcher.call(s,o.matcherParam,s)&&(i=this.fire(e,s,o)),i===!1)return e[h]=!0,e.preventDefault(),void 0;if(s===n)break;r=f.length,s=s.parentElement}}},e.prototype.fire=function(e,t,r){return r.handler.call(t,e,t)};var i=function(e){if(e){var t=e.prototype;return t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector}}(Element);e.prototype.destroy=function(){this.off(),this.root()}})()},{}]},{},[1])(1)});
(function(e){if("function"==typeof bootstrap)bootstrap("delegate",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeDelegate=e}else"undefined"!=typeof window?window.Delegate=e():global.Delegate=e()})(function(){return function(e,t,r){function n(r,i){if(!t[r]){if(!e[r]){var s="function"==typeof require&&require;if(!i&&s)return s(r,!0);if(o)return o(r,!0);throw Error("Cannot find module '"+r+"'")}var a=t[r]={exports:{}};e[r][0].call(a.exports,function(t){var o=e[r][1][t];return n(o?o:t)},a,a.exports)}return t[r].exports}for(var o="function"==typeof require&&require,i=0;r.length>i;i++)n(r[i]);return n}({1:[function(e,t){(function(){"use strict";function e(t){this.listenerMap=[{},{}],t&&this.root(t),this.handle=e.prototype.handle.bind(this)}function r(e,t){return e.toLowerCase()===t.tagName.toLowerCase()}function n(e,t){return this.rootElement===window?t===document:this.rootElement===t}function o(e,t){return Array.prototype.some.call(this.rootElement.children,function(e){return e===t})&&a.call(t,e,t)}function i(e,t){return this.rootElement.contains(t)&&a.call(t,e,t)}function s(e,t){return e===t.id}t.exports=e,e.prototype.root=function(e){var t,r=this.listenerMap;if("string"==typeof e&&(e=document.querySelector(e)),this.rootElement){for(t in r[1])r[1].hasOwnProperty(t)&&this.rootElement.removeEventListener(t,this.handle,!0);for(t in r[0])r[0].hasOwnProperty(t)&&this.rootElement.removeEventListener(t,this.handle,!1)}if(!e||!e.addEventListener)return this.rootElement&&delete this.rootElement,this;this.rootElement=e;for(t in r[1])r[1].hasOwnProperty(t)&&this.rootElement.addEventListener(t,this.handle,!0);for(t in r[0])r[0].hasOwnProperty(t)&&this.rootElement.addEventListener(t,this.handle,!1);return this},e.prototype.captureForType=function(e){return-1!==["error","blur","focus","scroll","resize"].indexOf(e)},e.prototype.on=function(e,t,l,h){var f,u,c,p;if(!e)throw new TypeError("Invalid event type: "+e);if("function"==typeof t&&(h=l,l=t,t=null),void 0===h&&(h=this.captureForType(e)),"function"!=typeof l)throw new TypeError("Handler must be a type of Function");return f=this.rootElement,u=this.listenerMap[h?1:0],u[e]||(f&&f.addEventListener(e,this.handle,h),u[e]=[]),t?/^[a-z]+$/i.test(t)?(p=t,c=r):/^#[a-z0-9\-_]+$/i.test(t)?(p=t.slice(1),c=s):/^\s*[>](.*)$/.test(t)?(p=RegExp.$1,c=o.bind(this)):/^\s*[&](.*)$/.test(t)?(p=RegExp.$1,c=i.bind(this)):(p=t,c=a):(p=null,c=n.bind(this)),u[e].push({selector:t,handler:l,matcher:c,matcherParam:p}),this},e.prototype.off=function(e,t,r,n){var o,i,s,a,l;if("function"==typeof t&&(n=r,r=t,t=null),void 0===n)return this.off(e,t,r,!0),this.off(e,t,r,!1),this;if(s=this.listenerMap[n?1:0],!e){for(l in s)s.hasOwnProperty(l)&&this.off(l,t,r);return this}if(a=s[e],!a||!a.length)return this;for(o=a.length-1;o>=0;o--)i=a[o],t&&t!==i.selector||r&&r!==i.handler||a.splice(o,1);return a.length||(delete s[e],this.rootElement&&this.rootElement.removeEventListener(e,this.handle,n)),this},e.prototype.handle=function(e){var t,r,n,o,i,s,a=e.type,l=[],h="ftLabsDelegateIgnore";if(e[h]!==!0){switch(s=e.target,s.nodeType===Node.TEXT_NODE&&(s=s.parentNode),n=this.rootElement,e.eventPhase){case Event.CAPTURING_PHASE:l=this.listenerMap[1][a];break;case Event.AT_TARGET:this.listenerMap[0]&&this.listenerMap[0][a]&&(l=l.concat(this.listenerMap[0][a])),this.listenerMap[1]&&this.listenerMap[1][a]&&(l=l.concat(this.listenerMap[1][a]));break;case Event.BUBBLING_PHASE:l=this.listenerMap[0][a]}for(r=l.length;s&&r;){for(t=0;r>t&&(o=l[t],o);t++)if(o.matcher.call(s,o.matcherParam,s)&&(i=this.fire(e,s,o)),i===!1)return e[h]=!0,e.preventDefault(),void 0;if(s===n)break;r=l.length,s=s.parentElement}}},e.prototype.fire=function(e,t,r){return r.handler.call(t,e,t)};var a=function(e){if(e){var t=e.prototype;return t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector}}(Element);e.prototype.destroy=function(){this.off(),this.root()}})()},{}]},{},[1])(1)});

@@ -28,8 +28,7 @@ module.exports = function(grunt) {

all: [
'Gruntfile.js',
'*.js',
'lib/**/*.js',
'test/*.js',
'test/**/*.js',
'bower.json',
'package.json'
'test/tests/*.js',
'*.json'
]

@@ -36,0 +35,0 @@ }

@@ -273,3 +273,3 @@ /*jshint browser:true, node:true*/

Delegate.prototype.handle = function(event) {
var i, l, type = event.type, root, listener, returned, listenerList = [], target, /** @const */ EVENTIGNORE = 'ftLabsDelegateIgnore';
var i, l, type = event.type, root, phase, listener, returned, listenerList = [], target, /** @const */ EVENTIGNORE = 'ftLabsDelegateIgnore';

@@ -281,3 +281,6 @@ if (event[EVENTIGNORE] === true) {

target = event.target;
if (target.nodeType === Node.TEXT_NODE) {
// Hardcode value of Node.TEXT_NODE
// as not defined in IE8
if (target.nodeType === 3) {
target = target.parentNode;

@@ -288,11 +291,13 @@ }

switch (event.eventPhase) {
case Event.CAPTURING_PHASE:
phase = event.eventPhase || ( event.target !== event.currentTarget ? 3 : 2 );
switch (phase) {
case 1: //Event.CAPTURING_PHASE:
listenerList = this.listenerMap[1][type];
break;
case Event.AT_TARGET:
case 2: //Event.AT_TARGET:
if (this.listenerMap[0] && this.listenerMap[0][type]) listenerList = listenerList.concat(this.listenerMap[0][type]);
if (this.listenerMap[1] && this.listenerMap[1][type]) listenerList = listenerList.concat(this.listenerMap[1][type]);
break;
case Event.BUBBLING_PHASE:
case 3: //Event.BUBBLING_PHASE:
listenerList = this.listenerMap[0][type];

@@ -299,0 +304,0 @@ break;

{
"name": "dom-delegate",
"version": "2.0.0",
"version": "2.0.1",
"author": "FT Labs <enquiries@labs.ft.com> (http://labs.ft.com/)",

@@ -5,0 +5,0 @@ "description": "Create and manage a DOM event delegator.",

@@ -23,2 +23,4 @@ # ftdomdelegate [![Build Status](https://travis-ci.org/ftlabs/ftdomdelegate.svg?branch=master)](https://travis-ci.org/ftlabs/ftdomdelegate)

When combined with a good [event listener polyfill](https://github.com/jonathantneal/EventListener) the library can be used in Internet Explorer 8 for events that bubble natively.
## Installation ##

@@ -25,0 +27,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc