From aae23fa7886e84cbbb3cdb37479aaa6bd1909d9c Mon Sep 17 00:00:00 2001 From: Fabio Spampinato Date: Fri, 18 May 2018 17:27:04 +0200 Subject: [PATCH] Bumped version to 2.1.6 --- dist/cash.js | 5 ++++- dist/cash.min.js | 14 +++++++------- package.json | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/dist/cash.js b/dist/cash.js index 1d899600..f4fb0612 100644 --- a/dist/cash.js +++ b/dist/cash.js @@ -645,6 +645,7 @@ fn.on = function (eventFullName, selector, callback, _one) { _this2.each(function (i, ele) { var finalCallback = function finalCallback(event) { if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) return; + var thisArg = ele; if (selector) { var target = event.target; @@ -654,10 +655,12 @@ fn.on = function (eventFullName, selector, callback, _one) { target = target.parentNode; if (!target) return; } + + thisArg = target; } event.namespace = event.namespace || ''; - callback.call(ele, event, event.data); + callback.call(thisArg, event, event.data); if (_one) { removeEvent(ele, name, namespaces, finalCallback); diff --git a/dist/cash.min.js b/dist/cash.min.js index 7d8e329f..5062935f 100644 --- a/dist/cash.min.js +++ b/dist/cash.min.js @@ -1,13 +1,13 @@ /* MIT https://github.com/kenwheeler/cash */ (function(){ -'use strict';var e=document,h=window,k=Array.prototype,l=k.filter,m=k.indexOf,n=k.map,p=k.push,q=k.slice,r=/^#[\w-]*$/,t=/^\.[\w-]*$/,v=/<.+>/,aa=/^\w+$/;function w(a,b){if(a){if(a.__cash)return a;var c=a;if(x(a)){if(c=r.test(a)?e.getElementById(a.slice(1)):v.test(a)?y(a):z(a,b),!c)return}else if(A(a))return this.ready(a);if(c.nodeType||c===h)c=[c];this.length=c.length;a=0;for(b=this.length;a/,aa=/^\w+$/;function w(a,b){if(a){if(a.__cash)return a;var c=a;if(x(a)){if(c=t.test(a)?e.getElementById(a.slice(1)):v.test(a)?y(a):z(a,b),!c)return}else if(A(a))return this.ready(a);if(c.nodeType||c===h)c=[c];this.length=c.length;a=0;for(b=this.length;ac?0:1;darguments.length?this[0]&&this[0].getAttribute(a):this.each(function(c,f){f.setAttribute(a,b)});for(var c in a)this.attr(c,a[c]);return this}};B.hasClass=function(a){var b=L(a),c=!1;b.length&&this.each(function(a,f){c=f.classList.contains(b[0]);return!c});return c};B.prop=function(a,b){if(a){if(x(a))return 2>arguments.length?this[0]&&this[0][a]:this.each(function(c,f){f[a]=b});for(var c in a)this.prop(c,a[c]);return this}}; B.removeAttr=function(a){return this.each(function(b,c){c.removeAttribute(a)})};B.removeProp=function(a){return this.each(function(b,c){delete c[a]})};B.toggleClass=function(a,b){var c=L(a),d=void 0!==b;return c.length?this.each(function(a,g){E(c,function(a){d?b?g.classList.add(a):g.classList.remove(a):g.classList.toggle(a)})}):this};B.addClass=function(a){return this.toggleClass(a,!0)};B.removeClass=function(a){return arguments.length?this.toggleClass(a,!1):this.attr("class","")}; -B.get=function(a){return void 0===a?q.call(this):this[0>a?a+this.length:a]};B.eq=function(a){return cash(this.get(a))};B.filter=function(a){if(!a)return cash();var b=A(a)?a:K(a);return cash(l.call(this,function(c,d){return b.call(c,d,c,a)}))};B.first=function(){return this.eq(0)};B.last=function(){return this.eq(-1)};B.map=function(a){return cash(n.call(this,function(b,c){return a.call(b,c,b)}))};B.slice=function(){return cash(q.apply(this,arguments))}; +B.get=function(a){return void 0===a?r.call(this):this[0>a?a+this.length:a]};B.eq=function(a){return cash(this.get(a))};B.filter=function(a){if(!a)return cash();var b=A(a)?a:K(a);return cash(l.call(this,function(c,d){return b.call(c,d,c,a)}))};B.first=function(){return this.eq(0)};B.last=function(){return this.eq(-1)};B.map=function(a){return cash(p.call(this,function(b,c){return a.call(b,c,b)}))};B.slice=function(){return cash(r.apply(this,arguments))}; function N(a,b){a=h.getComputedStyle(a,null);return b?a[b]:a}function O(a,b){return parseInt(N(a,b),10)||0}var P={},ea=e.createElement("div").style,fa=["webkit","moz","ms","o"];function Q(a){if(!P[a]){var b=C(a),c=""+b.charAt(0).toUpperCase()+b.slice(1);b=(b+" "+fa.join(c+" ")+c).split(" ");E(b,function(b){if(b in ea)return P[a]=b,!1})}return P[a]}cash.prefixedProp=Q;var ha={columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0}; function R(a,b){return!ha[a]&&I(b)?b+"px":b}B.css=function(a,b){if(x(a)){a=Q(a);if(2>arguments.length)return this[0]&&N(this[0],a);b=R(a,b);return this.each(function(c,f){f.style[a]=b})}for(var c in a)this.css(c,a[c]);return this};function S(a){return a.__cashData=a.__cashData||{}}function ia(a,b){var c=S(a);if(!(b in c)){a=a.dataset?a.dataset[C(b)]:cash(a).attr("data-"+b);try{a=JSON.parse(a)}catch(d){}c[b]=a}return c[b]} B.data=function(a,b){if(x(a))return void 0===b?this[0]&&ia(this[0],a):this.each(function(c,f){S(f)[a]=b});for(var c in a)this.data(c,a[c]);return this};B.removeData=function(a){return this.each(function(b,c){void 0===a?delete c.__cashData:delete S(c)[a]})};function T(a,b){return O(a,"border"+(b?"Left":"Top")+"Width")+O(a,"padding"+(b?"Left":"Top"))+O(a,"padding"+(b?"Right":"Bottom"))+O(a,"border"+(b?"Right":"Bottom")+"Width")} @@ -15,15 +15,15 @@ E(["Width","Height"],function(a){B["inner"+a]=function(){return this[0]&&this[0] E(["Width","Height"],function(a,b){B["outer"+a]=function(c){if(this[0])return this[0]["offset"+a]+(c?O(this[0],"margin"+(b?"Top":"Left"))+O(this[0],"margin"+(b?"Bottom":"Right")):0)}});function U(a,b){for(var c=0,d=b.length;ca.indexOf(b[c]))return!1;return!0}function ja(a,b,c){E(a[c],function(a){b.removeEventListener(c,a[1])});delete a[c]}function ka(a,b,c,d){d.guid=d.guid||F++;var f=a.__cashEvents=a.__cashEvents||{};f[b]=f[b]||[];f[b].push([c,d]);a.addEventListener(b,d)} function V(a){a=a.split(".");return[a[0],a.slice(1).sort()]}function W(a,b,c,d){var f=a.__cashEvents=a.__cashEvents||{};if(b){var g=f[b];g&&(d&&(d.guid=d.guid||F++),f[b]=g.filter(function(f){var g=f[0];f=f[1];if(d&&f.guid!==d.guid||!U(g,c))return!0;a.removeEventListener(b,f)}))}else if(c&&c.length)for(b in f)W(a,b,c,d);else for(b in f)ja(f,a,b)} B.off=function(a,b){var c=this;void 0===a?this.each(function(a,b){return W(b)}):E(L(a),function(a){a=V(a);var d=a[0],g=a[1];c.each(function(a,c){return W(c,d,g,b)})});return this}; -B.on=function(a,b,c,d){var f=this;if(!x(a)){for(var g in a)this.on(g,b,a[g]);return this}A(b)&&(c=b,b=!1);E(L(a),function(a){a=V(a);var g=a[0],D=a[1];f.each(function(a,f){a=function la(a){if(!a.namespace||U(D,a.namespace.split("."))){if(b)for(var u=a.target;!G(u,b);){if(u===f)return;u=u.parentNode;if(!u)return}a.namespace=a.namespace||"";c.call(f,a,a.data);d&&W(f,g,D,la)}};a.guid=c.guid=c.guid||F++;ka(f,g,D,a)})});return this};B.one=function(a,b,c){return this.on(a,b,c,!0)}; +B.on=function(a,b,c,d){var f=this;if(!x(a)){for(var g in a)this.on(g,b,a[g]);return this}A(b)&&(c=b,b=!1);E(L(a),function(a){a=V(a);var g=a[0],D=a[1];f.each(function(a,f){a=function la(a){if(!a.namespace||U(D,a.namespace.split("."))){var m=f;if(b)for(m=a.target;!G(m,b);){if(m===f)return;m=m.parentNode;if(!m)return}a.namespace=a.namespace||"";c.call(m,a,a.data);d&&W(f,g,D,la)}};a.guid=c.guid=c.guid||F++;ka(f,g,D,a)})});return this};B.one=function(a,b,c){return this.on(a,b,c,!0)}; B.ready=function(a){"loading"!==e.readyState?setTimeout(a):e.addEventListener("DOMContentLoaded",a);return this};B.trigger=function(a,b){var c=a;if(x(a)){var d=V(a);a=d[0];d=d[1];c=e.createEvent("HTMLEvents");c.initEvent(a,!0,!0);c.namespace=d.join(".")}c.data=b;return this.each(function(a,b){b.dispatchEvent(c)})};var ma=/select-one/i,na=/select-multiple/i;function X(a){var b=a.type;return ma.test(b)?0>a.selectedIndex?null:a.options[a.selectedIndex].value:na.test(b)?oa(a):a.value} function oa(a){var b=[];E(a.options,function(a){a.selected&&b.push(a.value)});return b}var pa=/%20/g,qa=/file|reset|submit|button/i,ra=/radio|checkbox/i;B.serialize=function(){var a="";this[0]&&E(this[0].elements||this,function(b){if(!(b.disabled||"FIELDSET"===b.tagName||qa.test(b.type)||ra.test(b.type)&&!b.checked)){var c=X(b);c&&(c=J(c)?c:[c],E(c,function(c){var d=a;c="\x26"+encodeURIComponent(b.name)+"\x3d"+encodeURIComponent(c).replace(pa,"+");a=d+c}))}});return a.substr(1)}; B.val=function(a){return void 0===a?this[0]&&X(this[0]):this.each(function(b,c){c.value=a})};B.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};B.detach=function(){return this.each(function(a,b){b.parentNode.removeChild(b)})};function Y(a,b,c){var d=x(b);!d&&b.length?E(b,function(b){return Y(a,b,c)}):E(a,d?function(a){a.insertAdjacentHTML(c?"afterbegin":"beforeend",b)}:function(a,d){d=d?b.cloneNode(!0):b;c?a.insertBefore(d,a.childNodes[0]):a.appendChild(d)})} B.append=function(a){Y(this,a);return this};B.appendTo=function(a){Y(cash(a),this);return this};B.html=function(a){if(void 0===a)return this[0]&&this[0].innerHTML;var b=a.nodeType?a[0].outerHTML:a;return this.each(function(a,d){d.innerHTML=b})};B.empty=function(){return this.html("")};B.insertAfter=function(a){var b=this;cash(a).each(function(a,d){var c=d.parentNode;b.each(function(b,f){c.insertBefore(a?f.cloneNode(!0):f,d.nextSibling)})});return this}; B.after=function(a){cash(a).insertAfter(this);return this};B.insertBefore=function(a){var b=this;cash(a).each(function(a,d){var c=d.parentNode;b.each(function(b,f){c.insertBefore(a?f.cloneNode(!0):f,d)})});return this};B.before=function(a){cash(a).insertBefore(this);return this};B.prepend=function(a){Y(this,a,!0);return this};B.prependTo=function(a){Y(cash(a),this,!0);return this};B.remove=function(){return this.detach().off()}; B.replaceWith=function(a){var b=this;return this.each(function(c,d){if(c=d.parentNode){var f=cash(a);if(!f[0])return b.remove(),!1;c.replaceChild(f[0],d);cash(f[0]).after(f.slice(1))}})};B.replaceAll=function(a){cash(a).replaceWith(this);return this};B.text=function(a){return void 0===a?this[0]?this[0].textContent:"":this.each(function(b,c){c.textContent=a})};var Z=e.documentElement; -B.offset=function(){var a=this[0];if(a)return a=a.getBoundingClientRect(),{top:a.top+h.pageYOffset-Z.clientTop,left:a.left+h.pageXOffset-Z.clientLeft}};B.offsetParent=function(){return cash(this[0]&&this[0].offsetParent)};B.position=function(){var a=this[0];if(a)return{left:a.offsetLeft,top:a.offsetTop}};B.children=function(a){var b=[];this.each(function(a,d){p.apply(b,d.children)});b=cash(M(b));return a?b.filter(function(b,d){return G(d,a)}):b}; -B.find=function(a){for(var b=[],c=0,d=this.length;c