Comparing version 1.0.12 to 1.0.15
{ | ||
"name": "jbone", | ||
"version": "1.0.12", | ||
"version": "1.0.15", | ||
"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.12", | ||
"version": "1.0.15", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "jquery", |
/*! | ||
* jBone v1.0.12 - 2014-05-04 - Library for DOM manipulation | ||
* jBone v1.0.15 - 2014-05-05 - Library for DOM manipulation | ||
* | ||
@@ -39,4 +39,8 @@ * https://github.com/kupriyanenko/jbone | ||
isFunction = function(el) { | ||
return typeof el === "function"; | ||
var getType = {}; | ||
return el && getType.toString.call(el) === "[object Function]"; | ||
}, | ||
isArray = function(el) { | ||
return Array.isArray(el); | ||
}, | ||
jBone = function(element, data) { | ||
@@ -114,9 +118,5 @@ return new fn.init(element, data); | ||
} | ||
// Return element wrapped by jBone | ||
if (element) { | ||
element = Array.isArray(element) ? element : [element]; | ||
return jBone.merge(this, element); | ||
} | ||
return this; | ||
return jBone.makeArray(element, this); | ||
}, | ||
@@ -183,2 +183,18 @@ | ||
function isArraylike(obj) { | ||
var length = obj.length, | ||
type = typeof obj; | ||
if (isFunction(type) || obj === win) { | ||
return false; | ||
} | ||
if (obj.nodeType === 1 && length) { | ||
return true; | ||
} | ||
return isArray(type) || length === 0 || | ||
typeof length === "number" && length > 0 && (length - 1) in obj; | ||
} | ||
jBone.merge = function(first, second) { | ||
@@ -231,2 +247,16 @@ var l = second.length, | ||
jBone.makeArray = function(arr, results) { | ||
var ret = results || []; | ||
if (arr !== null) { | ||
if (isArraylike(arr)) { | ||
jBone.merge(ret, isString(arr) ? [arr] : arr); | ||
} else { | ||
ret.push(arr); | ||
} | ||
} | ||
return ret; | ||
}; | ||
function BoneEvent(e, data) { | ||
@@ -693,9 +723,21 @@ var key, setter; | ||
// create jBone object and then append | ||
if (isString(appended) && rquickExpr.exec(appended)) { | ||
appended = jBone(appended); | ||
} else if (!isObject(appended)) { | ||
} | ||
// create text node for inserting | ||
else if (!isObject(appended)) { | ||
appended = document.createTextNode(appended); | ||
} | ||
if (appended instanceof jBone) { | ||
// just append NodeElement | ||
if (appended instanceof Node) { | ||
setter = function(el) { | ||
el.appendChild(appended); | ||
}; | ||
} | ||
// wrap object by jBone, and then append | ||
else { | ||
appended = appended instanceof jBone ? appended : jBone(appended); | ||
setter = function(el, i) { | ||
@@ -710,6 +752,2 @@ appended.forEach(function(node) { | ||
}; | ||
} else if (appended instanceof Node) { | ||
setter = function(el) { | ||
el.appendChild(appended); | ||
}; | ||
} | ||
@@ -716,0 +754,0 @@ |
/*! | ||
* jBone v1.0.12 - 2014-05-04 - Library for DOM manipulation | ||
* jBone v1.0.15 - 2014-05-05 - 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]()}:n(b[a])?function(){return b[a]()}:b[a]};for(c in a)(a[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(!a)return this;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=k.querySelectorAll(a),o.merge(this,c)}catch(j){return this}}return a.nodeType?(this[0]=a,this.length=1,this):n(a)?a():a instanceof o?a:a?(a=Array.isArray(a)?a:[a],o.merge(this,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},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&&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:o.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),o._cache.events[o.getData(e).jid][c].splice(d,1))};for(e=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)})}):void a.split(" ").forEach(function(a){f=a.split(".")[0],d=a.split(".").splice(1).join("."),c[f]?c[f].forEach(function(a,e){(!d||d&&a.namespace===d)&&i(c,f,e,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};h>g;g++)e(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]&&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]&&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 this[0]&&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 this[0]&&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){b.appendChild(c?a.cloneNode():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}),a.jBone=a.$=o):"object"==typeof a&&"object"==typeof a.document&&(a.jBone=a.$=o)}(window); | ||
!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){this[a]="preventDefault"===a?function(){return this.defaultPrevented=!0,b[a]()}:o(b[a])?function(){return b[a]()}:b[a]};for(c in a)(a[c]||"function"==typeof a[c])&&d.call(this,c,a);q.extend(this,b)}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){var b={};return a&&"[object Function]"===b.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},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){var c;return a.reverse().some(function(a){return a.contains(b)?c=a:void 0}),c},q.extend=function(a){var b,c,d,e;return j.call(arguments,1).forEach(function(f){if(f)for(b=k(f),c=b.length,d=0,e=a;c>d;d++)e[b[d]]=f[b[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.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)},d.on=function(a){var b,d,e,f,g,h,i,j,k=arguments,l=this.length,m=0;for(2===k.length?b=k[1]:(d=k[1],b=k[2]),j=function(j){q.setId(j),g=q.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?(~q(j).find(d).indexOf(a.target)||(i=q.contains(q(j).find(d),a.target)))&&(i=i||a.target,a=new c(a,{currentTarget:i}),b.call(i,a)):b.call(j,a))},g[h].push({namespace:e,fn:f,originfn:b}),j.addEventListener&&j.addEventListener(h,f,!1)})};l>m;m++)j(this[m]);return this},d.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){q(d).off(a,e),b.call(d,c)};c?q(d).on(a,c,e):q(d).on(a,e)})};g>f;f++)d(this[f]);return this},d.trigger=function(a){var b,c=[],d=0,e=this.length;if(!a)return this;for(m(a)?c=a.split(" ").map(function(a){return q.Event(a)}):(a=a instanceof Event?a:q.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},d.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),q._cache.events[q.getData(e).jid][c].splice(d,1))};for(e=function(b){return(c=q.getData(b).events)?!a&&c?k(c).forEach(function(a){c[a].forEach(function(d,e){i(c,a,e,b,d)})}):(a.split(" ").forEach(function(a){f=a.split(".")[0],d=a.split(".").splice(1).join("."),c[f]?c[f].forEach(function(a,e){(!d||d&&a.namespace===d)&&i(c,f,e,b,a)}):d&&k(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++)e(this[g]);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 this[a]},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.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.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.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 instanceof Node?b=function(b){b.appendChild(a)}:(a=a instanceof q?a:q(a),b=function(b,c){a.forEach(function(a){c?b.appendChild(a.cloneNode()):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); |
{ | ||
"name": "jbone", | ||
"title": "jBone", | ||
"version": "1.0.12", | ||
"version": "1.0.15", | ||
"description": "Library for DOM manipulation", | ||
@@ -6,0 +6,0 @@ "main": "dist/jbone.js", |
@@ -28,4 +28,8 @@ var | ||
isFunction = function(el) { | ||
return typeof el === "function"; | ||
var getType = {}; | ||
return el && getType.toString.call(el) === "[object Function]"; | ||
}, | ||
isArray = function(el) { | ||
return Array.isArray(el); | ||
}, | ||
jBone = function(element, data) { | ||
@@ -103,9 +107,5 @@ return new fn.init(element, data); | ||
} | ||
// Return element wrapped by jBone | ||
if (element) { | ||
element = Array.isArray(element) ? element : [element]; | ||
return jBone.merge(this, element); | ||
} | ||
return this; | ||
return jBone.makeArray(element, this); | ||
}, | ||
@@ -112,0 +112,0 @@ |
@@ -22,9 +22,21 @@ fn.html = function(value) { | ||
// create jBone object and then append | ||
if (isString(appended) && rquickExpr.exec(appended)) { | ||
appended = jBone(appended); | ||
} else if (!isObject(appended)) { | ||
} | ||
// create text node for inserting | ||
else if (!isObject(appended)) { | ||
appended = document.createTextNode(appended); | ||
} | ||
if (appended instanceof jBone) { | ||
// just append NodeElement | ||
if (appended instanceof Node) { | ||
setter = function(el) { | ||
el.appendChild(appended); | ||
}; | ||
} | ||
// wrap object by jBone, and then append | ||
else { | ||
appended = appended instanceof jBone ? appended : jBone(appended); | ||
setter = function(el, i) { | ||
@@ -39,6 +51,2 @@ appended.forEach(function(node) { | ||
}; | ||
} else if (appended instanceof Node) { | ||
setter = function(el) { | ||
el.appendChild(appended); | ||
}; | ||
} | ||
@@ -45,0 +53,0 @@ |
@@ -0,1 +1,17 @@ | ||
function isArraylike(obj) { | ||
var length = obj.length, | ||
type = typeof obj; | ||
if (isFunction(type) || obj === win) { | ||
return false; | ||
} | ||
if (obj.nodeType === 1 && length) { | ||
return true; | ||
} | ||
return isArray(type) || length === 0 || | ||
typeof length === "number" && length > 0 && (length - 1) in obj; | ||
} | ||
jBone.merge = function(first, second) { | ||
@@ -47,1 +63,15 @@ var l = second.length, | ||
}; | ||
jBone.makeArray = function(arr, results) { | ||
var ret = results || []; | ||
if (arr !== null) { | ||
if (isArraylike(arr)) { | ||
jBone.merge(ret, isString(arr) ? [arr] : arr); | ||
} else { | ||
ret.push(arr); | ||
} | ||
} | ||
return ret; | ||
}; |
@@ -102,2 +102,14 @@ describe('jBone Core', function() { | ||
it('jBone(NodeList)', function() { | ||
var fragment = document.createDocumentFragment(), | ||
a0 = document.createElement('a'), | ||
a1 = document.createElement('a'); | ||
fragment.appendChild(a0); | ||
fragment.appendChild(a1); | ||
var $a = $(fragment.childNodes); | ||
expect($a).have.length(2); | ||
}); | ||
}); |
@@ -85,2 +85,14 @@ describe('jBone Manipulation', function() { | ||
it('append(NodeList)', function() { | ||
var a = jBone('<div>'), | ||
f = document.createDocumentFragment(); | ||
f.appendChild(document.createElement('span')); | ||
f.appendChild(document.createElement('span')); | ||
a.append(f.childNodes); | ||
expect(a.find('span')).to.have.length(2); | ||
}); | ||
it('append(text)', function() { | ||
@@ -87,0 +99,0 @@ var a = jBone('<div>'); |
630821
17806