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

ak-delegate

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ak-delegate - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

karma-coverage.conf.js

62

index.js

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

'use strict';
/**
* polyfill CSS matchesSelector()
*/
var matchSelector;
var prototype = Element.prototype;
if (prototype.webkitMatchesSelector) {
matchSelector = 'webkitMatchesSelector';
} else if (prototype.mozMatchesSelector) {
matchSelector = 'mozMatchesSelector';
} else if (prototype.msMatchesSelector) {
matchSelector = 'msMatchesSelector';
} else {
matchSelector = 'matchesSelector';
}
/**
* Export `off`
*
* @param {HTMLElement} el
* @param {String} selector
* @param {String} event
* @param {Function} callback
* @param {Boolean} capture (optional)
* @return {Function} use it to undelegate
*/
module.exports.on = function (el, selector, event, callback, capture) {
if (event === 'focus' || event === 'blur') {
capture = true;
}
var fn = function (e) {
if (! e.target[matchSelector](selector) || e.type !== event) {
return;
}
callback(e);
};
el.addEventListener(event, fn, capture || false);
return fn;
};
/**
* Export `off`
*
* @param {HTMLElement} el
* @param {String} event
* @param {Function} callback
* @param {Boolean} capture (optional)
*/
module.exports.off = function (el, event, callback, capture) {
if (event === 'focus' || event === 'blur') {
capture = true;
}
el.removeEventListener(event, callback, capture || false);
};
module.exports = process.env.TEST_COVERAGE ? require('./lib-cov/delegate') : require('./lib/delegate');

@@ -48,3 +48,2 @@ // Karma configuration

// Start these browsers, currently available:

@@ -51,0 +50,0 @@ // - Chrome

{
"name": "ak-delegate",
"version": "0.0.2",
"version": "0.0.3",
"description": "dom event delegation",

@@ -26,12 +26,15 @@ "keywords": [

"engines": {
"node": "~0.10.22"
"node": "~0.10.24"
},
"dependencies": {},
"devDependencies": {
"browserify": "~2.35.4",
"karma": "~0.10.8",
"browserify": "~3.12.0",
"karma": "~0.11.9",
"karma-mocha": "~0.1.1",
"karma-safari-launcher": "~0.1.1",
"karma-firefox-launcher": "~0.1.2"
"karma-firefox-launcher": "~0.1.2",
"envify": "~1.0.1",
"karma-coverage": "~0.1.4",
"istanbul": "~0.2.1"
}
}

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

/*global describe, it, FocusEvent*/
/*global describe, it*/

@@ -59,6 +59,18 @@ 'use strict';

var input = document.querySelector('.l-3 input');
input.dispatchEvent(new FocusEvent('focus'));
input.dispatchEvent(new FocusEvent('blur'));
// TODO use `input.focus();` when retarded Firefox & IE will handle it
var e = document.createEvent('HTMLEvents');
e.initEvent('focus', true, true);
input.dispatchEvent(e);
// TODO use `input.blur();` when retarded Firefox & IE will handle it
e = document.createEvent('HTMLEvents');
e.initEvent('blur', true, true);
input.dispatchEvent(e);
delegate.off(document.body, 'focus', fn);
input.dispatchEvent(new FocusEvent('focus'));
// TODO use `input.focus();` when retarded Firefox & IE will handle it
e = document.createEvent('HTMLEvents');
e.initEvent('focus', true, true);
input.dispatchEvent(e);
});

@@ -114,2 +126,12 @@

});
it('#on(".d-2 .l-3"), #click(".l-4")', function (done) {
var d2 = document.body.querySelector('.d-2');
delegate.on(d2, '.l-3', 'click', function () {
done();
});
document.querySelector('.d-2 .l-4').click();
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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