diff --git a/bower.json b/bower.json index 983b98c..229088d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jbone", - "version": "1.2.0", + "version": "1.2.1", "description": "Library for DOM manipulation", "main": "dist/jbone.js", "homepage": "http://jbone.js.org", diff --git a/component.json b/component.json index ad5e18a..78e1dde 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "jbone", "repo": "kupriyanenko/jbone", "description": "JavaScript Library for DOM manipulation. Replacement jQuery for Backbone in browsers (2.5kb gzipped)", - "version": "1.2.0", + "version": "1.2.1", "keywords": [ "jquery", "jbone", diff --git a/dist/jbone.js b/dist/jbone.js index 327e3f9..c336341 100644 --- a/dist/jbone.js +++ b/dist/jbone.js @@ -1,9 +1,9 @@ /*! - * jBone v1.2.0 - 2016-04-13 - Library for DOM manipulation + * jBone v1.2.1 - 2017-09-19 - Library for DOM manipulation * * http://jbone.js.org * - * Copyright 2016 Alexey Kupriyanenko + * Copyright 2017 Alexey Kupriyanenko * Released under the MIT license. */ @@ -27,7 +27,7 @@ splice = [].splice, keys = Object.keys, // Alias for global variables -doc = document, +doc = win.document, isString = function(el) { return typeof el === "string"; @@ -1059,4 +1059,4 @@ else if (typeof define === "function" && define.amd) { win.jBone = win.$ = jBone; } -}(window)); +}(typeof window !== "undefined" ? window : this)); diff --git a/dist/jbone.min.js b/dist/jbone.min.js index 3451ab2..9f92bf3 100644 --- a/dist/jbone.min.js +++ b/dist/jbone.min.js @@ -1,10 +1,10 @@ /*! - * jBone v1.2.0 - 2016-04-13 - Library for DOM manipulation + * jBone v1.2.1 - 2017-09-19 - Library for DOM manipulation * * http://jbone.js.org * - * Copyright 2016 Alexey Kupriyanenko + * Copyright 2017 Alexey Kupriyanenko * Released under the MIT license. */ -!function(a){function b(b){var c=b.length,d=typeof b;return o(d)||b===a?!1:1===b.nodeType&&c?!0:p(d)||0===c||"number"==typeof c&&c>0&&c-1 in b}function c(a,b){var c,d;this.originalEvent=a,d=function(a,b){"preventDefault"===a?this[a]=function(){return this.defaultPrevented=!0,b[a]()}:"stopImmediatePropagation"===a?this[a]=function(){return this.immediatePropagationStopped=!0,b[a]()}:o(b[a])?this[a]=function(){return b[a]()}:this[a]=b[a]};for(c in a)(a[c]||"function"==typeof a[c])&&d.call(this,c,a);q.extend(this,b,{isImmediatePropagationStopped:function(){return!!this.immediatePropagationStopped}})}var d,e=a.$,f=a.jBone,g=/^<(\w+)\s*\/?>$/,h=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,i=[].slice,j=[].splice,k=Object.keys,l=document,m=function(a){return"string"==typeof a},n=function(a){return a instanceof Object},o=function(a){return"[object Function]"==={}.toString.call(a)},p=function(a){return Array.isArray(a)},q=function(a,b){return new d.init(a,b)};q.noConflict=function(){return a.$=e,a.jBone=f,q},d=q.fn=q.prototype={init:function(a,b){var c,d,e,f;if(!a)return this;if(m(a)){if(d=g.exec(a))return this[0]=l.createElement(d[1]),this.length=1,n(b)&&this.attr(b),this;if((d=h.exec(a))&&d[1]){for(f=l.createDocumentFragment(),e=l.createElement("div"),e.innerHTML=a;e.lastChild;)f.appendChild(e.firstChild);return c=i.call(f.childNodes),q.merge(this,c)}if(q.isElement(b))return q(b).find(a);try{return c=l.querySelectorAll(a),q.merge(this,c)}catch(j){return this}}return a.nodeType?(this[0]=a,this.length=1,this):o(a)?a():a instanceof q?a:q.makeArray(a,this)},pop:[].pop,push:[].push,reverse:[].reverse,shift:[].shift,sort:[].sort,splice:[].splice,slice:[].slice,indexOf:[].indexOf,forEach:[].forEach,unshift:[].unshift,concat:[].concat,join:[].join,every:[].every,some:[].some,filter:[].filter,map:[].map,reduce:[].reduce,reduceRight:[].reduceRight,length:0},d.constructor=q,d.init.prototype=d,q.setId=function(b){var c=b.jid;b===a?c="window":void 0===b.jid&&(b.jid=c=++q._cache.jid),q._cache.events[c]||(q._cache.events[c]={})},q.getData=function(b){b=b instanceof q?b[0]:b;var c=b===a?"window":b.jid;return{jid:c,events:q._cache.events[c]}},q.isElement=function(a){return a&&a instanceof q||a instanceof HTMLElement||m(a)},q._cache={events:{},jid:0},d.pushStack=function(a){var b=q.merge(this.constructor(),a);return b},q.merge=function(a,b){for(var c=b.length,d=a.length,e=0;c>e;)a[d++]=b[e++];return a.length=d,a},q.contains=function(a,b){return a.contains(b)},q.extend=function(a){var b;return j.call(arguments,1).forEach(function(c){if(b=a,c)for(var d in c)b[d]=c[d]}),a},q.makeArray=function(a,c){var d=c||[];return null!==a&&(b(a)?q.merge(d,m(a)?[a]:a):d.push(a)),d},q.unique=function(a){if(null==a)return[];for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c];b.indexOf(e)<0&&b.push(e)}return b},q.Event=function(a,b){var c,d;return a.type&&!b&&(b=a,a=a.type),c=a.split(".").splice(1).join("."),d=a.split(".")[0],a=l.createEvent("Event"),a.initEvent(d,!0,!0),q.extend(a,{namespace:c,isDefaultPrevented:function(){return a.defaultPrevented}},b)},q.event={add:function(a,b,c,d,e){q.setId(a);var f,g,h,i=function(b){q.event.dispatch.call(a,b)},j=q.getData(a).events;for(b=b.split(" "),g=b.length;g--;)h=b[g],f=h.split(".")[0],j[f]=j[f]||[],j[f].length?i=j[f][0].fn:a.addEventListener&&a.addEventListener(f,i,!1),j[f].push({namespace:h.split(".").splice(1).join("."),fn:i,selector:e,data:d,originfn:c})},remove:function(a,b,c,d){var e,f,g=function(a,b,d,e,f){var g;(c&&f.originfn===c||!c)&&(g=f.fn),a[b][d].fn===g&&(a[b].splice(d,1),a[b].length||e.removeEventListener(b,g))},h=q.getData(a).events;if(h)return!b&&h?k(h).forEach(function(b){for(f=h[b],e=f.length;e--;)g(h,b,e,a,f[e])}):void b.split(" ").forEach(function(b){var c,i=b.split(".")[0],j=b.split(".").splice(1).join(".");if(h[i])for(f=h[i],e=f.length;e--;)c=f[e],(!j||j&&c.namespace===j)&&(!d||d&&c.selector===d)&&g(h,i,e,a,c);else j&&k(h).forEach(function(b){for(f=h[b],e=f.length;e--;)c=f[e],c.namespace.split(".")[0]===j.split(".")[0]&&g(h,b,e,a,c)})})},trigger:function(a,b){var c=[];m(b)?c=b.split(" ").map(function(a){return q.Event(a)}):(b=b instanceof Event?b:q.Event(b),c=[b]),c.forEach(function(b){b.type&&a.dispatchEvent&&a.dispatchEvent(b)})},dispatch:function(a){for(var b,d,e,f,g,h=0,i=0,j=this,k=q.getData(j).events[a.type],l=k.length,m=[],n=[];l>h;h++)m.push(k[h]);for(h=0,l=m.length;l>h&&~k.indexOf(m[h])&&(!f||!f.isImmediatePropagationStopped());h++)if(d=null,g={},e=m[h],e.data&&(g.data=e.data),e.selector){if(~(n=q(j).find(e.selector)).indexOf(a.target)&&(d=a.target)||j!==a.target&&j.contains(a.target)){if(!d)for(b=n.length,i=0;b>i;i++)n[i]&&n[i].contains(a.target)&&(d=n[i]);if(!d)continue;g.currentTarget=d,f=new c(a,g),a.namespace&&a.namespace!==e.namespace||e.originfn.call(d,f)}}else f=new c(a,g),a.namespace&&a.namespace!==e.namespace||e.originfn.call(j,f)}},d.on=function(a,b,c,d){var e=this.length,f=0;if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),!d)return this;for(;e>f;f++)q.event.add(this[f],a,d,c,b);return this},d.one=function(a){var b,c=arguments,d=0,e=this.length,f=i.call(c,1,c.length-1),g=i.call(c,-1)[0];for(b=function(b){var c=q(b);a.split(" ").forEach(function(a){var d=function(e){c.off(a,d),g.call(b,e)};c.on.apply(c,[a].concat(f,d))})};e>d;d++)b(this[d]);return this},d.trigger=function(a){var b=0,c=this.length;if(!a)return this;for(;c>b;b++)q.event.trigger(this[b],a);return this},d.off=function(a,b,c){var d=0,e=this.length;for(o(b)&&(c=b,b=void 0);e>d;d++)q.event.remove(this[d],a,c,b);return this},d.find=function(a){for(var b=[],c=0,d=this.length,e=function(c){o(c.querySelectorAll)&&[].forEach.call(c.querySelectorAll(a),function(a){b.push(a)})};d>c;c++)e(this[c]);return q(b)},d.get=function(a){return null!=a?0>a?this[a+this.length]:this[a]:i.call(this)},d.eq=function(a){return q(this[a])},d.parent=function(){for(var a,b=[],c=0,d=this.length;d>c;c++)!~b.indexOf(a=this[c].parentElement)&&a&&b.push(a);return q(b)},d.toArray=function(){return i.call(this)},d.is=function(){var a=arguments;return this.some(function(b){return b.tagName.toLowerCase()===a[0]})},d.has=function(){var a=arguments;return this.some(function(b){return b.querySelectorAll(a[0]).length})},d.add=function(a,b){return this.pushStack(q.unique(q.merge(this.get(),q(a,b))))},d.attr=function(a,b){var c,d=arguments,e=0,f=this.length;if(m(a)&&1===d.length)return this[0]&&this[0].getAttribute(a);for(2===d.length?c=function(c){c.setAttribute(a,b)}:n(a)&&(c=function(b){k(a).forEach(function(c){b.setAttribute(c,a[c])})});f>e;e++)c(this[e]);return this},d.removeAttr=function(a){for(var b=0,c=this.length;c>b;b++)this[b].removeAttribute(a);return this},d.val=function(a){var b=0,c=this.length;if(0===arguments.length)return this[0]&&this[0].value;for(;c>b;b++)this[b].value=a;return this},d.css=function(b,c){var d,e=arguments,f=0,g=this.length;if(m(b)&&1===e.length)return this[0]&&a.getComputedStyle(this[0])[b];for(2===e.length?d=function(a){a.style[b]=c}:n(b)&&(d=function(a){k(b).forEach(function(c){a.style[c]=b[c]})});g>f;f++)d(this[f]);return this},d.data=function(a,b){var c,d=arguments,e={},f=0,g=this.length,h=function(a,b,c){n(c)?(a.jdata=a.jdata||{},a.jdata[b]=c):a.dataset[b]=c},i=function(a){return"true"===a?!0:"false"===a?!1:a};if(0===d.length)return this[0].jdata&&(e=this[0].jdata),k(this[0].dataset).forEach(function(a){e[a]=i(this[0].dataset[a])},this),e;if(1===d.length&&m(a))return this[0]&&i(this[0].dataset[a]||this[0].jdata&&this[0].jdata[a]);for(1===d.length&&n(a)?c=function(b){k(a).forEach(function(c){h(b,c,a[c])})}:2===d.length&&(c=function(c){h(c,a,b)});g>f;f++)c(this[f]);return this},d.removeData=function(a){for(var b,c,d=0,e=this.length;e>d;d++)if(b=this[d].jdata,c=this[d].dataset,a)b&&b[a]&&delete b[a],delete c[a];else{for(a in b)delete b[a];for(a in c)delete c[a]}return this},d.addClass=function(a){for(var b=0,c=0,d=this.length,e=a?a.trim().split(/\s+/):[];d>b;b++)for(c=0,c=0;cb;b++)for(c=0,c=0;cc;c++)this[c].classList[e](a);return this},d.hasClass=function(a){var b=0,c=this.length;if(a)for(;c>b;b++)if(this[b].classList.contains(a))return!0;return!1},d.html=function(a){var b,c=arguments;return 1===c.length&&void 0!==a?this.empty().append(a):0===c.length&&(b=this[0])?b.innerHTML:this},d.append=function(a){var b,c=0,d=this.length;for(m(a)&&h.exec(a)?a=q(a):n(a)||(a=document.createTextNode(a)),a=a instanceof q?a:q(a),b=function(b,c){a.forEach(function(a){c?b.appendChild(a.cloneNode(!0)):b.appendChild(a)})};d>c;c++)b(this[c],c);return this},d.appendTo=function(a){return q(a).append(this),this},d.empty=function(){for(var a,b=0,c=this.length;c>b;b++)for(a=this[b];a.lastChild;)a.removeChild(a.lastChild);return this},d.remove=function(){var a,b=0,c=this.length;for(this.off();c>b;b++)a=this[b],delete a.jdata,a.parentNode&&a.parentNode.removeChild(a);return this},"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=q:"function"==typeof define&&define.amd?(define(function(){return q}),a.jBone=a.$=q):"object"==typeof a&&"object"==typeof a.document&&(a.jBone=a.$=q)}(window); \ No newline at end of file +!function(a){function b(b){var c=b.length,d=typeof b;return!o(d)&&b!==a&&(!(1!==b.nodeType||!c)||(p(d)||0===c||"number"==typeof c&&c>0&&c-1 in b))}function c(a,b){var c,d;this.originalEvent=a,d=function(a,b){"preventDefault"===a?this[a]=function(){return this.defaultPrevented=!0,b[a]()}:"stopImmediatePropagation"===a?this[a]=function(){return this.immediatePropagationStopped=!0,b[a]()}:o(b[a])?this[a]=function(){return b[a]()}:this[a]=b[a]};for(c in a)(a[c]||"function"==typeof a[c])&&d.call(this,c,a);q.extend(this,b,{isImmediatePropagationStopped:function(){return!!this.immediatePropagationStopped}})}var d,e=a.$,f=a.jBone,g=/^<(\w+)\s*\/?>$/,h=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,i=[].slice,j=[].splice,k=Object.keys,l=a.document,m=function(a){return"string"==typeof a},n=function(a){return a instanceof Object},o=function(a){return"[object Function]"==={}.toString.call(a)},p=function(a){return Array.isArray(a)},q=function(a,b){return new d.init(a,b)};q.noConflict=function(){return a.$=e,a.jBone=f,q},d=q.fn=q.prototype={init:function(a,b){var c,d,e,f;if(!a)return this;if(m(a)){if(d=g.exec(a))return this[0]=l.createElement(d[1]),this.length=1,n(b)&&this.attr(b),this;if((d=h.exec(a))&&d[1]){for(f=l.createDocumentFragment(),e=l.createElement("div"),e.innerHTML=a;e.lastChild;)f.appendChild(e.firstChild);return c=i.call(f.childNodes),q.merge(this,c)}if(q.isElement(b))return q(b).find(a);try{return c=l.querySelectorAll(a),q.merge(this,c)}catch(a){return this}}return a.nodeType?(this[0]=a,this.length=1,this):o(a)?a():a instanceof q?a:q.makeArray(a,this)},pop:[].pop,push:[].push,reverse:[].reverse,shift:[].shift,sort:[].sort,splice:[].splice,slice:[].slice,indexOf:[].indexOf,forEach:[].forEach,unshift:[].unshift,concat:[].concat,join:[].join,every:[].every,some:[].some,filter:[].filter,map:[].map,reduce:[].reduce,reduceRight:[].reduceRight,length:0},d.constructor=q,d.init.prototype=d,q.setId=function(b){var c=b.jid;b===a?c="window":void 0===b.jid&&(b.jid=c=++q._cache.jid),q._cache.events[c]||(q._cache.events[c]={})},q.getData=function(b){b=b instanceof q?b[0]:b;var c=b===a?"window":b.jid;return{jid:c,events:q._cache.events[c]}},q.isElement=function(a){return a&&a instanceof q||a instanceof HTMLElement||m(a)},q._cache={events:{},jid:0},d.pushStack=function(a){return q.merge(this.constructor(),a)},q.merge=function(a,b){for(var c=b.length,d=a.length,e=0;e