Skip to content

Commit

Permalink
make the only dependency have a fixed version for security reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
gmrchk committed Dec 16, 2018
1 parent 0008882 commit 9deea75
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 42 deletions.
36 changes: 1 addition & 35 deletions dist/swup.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ var closest = __webpack_require__(5);
* @param {Boolean} useCapture
* @return {Object}
*/
function _delegate(element, selector, type, callback, useCapture) {
function delegate(element, selector, type, callback, useCapture) {
var listenerFn = listener.apply(this, arguments);

element.addEventListener(type, listenerFn, useCapture);
Expand All @@ -762,40 +762,6 @@ function _delegate(element, selector, type, callback, useCapture) {
}
}

/**
* Delegates event to a selector.
*
* @param {Element|String|Array} [elements]
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @param {Boolean} useCapture
* @return {Object}
*/
function delegate(elements, selector, type, callback, useCapture) {
// Handle the regular Element usage
if (typeof elements.addEventListener === 'function') {
return _delegate.apply(null, arguments);
}

// Handle Element-less usage, it defaults to global delegation
if (typeof type === 'function') {
// Use `document` as the first parameter, then apply arguments
// This is a short way to .unshift `arguments` without running into deoptimizations
return _delegate.bind(null, document).apply(null, arguments);
}

// Handle Selector-based usage
if (typeof elements === 'string') {
elements = document.querySelectorAll(elements);
}

// Handle Array-like based usage
return Array.prototype.map.call(elements, function (element) {
return _delegate(element, selector, type, callback, useCapture);
});
}

/**
* Finds closest match and invokes callback.
*
Expand Down
Loading

0 comments on commit 9deea75

Please sign in to comment.