Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "jbone", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"ignore": [ | ||
@@ -5,0 +5,0 @@ "**/.*", |
@@ -5,3 +5,3 @@ { | ||
"description": "JavaScript Library for DOM manipulation. Replacement jQuery for Backbone in browsers (2.5kb gzipped)", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "jquery", |
/*! | ||
* jBone v1.0.7 - 2014-02-21 - Library for DOM manipulation | ||
* jBone v1.0.8 - 2014-04-06 - Library for DOM manipulation | ||
* | ||
@@ -727,4 +727,3 @@ * https://github.com/kupriyanenko/jbone | ||
delete jBone._cache.events[el.jid]; | ||
el.jdata = {}; | ||
delete el.jdata; | ||
el.parentNode && el.parentNode.removeChild(el); | ||
@@ -731,0 +730,0 @@ } |
/*! | ||
* jBone v1.0.7 - 2014-02-21 - Library for DOM manipulation | ||
* jBone v1.0.8 - 2014-04-06 - Library for DOM manipulation | ||
* | ||
@@ -10,2 +10,2 @@ * https://github.com/kupriyanenko/jbone | ||
!function(a){function b(a,b){var c,d;this.originalEvent=a,d=function(a,b){this[a]="preventDefault"===a?function(){return this.defaultPrevented=!0,b[a]()}:m(b[a])?function(){return b[a]()}:b[a]};for(c in a)(a.hasOwnProperty(c)||"function"==typeof a[c])&&d.call(this,c,a);n.extend(this,b)}var c=a.$,d=a.jBone,e=/^<(\w+)\s*\/?>$/,f=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,g=[].slice,h=[].splice,i=Object.keys,j=document,k=function(a){return"string"==typeof a},l=function(a){return a instanceof Object},m=function(a){return"function"==typeof a},n=function(a,b){return new n.fn.init(a,b)};n.noConflict=function(){return a.$=c,a.jBone=d,n},n.fn=n.prototype={init:function(a,b){var c,d,h,i;if(k(a)){if(d=e.exec(a))return this[0]=j.createElement(d[1]),this.length=1,l(b)&&this.attr(b),this;if((d=f.exec(a))&&d[1]){for(i=j.createDocumentFragment(),h=j.createElement("div"),h.innerHTML=a;h.lastChild;)i.appendChild(h.firstChild);return c=g.call(i.childNodes),n.merge(this,c)}if(n.isElement(b))return n(b).find(a);try{return c=g.call(j.querySelectorAll(a)),n.merge(this,c)}catch(o){return this}}else{if(m(a))return a();if(a instanceof n)return a;if(a)return a=Array.isArray(a)?a:[a],n.merge(this,a)}return 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},n.fn.constructor=n,n.fn.init.prototype=n.fn,n.setId=function(b){var c=b.jid;b===a?c="window":void 0===b.jid&&(b.jid=c=++n._cache.jid),n._cache.events[c]||(n._cache.events[c]={})},n.getData=function(b){b=b instanceof n?b[0]:b;var c=b===a?"window":b.jid;return{jid:c,events:n._cache.events[c]}},n.isElement=function(a){return a instanceof n||a instanceof HTMLElement||k(a)},n._cache={events:{},jid:0},n.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},n.contains=function(a,b){var c;return a.reverse().some(function(a){return a.contains(b)?c=a:void 0}),c},n.extend=function(a){var b,c,d,e;return h.call(arguments,1).forEach(function(f){if(f)for(b=i(f),c=b.length,d=0,e=a;c>d;d++)e[b[d]]=f[b[d]]}),a},n.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=j.createEvent("Event"),a.initEvent(d,!0,!0),n.extend(a,{namespace:c,isDefaultPrevented:function(){return a.defaultPrevented}},b)},n.fn.on=function(a){var c,d,e,f,g,h,i,j,k=arguments,l=this.length,m=0;for(2===k.length?c=k[1]:(d=k[1],c=k[2]),j=function(j){n.setId(j),g=n.getData(j).events,a.split(" ").forEach(function(a){h=a.split(".")[0],e=a.split(".").splice(1).join("."),g[h]=g[h]||[],f=function(a){a.namespace&&a.namespace!==e||(i=null,d?(~n(j).find(d).indexOf(a.target)||(i=n.contains(n(j).find(d),a.target)))&&(i=i||a.target,a=new b(a,{currentTarget:i}),c.call(i,a)):c.call(j,a))},g[h].push({namespace:e,fn:f,originfn:c}),j.addEventListener&&j.addEventListener(h,f,!1)})};l>m;m++)j(this[m]);return this},n.fn.one=function(a){var b,c,d,e=arguments,f=0,g=this.length;for(2===e.length?b=e[1]:(c=e[1],b=e[2]),d=function(d){a.split(" ").forEach(function(a){var e=function(c){n(d).off(a,e),b.call(d,c)};c?n(d).on(a,c,e):n(d).on(a,e)})};g>f;f++)d(this[f]);return this},n.fn.trigger=function(a){var b,c=[],d=0,e=this.length;if(!a)return this;for(k(a)?c=a.split(" ").map(function(a){return n.Event(a)}):(a=a instanceof Event?a:$.Event(a),c=[a]),b=function(a){c.forEach(function(b){b.type&&a.dispatchEvent&&a.dispatchEvent(b)})};e>d;d++)b(this[d]);return this},n.fn.off=function(a,b){var c,d,e,f,g=0,h=this.length,j=function(a,c,d,e,f){var g;(b&&f.originfn===b||!b)&&(g=f.fn),a[c][d].fn===g&&(e.removeEventListener(c,g),delete n._cache.events[n.getData(e).jid][c][d])};for(f=function(b){c=n.getData(b).events,c&&a.split(" ").forEach(function(a){e=a.split(".")[0],d=a.split(".").splice(1).join("."),c[e]?c[e].forEach(function(a,f){(!d||d&&a.namespace===d)&&j(c,e,f,b,a)}):d&&i(c).forEach(function(a){c[a].forEach(function(e,f){e.namespace.split(".")[0]===d.split(".")[0]&&j(c,a,f,b,e)})})})};h>g;g++)f(this[g]);return this},n.fn.find=function(a){var b,c=[],d=0,e=this.length;for(b=function(b){m(b.querySelectorAll)&&[].forEach.call(b.querySelectorAll(a),function(a){c.push(a)})};e>d;d++)b(this[d]);return n(c)},n.fn.get=function(a){return this[a]},n.fn.eq=function(a){return n(this[a])},n.fn.parent=function(){var a,b=[];return this.forEach(function(c){!~b.indexOf(a=c.parentElement)&&a&&b.push(a)}),n(b)},n.fn.toArray=function(){return g.call(this)},n.fn.is=function(){var a=arguments;return this.some(function(b){return b.tagName.toLowerCase()===a[0]})},n.fn.has=function(){var a=arguments;return this.some(function(b){return b.querySelectorAll(a[0]).length})},n.fn.attr=function(a,b){var c,d=arguments,e=0,f=this.length;if(k(a)&&1===d.length)return this[0].getAttribute(a);for(2===d.length?c=function(c){c.setAttribute(a,b)}:l(a)&&(c=function(b){i(a).forEach(function(c){b.setAttribute(c,a[c])})});f>e;e++)c(this[e]);return this},n.fn.val=function(a){var b=0,c=this.length;if(0===arguments.length)return this[0].value;for(;c>b;b++)this[b].value=a;return this},n.fn.css=function(b,c){var d,e=arguments,f=0,g=this.length;if(k(b)&&1===e.length)return a.getComputedStyle(this[0])[b];for(2===e.length?d=function(a){a.style[b]=c}:l(b)&&(d=function(a){i(b).forEach(function(c){a.style[c]=b[c]})});g>f;f++)d(this[f]);return this},n.fn.data=function(a,b){var c,d=arguments,e={},f=0,g=this.length,h=function(a,b,c){l(c)?(a.jdata=a.jdata||{},a.jdata[b]=c):a.dataset[b]=c},j=function(a){return"true"===a?!0:"false"===a?!1:a};if(0===d.length)return this[0].jdata&&(e=this[0].jdata),i(this[0].dataset).forEach(function(a){e[a]=j(this[0].dataset[a])},this),e;if(1===d.length&&k(a))return j(this[0].dataset[a]||this[0].jdata&&this[0].jdata[a]);for(1===d.length&&l(a)?c=function(b){i(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},n.fn.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},n.fn.append=function(a){var b,c=0,d=this.length;for(k(a)&&f.exec(a)?a=n(a):l(a)||(a=document.createTextNode(a)),a instanceof n?b=function(b,c){a.forEach(function(a){b.appendChild(c?a.cloneNode():a)})}:a instanceof Node&&(b=function(b){b.appendChild(a)});d>c;c++)b(this[c],c);return this},n.fn.appendTo=function(a){return n(a).append(this),this},n.fn.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},n.fn.remove=function(){for(var a,b=0,c=this.length;c>b;b++)a=this[b],delete n._cache.events[a.jid],a.jdata={},a.parentNode&&a.parentNode.removeChild(a);return this},"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=n:"function"==typeof define&&define.amd&&define(function(){return n}),"object"==typeof a&&"object"==typeof a.document&&(a.jBone=a.$=n)}(window); | ||
!function(a){function b(a,b){var c,d;this.originalEvent=a,d=function(a,b){this[a]="preventDefault"===a?function(){return this.defaultPrevented=!0,b[a]()}:m(b[a])?function(){return b[a]()}:b[a]};for(c in a)(a.hasOwnProperty(c)||"function"==typeof a[c])&&d.call(this,c,a);n.extend(this,b)}var c=a.$,d=a.jBone,e=/^<(\w+)\s*\/?>$/,f=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,g=[].slice,h=[].splice,i=Object.keys,j=document,k=function(a){return"string"==typeof a},l=function(a){return a instanceof Object},m=function(a){return"function"==typeof a},n=function(a,b){return new n.fn.init(a,b)};n.noConflict=function(){return a.$=c,a.jBone=d,n},n.fn=n.prototype={init:function(a,b){var c,d,h,i;if(k(a)){if(d=e.exec(a))return this[0]=j.createElement(d[1]),this.length=1,l(b)&&this.attr(b),this;if((d=f.exec(a))&&d[1]){for(i=j.createDocumentFragment(),h=j.createElement("div"),h.innerHTML=a;h.lastChild;)i.appendChild(h.firstChild);return c=g.call(i.childNodes),n.merge(this,c)}if(n.isElement(b))return n(b).find(a);try{return c=g.call(j.querySelectorAll(a)),n.merge(this,c)}catch(o){return this}}else{if(m(a))return a();if(a instanceof n)return a;if(a)return a=Array.isArray(a)?a:[a],n.merge(this,a)}return 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},n.fn.constructor=n,n.fn.init.prototype=n.fn,n.setId=function(b){var c=b.jid;b===a?c="window":void 0===b.jid&&(b.jid=c=++n._cache.jid),n._cache.events[c]||(n._cache.events[c]={})},n.getData=function(b){b=b instanceof n?b[0]:b;var c=b===a?"window":b.jid;return{jid:c,events:n._cache.events[c]}},n.isElement=function(a){return a instanceof n||a instanceof HTMLElement||k(a)},n._cache={events:{},jid:0},n.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},n.contains=function(a,b){var c;return a.reverse().some(function(a){return a.contains(b)?c=a:void 0}),c},n.extend=function(a){var b,c,d,e;return h.call(arguments,1).forEach(function(f){if(f)for(b=i(f),c=b.length,d=0,e=a;c>d;d++)e[b[d]]=f[b[d]]}),a},n.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=j.createEvent("Event"),a.initEvent(d,!0,!0),n.extend(a,{namespace:c,isDefaultPrevented:function(){return a.defaultPrevented}},b)},n.fn.on=function(a){var c,d,e,f,g,h,i,j,k=arguments,l=this.length,m=0;for(2===k.length?c=k[1]:(d=k[1],c=k[2]),j=function(j){n.setId(j),g=n.getData(j).events,a.split(" ").forEach(function(a){h=a.split(".")[0],e=a.split(".").splice(1).join("."),g[h]=g[h]||[],f=function(a){a.namespace&&a.namespace!==e||(i=null,d?(~n(j).find(d).indexOf(a.target)||(i=n.contains(n(j).find(d),a.target)))&&(i=i||a.target,a=new b(a,{currentTarget:i}),c.call(i,a)):c.call(j,a))},g[h].push({namespace:e,fn:f,originfn:c}),j.addEventListener&&j.addEventListener(h,f,!1)})};l>m;m++)j(this[m]);return this},n.fn.one=function(a){var b,c,d,e=arguments,f=0,g=this.length;for(2===e.length?b=e[1]:(c=e[1],b=e[2]),d=function(d){a.split(" ").forEach(function(a){var e=function(c){n(d).off(a,e),b.call(d,c)};c?n(d).on(a,c,e):n(d).on(a,e)})};g>f;f++)d(this[f]);return this},n.fn.trigger=function(a){var b,c=[],d=0,e=this.length;if(!a)return this;for(k(a)?c=a.split(" ").map(function(a){return n.Event(a)}):(a=a instanceof Event?a:$.Event(a),c=[a]),b=function(a){c.forEach(function(b){b.type&&a.dispatchEvent&&a.dispatchEvent(b)})};e>d;d++)b(this[d]);return this},n.fn.off=function(a,b){var c,d,e,f,g=0,h=this.length,j=function(a,c,d,e,f){var g;(b&&f.originfn===b||!b)&&(g=f.fn),a[c][d].fn===g&&(e.removeEventListener(c,g),delete n._cache.events[n.getData(e).jid][c][d])};for(f=function(b){c=n.getData(b).events,c&&a.split(" ").forEach(function(a){e=a.split(".")[0],d=a.split(".").splice(1).join("."),c[e]?c[e].forEach(function(a,f){(!d||d&&a.namespace===d)&&j(c,e,f,b,a)}):d&&i(c).forEach(function(a){c[a].forEach(function(e,f){e.namespace.split(".")[0]===d.split(".")[0]&&j(c,a,f,b,e)})})})};h>g;g++)f(this[g]);return this},n.fn.find=function(a){var b,c=[],d=0,e=this.length;for(b=function(b){m(b.querySelectorAll)&&[].forEach.call(b.querySelectorAll(a),function(a){c.push(a)})};e>d;d++)b(this[d]);return n(c)},n.fn.get=function(a){return this[a]},n.fn.eq=function(a){return n(this[a])},n.fn.parent=function(){var a,b=[];return this.forEach(function(c){!~b.indexOf(a=c.parentElement)&&a&&b.push(a)}),n(b)},n.fn.toArray=function(){return g.call(this)},n.fn.is=function(){var a=arguments;return this.some(function(b){return b.tagName.toLowerCase()===a[0]})},n.fn.has=function(){var a=arguments;return this.some(function(b){return b.querySelectorAll(a[0]).length})},n.fn.attr=function(a,b){var c,d=arguments,e=0,f=this.length;if(k(a)&&1===d.length)return this[0].getAttribute(a);for(2===d.length?c=function(c){c.setAttribute(a,b)}:l(a)&&(c=function(b){i(a).forEach(function(c){b.setAttribute(c,a[c])})});f>e;e++)c(this[e]);return this},n.fn.val=function(a){var b=0,c=this.length;if(0===arguments.length)return this[0].value;for(;c>b;b++)this[b].value=a;return this},n.fn.css=function(b,c){var d,e=arguments,f=0,g=this.length;if(k(b)&&1===e.length)return a.getComputedStyle(this[0])[b];for(2===e.length?d=function(a){a.style[b]=c}:l(b)&&(d=function(a){i(b).forEach(function(c){a.style[c]=b[c]})});g>f;f++)d(this[f]);return this},n.fn.data=function(a,b){var c,d=arguments,e={},f=0,g=this.length,h=function(a,b,c){l(c)?(a.jdata=a.jdata||{},a.jdata[b]=c):a.dataset[b]=c},j=function(a){return"true"===a?!0:"false"===a?!1:a};if(0===d.length)return this[0].jdata&&(e=this[0].jdata),i(this[0].dataset).forEach(function(a){e[a]=j(this[0].dataset[a])},this),e;if(1===d.length&&k(a))return j(this[0].dataset[a]||this[0].jdata&&this[0].jdata[a]);for(1===d.length&&l(a)?c=function(b){i(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},n.fn.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},n.fn.append=function(a){var b,c=0,d=this.length;for(k(a)&&f.exec(a)?a=n(a):l(a)||(a=document.createTextNode(a)),a instanceof n?b=function(b,c){a.forEach(function(a){b.appendChild(c?a.cloneNode():a)})}:a instanceof Node&&(b=function(b){b.appendChild(a)});d>c;c++)b(this[c],c);return this},n.fn.appendTo=function(a){return n(a).append(this),this},n.fn.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},n.fn.remove=function(){for(var a,b=0,c=this.length;c>b;b++)a=this[b],delete n._cache.events[a.jid],delete a.jdata,a.parentNode&&a.parentNode.removeChild(a);return this},"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=n:"function"==typeof define&&define.amd&&define(function(){return n}),"object"==typeof a&&"object"==typeof a.document&&(a.jBone=a.$=n)}(window); |
@@ -59,4 +59,4 @@ module.exports = function(grunt) { | ||
src: "<%= src %>", | ||
dest: 'dist/jbone.js', | ||
}, | ||
dest: 'dist/jbone.js' | ||
} | ||
}, | ||
@@ -63,0 +63,0 @@ uglify: { |
{ | ||
"name": "jbone", | ||
"title": "jBone", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Library for DOM manipulation", | ||
@@ -6,0 +6,0 @@ "main": "dist/jbone.js", |
@@ -5,2 +5,3 @@ # jBone | ||
[](http://badge.fury.io/bo/jbone) | ||
[](http://badge.fury.io/js/jbone) | ||
@@ -21,2 +22,4 @@ http://kupriyanenko.github.io/jbone/ | ||
##### With bower | ||
``` | ||
@@ -26,2 +29,16 @@ $ bower install jbone --save | ||
##### With component | ||
``` | ||
component install kupriyanenko/jbone | ||
``` | ||
##### With nodejs or browserify | ||
``` | ||
$ npm install jbone --save | ||
``` | ||
## Use it | ||
Add a `<script>` element for jbone.js | ||
@@ -33,5 +50,11 @@ | ||
## Use it | ||
Or include like npm module (with nodejs or browserify) | ||
```javascript | ||
var $ = require('jbone'); | ||
``` | ||
And write awesome code: | ||
```javascript | ||
var $input = $("<input>", { | ||
@@ -38,0 +61,0 @@ "class": "name" |
@@ -82,4 +82,3 @@ jBone.fn.html = function(value) { | ||
delete jBone._cache.events[el.jid]; | ||
el.jdata = {}; | ||
delete el.jdata; | ||
el.parentNode && el.parentNode.removeChild(el); | ||
@@ -86,0 +85,0 @@ } |
81442
207