Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "jbone", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"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.8", | ||
"version": "1.0.9", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "jquery", |
/*! | ||
* jBone v1.0.8 - 2014-04-06 - Library for DOM manipulation | ||
* jBone v1.0.9 - 2014-04-22 - Library for DOM manipulation | ||
* | ||
@@ -42,4 +42,5 @@ * https://github.com/kupriyanenko/jbone | ||
jBone = function(element, data) { | ||
return new jBone.fn.init(element, data); | ||
}; | ||
return new fn.init(element, data); | ||
}, | ||
fn; | ||
@@ -54,3 +55,3 @@ // set previous values and return the instance upon calling the no-conflict mode | ||
jBone.fn = jBone.prototype = { | ||
fn = jBone.fn = jBone.prototype = { | ||
init: function(element, data) { | ||
@@ -136,5 +137,5 @@ var elements, tag, wraper, fragment; | ||
jBone.fn.constructor = jBone; | ||
fn.constructor = jBone; | ||
jBone.fn.init.prototype = jBone.fn; | ||
fn.init.prototype = fn; | ||
@@ -273,3 +274,3 @@ jBone.setId = function(el) { | ||
jBone.fn.on = function(event) { | ||
fn.on = function(event) { | ||
var args = arguments, | ||
@@ -329,3 +330,3 @@ length = this.length, | ||
jBone.fn.one = function(event) { | ||
fn.one = function(event) { | ||
var args = arguments, | ||
@@ -364,3 +365,3 @@ i = 0, | ||
jBone.fn.trigger = function(event) { | ||
fn.trigger = function(event) { | ||
var events = [], | ||
@@ -401,3 +402,3 @@ i = 0, | ||
jBone.fn.off = function(event, fn) { | ||
fn.off = function(event, fn) { | ||
var i = 0, | ||
@@ -429,2 +430,11 @@ length = this.length, | ||
// remove all events | ||
if (!event && events) { | ||
return keys(events).forEach(function(eventType) { | ||
events[eventType].forEach(function(e, index) { | ||
removeListener(events, eventType, index, el, e); | ||
}); | ||
}); | ||
} | ||
event.split(" ").forEach(function(event) { | ||
@@ -462,16 +472,14 @@ eventType = event.split(".")[0]; | ||
jBone.fn.find = function(selector) { | ||
fn.find = function(selector) { | ||
var results = [], | ||
i = 0, | ||
length = this.length, | ||
finder; | ||
finder = function(el) { | ||
if (isFunction(el.querySelectorAll)) { | ||
[].forEach.call(el.querySelectorAll(selector), function(found) { | ||
results.push(found); | ||
}); | ||
} | ||
}; | ||
finder = function(el) { | ||
if (isFunction(el.querySelectorAll)) { | ||
[].forEach.call(el.querySelectorAll(selector), function(found) { | ||
results.push(found); | ||
}); | ||
} | ||
}; | ||
for (; i < length; i++) { | ||
@@ -484,18 +492,21 @@ finder(this[i]); | ||
jBone.fn.get = function(index) { | ||
fn.get = function(index) { | ||
return this[index]; | ||
}; | ||
jBone.fn.eq = function(index) { | ||
fn.eq = function(index) { | ||
return jBone(this[index]); | ||
}; | ||
jBone.fn.parent = function() { | ||
var results = [], parent; | ||
fn.parent = function() { | ||
var results = [], | ||
parent, | ||
i = 0, | ||
length = this.length; | ||
this.forEach(function(el) { | ||
if (!~results.indexOf(parent = el.parentElement) && parent) { | ||
for (; i < length; i++) { | ||
if (!~results.indexOf(parent = this[i].parentElement) && parent) { | ||
results.push(parent); | ||
} | ||
}); | ||
} | ||
@@ -505,7 +516,7 @@ return jBone(results); | ||
jBone.fn.toArray = function() { | ||
fn.toArray = function() { | ||
return slice.call(this); | ||
}; | ||
jBone.fn.is = function() { | ||
fn.is = function() { | ||
var args = arguments; | ||
@@ -518,3 +529,3 @@ | ||
jBone.fn.has = function() { | ||
fn.has = function() { | ||
var args = arguments; | ||
@@ -527,3 +538,3 @@ | ||
jBone.fn.attr = function(key, value) { | ||
fn.attr = function(key, value) { | ||
var args = arguments, | ||
@@ -557,3 +568,3 @@ i = 0, | ||
jBone.fn.val = function(value) { | ||
fn.val = function(value) { | ||
var i = 0, | ||
@@ -573,3 +584,3 @@ length = this.length; | ||
jBone.fn.css = function(key, value) { | ||
fn.css = function(key, value) { | ||
var args = arguments, | ||
@@ -605,3 +616,3 @@ i = 0, | ||
jBone.fn.data = function(key, value) { | ||
fn.data = function(key, value) { | ||
var args = arguments, data = {}, | ||
@@ -662,3 +673,3 @@ i = 0, | ||
jBone.fn.html = function(value) { | ||
fn.html = function(value) { | ||
var args = arguments, | ||
@@ -679,3 +690,3 @@ el; | ||
jBone.fn.append = function(appended) { | ||
fn.append = function(appended) { | ||
var i = 0, | ||
@@ -714,3 +725,3 @@ length = this.length, | ||
jBone.fn.appendTo = function(to) { | ||
fn.appendTo = function(to) { | ||
jBone(to).append(this); | ||
@@ -721,3 +732,3 @@ | ||
jBone.fn.empty = function() { | ||
fn.empty = function() { | ||
var i = 0, | ||
@@ -738,3 +749,3 @@ length = this.length, | ||
jBone.fn.remove = function() { | ||
fn.remove = function() { | ||
var i = 0, | ||
@@ -744,6 +755,9 @@ length = this.length, | ||
// remove all listners | ||
this.off(); | ||
for (; i < length; i++) { | ||
el = this[i]; | ||
delete jBone._cache.events[el.jid]; | ||
// remove data and nodes | ||
delete el.jdata; | ||
@@ -750,0 +764,0 @@ el.parentNode && el.parentNode.removeChild(el); |
/*! | ||
* jBone v1.0.8 - 2014-04-06 - Library for DOM manipulation | ||
* jBone v1.0.9 - 2014-04-22 - 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],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); | ||
!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]()}:n(b[a])?function(){return b[a]()}:b[a]};for(c in a)(a.hasOwnProperty(c)||"function"==typeof a[c])&&d.call(this,c,a);o.extend(this,b)}var c,d=a.$,e=a.jBone,f=/^<(\w+)\s*\/?>$/,g=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,h=[].slice,i=[].splice,j=Object.keys,k=document,l=function(a){return"string"==typeof a},m=function(a){return a instanceof Object},n=function(a){return"function"==typeof a},o=function(a,b){return new c.init(a,b)};o.noConflict=function(){return a.$=d,a.jBone=e,o},c=o.fn=o.prototype={init:function(a,b){var c,d,e,i;if(l(a)){if(d=f.exec(a))return this[0]=k.createElement(d[1]),this.length=1,m(b)&&this.attr(b),this;if((d=g.exec(a))&&d[1]){for(i=k.createDocumentFragment(),e=k.createElement("div"),e.innerHTML=a;e.lastChild;)i.appendChild(e.firstChild);return c=h.call(i.childNodes),o.merge(this,c)}if(o.isElement(b))return o(b).find(a);try{return c=h.call(k.querySelectorAll(a)),o.merge(this,c)}catch(j){return this}}else{if(n(a))return a();if(a instanceof o)return a;if(a)return a=Array.isArray(a)?a:[a],o.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},c.constructor=o,c.init.prototype=c,o.setId=function(b){var c=b.jid;b===a?c="window":void 0===b.jid&&(b.jid=c=++o._cache.jid),o._cache.events[c]||(o._cache.events[c]={})},o.getData=function(b){b=b instanceof o?b[0]:b;var c=b===a?"window":b.jid;return{jid:c,events:o._cache.events[c]}},o.isElement=function(a){return a instanceof o||a instanceof HTMLElement||l(a)},o._cache={events:{},jid:0},o.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},o.contains=function(a,b){var c;return a.reverse().some(function(a){return a.contains(b)?c=a:void 0}),c},o.extend=function(a){var b,c,d,e;return i.call(arguments,1).forEach(function(f){if(f)for(b=j(f),c=b.length,d=0,e=a;c>d;d++)e[b[d]]=f[b[d]]}),a},o.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=k.createEvent("Event"),a.initEvent(d,!0,!0),o.extend(a,{namespace:c,isDefaultPrevented:function(){return a.defaultPrevented}},b)},c.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){o.setId(j),g=o.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?(~o(j).find(d).indexOf(a.target)||(i=o.contains(o(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},c.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){o(d).off(a,e),b.call(d,c)};c?o(d).on(a,c,e):o(d).on(a,e)})};g>f;f++)d(this[f]);return this},c.trigger=function(a){var b,c=[],d=0,e=this.length;if(!a)return this;for(l(a)?c=a.split(" ").map(function(a){return o.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},c.off=function(a,b){var c,d,e,f,g=0,h=this.length,i=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 o._cache.events[o.getData(e).jid][c][d])};for(f=function(b){return(c=o.getData(b).events)?!a&&c?j(c).forEach(function(a){c[a].forEach(function(d,e){i(c,a,e,b,d)})}):(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)&&i(c,e,f,b,a)}):d&&j(c).forEach(function(a){c[a].forEach(function(e,f){e.namespace.split(".")[0]===d.split(".")[0]&&i(c,a,f,b,e)})})}),void 0):void 0};h>g;g++)f(this[g]);return this},c.find=function(a){for(var b=[],c=0,d=this.length,e=function(c){n(c.querySelectorAll)&&[].forEach.call(c.querySelectorAll(a),function(a){b.push(a)})};d>c;c++)e(this[c]);return o(b)},c.get=function(a){return this[a]},c.eq=function(a){return o(this[a])},c.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 o(b)},c.toArray=function(){return h.call(this)},c.is=function(){var a=arguments;return this.some(function(b){return b.tagName.toLowerCase()===a[0]})},c.has=function(){var a=arguments;return this.some(function(b){return b.querySelectorAll(a[0]).length})},c.attr=function(a,b){var c,d=arguments,e=0,f=this.length;if(l(a)&&1===d.length)return this[0].getAttribute(a);for(2===d.length?c=function(c){c.setAttribute(a,b)}:m(a)&&(c=function(b){j(a).forEach(function(c){b.setAttribute(c,a[c])})});f>e;e++)c(this[e]);return this},c.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},c.css=function(b,c){var d,e=arguments,f=0,g=this.length;if(l(b)&&1===e.length)return a.getComputedStyle(this[0])[b];for(2===e.length?d=function(a){a.style[b]=c}:m(b)&&(d=function(a){j(b).forEach(function(c){a.style[c]=b[c]})});g>f;f++)d(this[f]);return this},c.data=function(a,b){var c,d=arguments,e={},f=0,g=this.length,h=function(a,b,c){m(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),j(this[0].dataset).forEach(function(a){e[a]=i(this[0].dataset[a])},this),e;if(1===d.length&&l(a))return i(this[0].dataset[a]||this[0].jdata&&this[0].jdata[a]);for(1===d.length&&m(a)?c=function(b){j(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},c.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},c.append=function(a){var b,c=0,d=this.length;for(l(a)&&g.exec(a)?a=o(a):m(a)||(a=document.createTextNode(a)),a instanceof o?b=function(b,c){a.forEach(function(a){c?b.appendChild(a.cloneNode()):b.appendChild(a)})}:a instanceof Node&&(b=function(b){b.appendChild(a)});d>c;c++)b(this[c],c);return this},c.appendTo=function(a){return o(a).append(this),this},c.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},c.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=o:"function"==typeof define&&define.amd&&define(function(){return o}),"object"==typeof a&&"object"==typeof a.document&&(a.jBone=a.$=o)}(window); |
{ | ||
"name": "jbone", | ||
"title": "jBone", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Library for DOM manipulation", | ||
@@ -6,0 +6,0 @@ "main": "dist/jbone.js", |
@@ -1,2 +0,2 @@ | ||
jBone.fn.attr = function(key, value) { | ||
fn.attr = function(key, value) { | ||
var args = arguments, | ||
@@ -30,3 +30,3 @@ i = 0, | ||
jBone.fn.val = function(value) { | ||
fn.val = function(value) { | ||
var i = 0, | ||
@@ -46,3 +46,3 @@ length = this.length; | ||
jBone.fn.css = function(key, value) { | ||
fn.css = function(key, value) { | ||
var args = arguments, | ||
@@ -78,3 +78,3 @@ i = 0, | ||
jBone.fn.data = function(key, value) { | ||
fn.data = function(key, value) { | ||
var args = arguments, data = {}, | ||
@@ -81,0 +81,0 @@ i = 0, |
@@ -31,4 +31,5 @@ var | ||
jBone = function(element, data) { | ||
return new jBone.fn.init(element, data); | ||
}; | ||
return new fn.init(element, data); | ||
}, | ||
fn; | ||
@@ -43,3 +44,3 @@ // set previous values and return the instance upon calling the no-conflict mode | ||
jBone.fn = jBone.prototype = { | ||
fn = jBone.fn = jBone.prototype = { | ||
init: function(element, data) { | ||
@@ -125,5 +126,5 @@ var elements, tag, wraper, fragment; | ||
jBone.fn.constructor = jBone; | ||
fn.constructor = jBone; | ||
jBone.fn.init.prototype = jBone.fn; | ||
fn.init.prototype = fn; | ||
@@ -130,0 +131,0 @@ jBone.setId = function(el) { |
@@ -52,3 +52,3 @@ function BoneEvent(e, data) { | ||
jBone.fn.on = function(event) { | ||
fn.on = function(event) { | ||
var args = arguments, | ||
@@ -108,3 +108,3 @@ length = this.length, | ||
jBone.fn.one = function(event) { | ||
fn.one = function(event) { | ||
var args = arguments, | ||
@@ -143,3 +143,3 @@ i = 0, | ||
jBone.fn.trigger = function(event) { | ||
fn.trigger = function(event) { | ||
var events = [], | ||
@@ -180,3 +180,3 @@ i = 0, | ||
jBone.fn.off = function(event, fn) { | ||
fn.off = function(event, fn) { | ||
var i = 0, | ||
@@ -208,2 +208,11 @@ length = this.length, | ||
// remove all events | ||
if (!event && events) { | ||
return keys(events).forEach(function(eventType) { | ||
events[eventType].forEach(function(e, index) { | ||
removeListener(events, eventType, index, el, e); | ||
}); | ||
}); | ||
} | ||
event.split(" ").forEach(function(event) { | ||
@@ -210,0 +219,0 @@ eventType = event.split(".")[0]; |
@@ -1,2 +0,2 @@ | ||
jBone.fn.html = function(value) { | ||
fn.html = function(value) { | ||
var args = arguments, | ||
@@ -17,3 +17,3 @@ el; | ||
jBone.fn.append = function(appended) { | ||
fn.append = function(appended) { | ||
var i = 0, | ||
@@ -52,3 +52,3 @@ length = this.length, | ||
jBone.fn.appendTo = function(to) { | ||
fn.appendTo = function(to) { | ||
jBone(to).append(this); | ||
@@ -59,3 +59,3 @@ | ||
jBone.fn.empty = function() { | ||
fn.empty = function() { | ||
var i = 0, | ||
@@ -76,3 +76,3 @@ length = this.length, | ||
jBone.fn.remove = function() { | ||
fn.remove = function() { | ||
var i = 0, | ||
@@ -82,6 +82,9 @@ length = this.length, | ||
// remove all listners | ||
this.off(); | ||
for (; i < length; i++) { | ||
el = this[i]; | ||
delete jBone._cache.events[el.jid]; | ||
// remove data and nodes | ||
delete el.jdata; | ||
@@ -88,0 +91,0 @@ el.parentNode && el.parentNode.removeChild(el); |
@@ -1,15 +0,13 @@ | ||
jBone.fn.find = function(selector) { | ||
fn.find = function(selector) { | ||
var results = [], | ||
i = 0, | ||
length = this.length, | ||
finder; | ||
finder = function(el) { | ||
if (isFunction(el.querySelectorAll)) { | ||
[].forEach.call(el.querySelectorAll(selector), function(found) { | ||
results.push(found); | ||
}); | ||
} | ||
}; | ||
finder = function(el) { | ||
if (isFunction(el.querySelectorAll)) { | ||
[].forEach.call(el.querySelectorAll(selector), function(found) { | ||
results.push(found); | ||
}); | ||
} | ||
}; | ||
for (; i < length; i++) { | ||
@@ -22,18 +20,21 @@ finder(this[i]); | ||
jBone.fn.get = function(index) { | ||
fn.get = function(index) { | ||
return this[index]; | ||
}; | ||
jBone.fn.eq = function(index) { | ||
fn.eq = function(index) { | ||
return jBone(this[index]); | ||
}; | ||
jBone.fn.parent = function() { | ||
var results = [], parent; | ||
fn.parent = function() { | ||
var results = [], | ||
parent, | ||
i = 0, | ||
length = this.length; | ||
this.forEach(function(el) { | ||
if (!~results.indexOf(parent = el.parentElement) && parent) { | ||
for (; i < length; i++) { | ||
if (!~results.indexOf(parent = this[i].parentElement) && parent) { | ||
results.push(parent); | ||
} | ||
}); | ||
} | ||
@@ -43,7 +44,7 @@ return jBone(results); | ||
jBone.fn.toArray = function() { | ||
fn.toArray = function() { | ||
return slice.call(this); | ||
}; | ||
jBone.fn.is = function() { | ||
fn.is = function() { | ||
var args = arguments; | ||
@@ -56,3 +57,3 @@ | ||
jBone.fn.has = function() { | ||
fn.has = function() { | ||
var args = arguments; | ||
@@ -59,0 +60,0 @@ |
@@ -250,3 +250,3 @@ describe('jBone Event', function() { | ||
it('trigger() order', function() { | ||
var markup = jBone('<div><div><p><span><b>b</b></span></p></div></div>'), | ||
var markup = jBone('<div><div><p><span><b></b></span></p></div></div>'), | ||
path = ''; | ||
@@ -267,3 +267,3 @@ | ||
expect(path).be.eql('b span p div div '); | ||
expect(path).be.eql('b p div div '); | ||
}); | ||
@@ -270,0 +270,0 @@ |
@@ -139,2 +139,16 @@ describe('jBone Manipulation', function() { | ||
}); | ||
it('remove() should remoe all event listners', function() { | ||
var a = jBone('<a>'), | ||
i = 0; | ||
a.on('click', function() { | ||
i++; | ||
}); | ||
a.remove(); | ||
a.trigger('click'); | ||
expect(i).to.be.eql(0); | ||
}); | ||
}); |
82266
2031