Browse files

update smoosh dependency to ~1.3.4

change order of main wrapper definition
bump package
  • Loading branch information...
1 parent 22fc118 commit 868db53842945c7e6c6ab1b1f6f48f23c1b9fec8 @ded committed Nov 25, 2012
Showing with 48 additions and 42 deletions.
  1. +1 −1 .jshintrc
  2. +21 −18 bonzo.js
  3. +1 −1 bonzo.min.js
  4. +1 −1 component.json
  5. +1 −1 make/build.js
  6. +2 −2 package.json
  7. +21 −18 src/bonzo.js
View
2 .jshintrc
@@ -1,5 +1,5 @@
{
- "predef": [ "assert", "refute", "define", "self" ]
+ "predef": ["assert", "refute", "define", "self"]
, "boss": true
, "shadow": true
, "trailing": true
View
39 bonzo.js
@@ -3,11 +3,11 @@
* https://github.com/ded/bonzo
* License MIT
*/
-(function (name, definition, context) {
+(function (name, context, definition) {
if (typeof module != 'undefined' && module.exports) module.exports = definition()
else if (typeof context['define'] == 'function' && context['define']['amd']) define(name, definition)
else context[name] = definition()
-})('bonzo', function() {
+})('bonzo', this, function() {
var win = window
, doc = win.document
, html = doc.documentElement
@@ -73,6 +73,24 @@
}
+ function isNode(node) {
+ return node && node.nodeName && (node.nodeType == 1 || node.nodeType == 11)
+ }
+
+
+ function normalize(node, host, clone) {
+ var i, l, ret
+ if (typeof node == 'string') return bonzo.create(node)
+ if (isNode(node)) node = [ node ]
+ if (clone) {
+ ret = [] // don't change original array
+ for (i = 0, l = node.length; i < l; i++) ret[i] = cloneNode(host, node[i])
+ return ret
+ }
+ return node
+ }
+
+
/**
* @param {string} c a class name to test
* @return {boolean}
@@ -169,10 +187,6 @@
return undefined
}
- function isNode(node) {
- return node && node.nodeName && (node.nodeType == 1 || node.nodeType == 11)
- }
-
/**
* @param {Bonzo|Array} ar
@@ -977,17 +991,6 @@
}
- function normalize(node, host, clone) {
- var i, l, ret
- if (typeof node == 'string') return bonzo.create(node)
- if (isNode(node)) node = [ node ]
- if (clone) {
- ret = [] // don't change original array
- for (i = 0, l = node.length; i < l; i++) ret[i] = cloneNode(host, node[i])
- return ret
- }
- return node
- }
function cloneNode(host, el) {
var c = el.cloneNode(true)
@@ -1123,4 +1126,4 @@
}
return bonzo
-}, this); // the only line we care about using a semi-colon. placed here for concatenation tools
+}); // the only line we care about using a semi-colon. placed here for concatenation tools
View
2 bonzo.min.js
@@ -3,4 +3,4 @@
* https://github.com/ded/bonzo
* License MIT
*/
-(function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=t():typeof n["define"]=="function"&&n.define.amd?define(e,t):n[e]=t()})("bonzo",function(){function M(e){return new RegExp("(^|\\s+)"+e+"(\\s+|$)")}function _(e,t,n,r){var i,s=0,o=e.length;for(;s<o;s++)i=r?e.length-s-1:s,t.call(n||e[i],e[i],i,e);return e}function D(e,t,n){for(var r=0,i=e.length;r<i;r++)I(e[r])&&(D(e[r].childNodes,t,n),t.call(n||e[r],e[r],r,e));return e}function P(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}function H(e){return e?e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase():e}function B(e){e[x]("data-node-uid")||e[S]("data-node-uid",++y);var t=e[x]("data-node-uid");return g[t]||(g[t]={})}function j(e){var t=e[x]("data-node-uid");t&&delete g[t]}function F(e){var t;try{return e===null||e===undefined?undefined:e==="true"?!0:e==="false"?!1:e==="null"?null:(t=parseFloat(e))==e?t:e}catch(n){}return undefined}function I(e){return e&&e.nodeName&&(e.nodeType==1||e.nodeType==11)}function q(e,t,n){for(var r=0,i=e.length;r<i;++r)if(t.call(n||null,e[r],r,e))return!0;return!1}function R(e){return e=="transform"&&(e=N.transform)||/^transform-?[Oo]rigin$/.test(e)&&(e=N.transform+"Origin")||e=="float"&&(e=N.cssFloat),e?P(e):null}function z(e,t,n,r){var s=0,o=t||this,u=[],a=i&&typeof e=="string"&&e.charAt(0)!="<"?i(e):e;return _($(a),function(e,t){_(o,function(r){n(e,u[s++]=t>0?J(o,r):r)},null,r)},this,r),o.length=s,_(u,function(e){o[--s]=e},null,!r),o}function W(e,t,n){var r=Y(e),i=r.css("position"),s=r.offset(),o="relative",u=i==o,a=[parseInt(r.css("left"),10),parseInt(r.css("top"),10)];i=="static"&&(r.css("position",o),i=o),isNaN(a[0])&&(a[0]=u?0:e.offsetLeft),isNaN(a[1])&&(a[1]=u?0:e.offsetTop),t!=null&&(e.style.left=t-s.left+a[0]+E),n!=null&&(e.style.top=n-s.top+a[1]+E)}function X(e,t){return typeof t=="function"?t(e):t}function V(e){this.length=0;if(e){e=typeof e!="string"&&!e.nodeType&&typeof e.length!="undefined"?e:[e],this.length=e.length;for(var t=0;t<e.length;t++)this[t]=e[t]}}function $(e,t,n){var r,i,s;if(typeof e=="string")return Y.create(e);I(e)&&(e=[e]);if(n){s=[];for(r=0,i=e.length;r<i;r++)s[r]=J(t,e[r]);return s}return e}function J(e,t){var n=t.cloneNode(!0),r,i;if(e.$&&typeof e.cloneEvents=="function"){e.$(n).cloneEvents(t),r=e.$(n).find("*"),i=e.$(t).find("*");for(var s=0;s<i.length;s++)e.$(r[s]).cloneEvents(i[s])}return n}function K(t,n,r){var i=this[0];return i?t==null&&n==null?(Q(i)?G():{x:i.scrollLeft,y:i.scrollTop})[r]:(Q(i)?e.scrollTo(t,n):(t!=null&&(i.scrollLeft=t),n!=null&&(i.scrollTop=n)),this):this}function Q(t){return t===e||/^(?:body|html)$/i.test(t.tagName)}function G(){return{x:e.pageXOffset||n.scrollLeft,y:e.pageYOffset||n.scrollTop}}function Y(e){return new V(e)}var e=window,t=e.document,n=t.documentElement,r="parentNode",i=null,s=/^(checked|value|selected|disabled)$/i,o=/^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i,u=["<table>","</table>",1],a=["<table><tbody><tr>","</tr></tbody></table>",3],f=["<select>","</select>",1],l=["_","",0,1],c={thead:u,tbody:u,tfoot:u,colgroup:u,caption:u,tr:["<table><tbody>","</tbody></table>",2],th:a,td:a,col:["<table><colgroup>","</colgroup></table>",2],fieldset:["<form>","</form>",1],legend:["<form><fieldset>","</fieldset></form>",2],option:f,optgroup:f,script:l,style:l,link:l,param:l,base:l},h=/^(checked|selected|disabled)$/,p=/msie/i.test(navigator.userAgent),d,v,m,g={},y=0,b=/^-?[\d\.]+$/,w=/^data-(.+)$/,E="px",S="setAttribute",x="getAttribute",T="getElementsByTagName",N=function(){var e=t.createElement("p");return e.innerHTML='<a href="#x">x</a><table style="float:left;"></table>',{hrefExtended:e[T]("a")[0][x]("href")!="#x",autoTbody:e[T]("tbody").length!==0,computedStyle:t.defaultView&&t.defaultView.getComputedStyle,cssFloat:e[T]("table")[0].style.styleFloat?"styleFloat":"cssFloat",transform:function(){var t=["transform","webkitTransform","MozTransform","OTransform","msTransform"],n;for(n=0;n<t.length;n++)if(t[n]in e.style)return t[n]}(),classList:"classList"in e,opasity:function(){return typeof t.createElement("a").style.opacity!="undefined"}()}}(),C=/(^\s*|\s*$)/g,k=/\s+/,L=String.prototype.toString,A={lineHeight:1,zoom:1,zIndex:1,opacity:1,boxFlex:1,WebkitBoxFlex:1,MozBoxFlex:1},O=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(C,"")},U=N.computedStyle?function(e,n){var r=null,i=t.defaultView.getComputedStyle(e,"");return i&&(r=i[n]),e.style[n]||r}:p&&n.currentStyle?function(e,t){if(t=="opacity"&&!N.opasity){var n=100;try{n=e.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(r){try{n=e.filters("alpha").opacity}catch(i){}}return n/100}var s=e.currentStyle?e.currentStyle[t]:null;return e.style[t]||s}:function(e,t){return e.style[t]};return N.classList?(d=function(e,t){return e.classList.contains(t)},v=function(e,t){e.classList.add(t)},m=function(e,t){e.classList.remove(t)}):(d=function(e,t){return M(t).test(e.className)},v=function(e,t){e.className=O(e.className+" "+t)},m=function(e,t){e.className=O(e.className.replace(M(t)," "))}),V.prototype={get:function(e){return this[e]||null},each:function(e,t){return _(this,e,t)},deepEach:function(e,t){return D(this,e,t)},map:function(e,t){var n=[],r,i;for(i=0;i<this.length;i++)r=e.call(this,this[i],i),t?t(r)&&n.push(r):n.push(r);return n},html:function(e,t){var r=t?n.textContent===undefined?"innerText":"textContent":"innerHTML",i=this,s=function(t,n){_($(e,i,n),function(e){t.appendChild(e)})},u=function(n,i){try{if(t||typeof e=="string"&&!o.test(n.tagName))return n[r]=e}catch(u){}s(n,i)};return typeof e!="undefined"?this.empty().each(u):this[0]?this[0][r]:""},text:function(e){return this.html(e,!0)},append:function(e){var t=this;return this.each(function(n,r){_($(e,t,r),function(e){n.appendChild(e)})})},prepend:function(e){var t=this;return this.each(function(n,r){var i=n.firstChild;_($(e,t,r),function(e){n.insertBefore(e,i)})})},appendTo:function(e,t){return z.call(this,e,t,function(e,t){e.appendChild(t)})},prependTo:function(e,t){return z.call(this,e,t,function(e,t){e.insertBefore(t,e.firstChild)},1)},before:function(e){var t=this;return this.each(function(n,i){_($(e,t,i),function(e){n[r].insertBefore(e,n)})})},after:function(e){var t=this;return this.each(function(n,i){_($(e,t,i),function(e){n[r].insertBefore(e,n.nextSibling)},null,1)})},insertBefore:function(e,t){return z.call(this,e,t,function(e,t){e[r].insertBefore(t,e)})},insertAfter:function(e,t){return z.call(this,e,t,function(e,t){var n=e.nextSibling;n?e[r].insertBefore(t,n):e[r].appendChild(t)},1)},replaceWith:function(e){return Y($(e)).insertAfter(this),this.remove()},addClass:function(e){return e=L.call(e).split(k),this.each(function(t){_(e,function(e){e&&!d(t,X(t,e))&&v(t,X(t,e))})})},removeClass:function(e){return e=L.call(e).split(k),this.each(function(t){_(e,function(e){e&&d(t,X(t,e))&&m(t,X(t,e))})})},hasClass:function(e){return e=L.call(e).split(k),q(this,function(t){return q(e,function(e){return e&&d(t,e)})})},toggleClass:function(e,t){return e=L.call(e).split(k),this.each(function(n){_(e,function(e){e&&(typeof t!="undefined"?t?v(n,e):m(n,e):d(n,e)?m(n,e):v(n,e))})})},show:function(e){return e=typeof e=="string"?e:"",this.each(function(t){t.style.display=e})},hide:function(){return this.each(function(e){e.style.display="none"})},toggle:function(e,t){return t=typeof t=="string"?t:"",typeof e!="function"&&(e=null),this.each(function(n){n.style.display=n.offsetWidth||n.offsetHeight?"none":t,e&&e.call(n)})},first:function(){return Y(this.length?this[0]:[])},last:function(){return Y(this.length?this[this.length-1]:[])},next:function(){return this.related("nextSibling")},previous:function(){return this.related("previousSibling")},parent:function(){return this.related(r)},related:function(e){return this.map(function(t){t=t[e];while(t&&t.nodeType!==1)t=t[e];return t||0},function(e){return e})},focus:function(){return this.length&&this[0].focus(),this},blur:function(){return this.length&&this[0].blur(),this},css:function(n,r){function o(e,t,n){for(var r in s)if(s.hasOwnProperty(r)){n=s[r],(t=R(r))&&b.test(n)&&!(t in A)&&(n+=E);try{e.style[t]=X(e,n)}catch(i){}}}var i,s=n;return r===undefined&&typeof n=="string"?(r=this[0],r?r===t||r===e?(i=r===t?Y.doc():Y.viewport(),n=="width"?i.width:n=="height"?i.height:""):(n=R(n))?U(r,n):null:null):(typeof n=="string"&&(s={},s[n]=r),p&&s.opacity&&(s.filter="alpha(opacity="+s.opacity*100+")",s.zoom=n.zoom||1,delete s.opacity),this.each(o))},offset:function(e,n){if(!e||typeof e!="object"||typeof e.top!="number"&&typeof e.left!="number"){if(typeof e=="number"||typeof n=="number")return this.each(function(t){W(t,e,n)});if(!this[0])return{top:0,left:0,height:0,width:0};var r=this[0],i=r.ownerDocument.documentElement,s=r.getBoundingClientRect(),o=G(),u=r.offsetWidth,a=r.offsetHeight,f=s.top+o.y-Math.max(0,i&&i.clientTop,t.body.clientTop),l=s.left+o.x-Math.max(0,i&&i.clientLeft,t.body.clientLeft);return{top:f,left:l,height:a,width:u}}return this.each(function(t){W(t,e.left,e.top)})},dim:function(){if(!this.length)return{height:0,width:0};var e=this[0],t=e.nodeType==9&&e.documentElement,n=!t&&!!e.style&&!e.offsetWidth&&!e.offsetHeight?function(t){var n={position:e.style.position||"",visibility:e.style.visibility||"",display:e.style.display||""};return t.first().css({position:"absolute",visibility:"hidden",display:"block"}),n}(this):null,r=t?Math.max(e.body.scrollWidth,e.body.offsetWidth,t.scrollWidth,t.offsetWidth,t.clientWidth):e.offsetWidth,i=t?Math.max(e.body.scrollHeight,e.body.offsetHeight,t.scrollWidth,t.offsetWidth,t.clientHeight):e.offsetHeight;return n&&this.first().css(n),{height:i,width:r}},attr:function(e,t){var n=this[0];if(typeof e=="string"||e instanceof String)return typeof t=="undefined"?n?s.test(e)?h.test(e)&&typeof n[e]=="string"?!0:n[e]:e!="href"&&e!="src"||!N.hrefExtended?n[x](e):n[x](e,2):null:this.each(function(n){s.test(e)?n[e]=X(n,t):n[S](e,X(n,t))});for(var r in e)e.hasOwnProperty(r)&&this.attr(r,e[r]);return this},removeAttr:function(e){return this.each(function(t){h.test(e)?t[e]=!1:t.removeAttribute(e)})},val:function(e){return typeof e=="string"?this.attr("value",e):this.length?this[0].value:null},data:function(e,t){var n=this[0],r,i;return typeof t=="undefined"?n?(r=B(n),typeof e=="undefined"?(_(n.attributes,function(e){(i=(""+e.name).match(w))&&(r[P(i[1])]=F(e.value))}),r):(typeof r[e]=="undefined"&&(r[e]=F(this.attr("data-"+H(e)))),r[e])):null:this.each(function(n){B(n)[e]=t})},remove:function(){return this.deepEach(j),this.detach()},empty:function(){return this.each(function(e){D(e.childNodes,j);while(e.firstChild)e.removeChild(e.firstChild)})},detach:function(){return this.each(function(e){e[r]&&e[r].removeChild(e)})},scrollTop:function(e){return K.call(this,null,e,"y")},scrollLeft:function(e){return K.call(this,e,null,"x")}},Y.setQueryEngine=function(e){i=e,delete Y.setQueryEngine},Y.aug=function(e,t){for(var n in e)e.hasOwnProperty(n)&&((t||V.prototype)[n]=e[n])},Y.create=function(e){return typeof e=="string"&&e!==""?function(){var n=/^\s*<([^\s>]+)/.exec(e),i=t.createElement("div"),s=[],o=n?c[n[1].toLowerCase()]:null,u=o?o[2]+1:1,a=o&&o[3],f=r,l=N.autoTbody&&o&&o[0]=="<table>"&&!/<tbody/i.test(e);i.innerHTML=o?o[0]+e+o[1]:e;while(u--)i=i.firstChild;a&&i&&i.nodeType!==1&&(i=i.nextSibling);do(!n||i.nodeType==1)&&(!l||i.tagName.toLowerCase()!="tbody")&&s.push(i);while(i=i.nextSibling);return _(s,function(e){e[f]&&e[f].removeChild(e)}),s}():I(e)?[e.cloneNode(!0)]:[]},Y.doc=function(){var e=Y.viewport();return{width:Math.max(t.body.scrollWidth,n.scrollWidth,e.width),height:Math.max(t.body.scrollHeight,n.scrollHeight,e.height)}},Y.firstChild=function(e){for(var t=e.childNodes,n=0,r=t&&t.length||0,i;n<r;n++)t[n].nodeType===1&&(i=t[r=n]);return i},Y.viewport=function(){return{width:p?n.clientWidth:self.innerWidth,height:p?n.clientHeight:self.innerHeight}},Y.isAncestor="compareDocumentPosition"in n?function(e,t){return(e.compareDocumentPosition(t)&16)==16}:"contains"in n?function(e,t){return e!==t&&e.contains(t)}:function(e,t){while(t=t[r])if(t===e)return!0;return!1},Y},this)
+(function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof t["define"]=="function"&&t.define.amd?define(e,n):t[e]=n()})("bonzo",this,function(){function M(e){return e&&e.nodeName&&(e.nodeType==1||e.nodeType==11)}function _(e,t,n){var r,i,s;if(typeof e=="string")return Y.create(e);M(e)&&(e=[e]);if(n){s=[];for(r=0,i=e.length;r<i;r++)s[r]=J(t,e[r]);return s}return e}function D(e){return new RegExp("(^|\\s+)"+e+"(\\s+|$)")}function P(e,t,n,r){var i,s=0,o=e.length;for(;s<o;s++)i=r?e.length-s-1:s,t.call(n||e[i],e[i],i,e);return e}function H(e,t,n){for(var r=0,i=e.length;r<i;r++)M(e[r])&&(H(e[r].childNodes,t,n),t.call(n||e[r],e[r],r,e));return e}function B(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}function j(e){return e?e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase():e}function F(e){e[x]("data-node-uid")||e[S]("data-node-uid",++y);var t=e[x]("data-node-uid");return g[t]||(g[t]={})}function I(e){var t=e[x]("data-node-uid");t&&delete g[t]}function q(e){var t;try{return e===null||e===undefined?undefined:e==="true"?!0:e==="false"?!1:e==="null"?null:(t=parseFloat(e))==e?t:e}catch(n){}return undefined}function R(e,t,n){for(var r=0,i=e.length;r<i;++r)if(t.call(n||null,e[r],r,e))return!0;return!1}function U(e){return e=="transform"&&(e=N.transform)||/^transform-?[Oo]rigin$/.test(e)&&(e=N.transform+"Origin")||e=="float"&&(e=N.cssFloat),e?B(e):null}function W(e,t,n,r){var s=0,o=t||this,u=[],a=i&&typeof e=="string"&&e.charAt(0)!="<"?i(e):e;return P(_(a),function(e,t){P(o,function(r){n(e,u[s++]=t>0?J(o,r):r)},null,r)},this,r),o.length=s,P(u,function(e){o[--s]=e},null,!r),o}function X(e,t,n){var r=Y(e),i=r.css("position"),s=r.offset(),o="relative",u=i==o,a=[parseInt(r.css("left"),10),parseInt(r.css("top"),10)];i=="static"&&(r.css("position",o),i=o),isNaN(a[0])&&(a[0]=u?0:e.offsetLeft),isNaN(a[1])&&(a[1]=u?0:e.offsetTop),t!=null&&(e.style.left=t-s.left+a[0]+E),n!=null&&(e.style.top=n-s.top+a[1]+E)}function V(e,t){return typeof t=="function"?t(e):t}function $(e){this.length=0;if(e){e=typeof e!="string"&&!e.nodeType&&typeof e.length!="undefined"?e:[e],this.length=e.length;for(var t=0;t<e.length;t++)this[t]=e[t]}}function J(e,t){var n=t.cloneNode(!0),r,i;if(e.$&&typeof e.cloneEvents=="function"){e.$(n).cloneEvents(t),r=e.$(n).find("*"),i=e.$(t).find("*");for(var s=0;s<i.length;s++)e.$(r[s]).cloneEvents(i[s])}return n}function K(t,n,r){var i=this[0];return i?t==null&&n==null?(Q(i)?G():{x:i.scrollLeft,y:i.scrollTop})[r]:(Q(i)?e.scrollTo(t,n):(t!=null&&(i.scrollLeft=t),n!=null&&(i.scrollTop=n)),this):this}function Q(t){return t===e||/^(?:body|html)$/i.test(t.tagName)}function G(){return{x:e.pageXOffset||n.scrollLeft,y:e.pageYOffset||n.scrollTop}}function Y(e){return new $(e)}var e=window,t=e.document,n=t.documentElement,r="parentNode",i=null,s=/^(checked|value|selected|disabled)$/i,o=/^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i,u=["<table>","</table>",1],a=["<table><tbody><tr>","</tr></tbody></table>",3],f=["<select>","</select>",1],l=["_","",0,1],c={thead:u,tbody:u,tfoot:u,colgroup:u,caption:u,tr:["<table><tbody>","</tbody></table>",2],th:a,td:a,col:["<table><colgroup>","</colgroup></table>",2],fieldset:["<form>","</form>",1],legend:["<form><fieldset>","</fieldset></form>",2],option:f,optgroup:f,script:l,style:l,link:l,param:l,base:l},h=/^(checked|selected|disabled)$/,p=/msie/i.test(navigator.userAgent),d,v,m,g={},y=0,b=/^-?[\d\.]+$/,w=/^data-(.+)$/,E="px",S="setAttribute",x="getAttribute",T="getElementsByTagName",N=function(){var e=t.createElement("p");return e.innerHTML='<a href="#x">x</a><table style="float:left;"></table>',{hrefExtended:e[T]("a")[0][x]("href")!="#x",autoTbody:e[T]("tbody").length!==0,computedStyle:t.defaultView&&t.defaultView.getComputedStyle,cssFloat:e[T]("table")[0].style.styleFloat?"styleFloat":"cssFloat",transform:function(){var t=["transform","webkitTransform","MozTransform","OTransform","msTransform"],n;for(n=0;n<t.length;n++)if(t[n]in e.style)return t[n]}(),classList:"classList"in e,opasity:function(){return typeof t.createElement("a").style.opacity!="undefined"}()}}(),C=/(^\s*|\s*$)/g,k=/\s+/,L=String.prototype.toString,A={lineHeight:1,zoom:1,zIndex:1,opacity:1,boxFlex:1,WebkitBoxFlex:1,MozBoxFlex:1},O=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(C,"")},z=N.computedStyle?function(e,n){var r=null,i=t.defaultView.getComputedStyle(e,"");return i&&(r=i[n]),e.style[n]||r}:p&&n.currentStyle?function(e,t){if(t=="opacity"&&!N.opasity){var n=100;try{n=e.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(r){try{n=e.filters("alpha").opacity}catch(i){}}return n/100}var s=e.currentStyle?e.currentStyle[t]:null;return e.style[t]||s}:function(e,t){return e.style[t]};return N.classList?(d=function(e,t){return e.classList.contains(t)},v=function(e,t){e.classList.add(t)},m=function(e,t){e.classList.remove(t)}):(d=function(e,t){return D(t).test(e.className)},v=function(e,t){e.className=O(e.className+" "+t)},m=function(e,t){e.className=O(e.className.replace(D(t)," "))}),$.prototype={get:function(e){return this[e]||null},each:function(e,t){return P(this,e,t)},deepEach:function(e,t){return H(this,e,t)},map:function(e,t){var n=[],r,i;for(i=0;i<this.length;i++)r=e.call(this,this[i],i),t?t(r)&&n.push(r):n.push(r);return n},html:function(e,t){var r=t?n.textContent===undefined?"innerText":"textContent":"innerHTML",i=this,s=function(t,n){P(_(e,i,n),function(e){t.appendChild(e)})},u=function(n,i){try{if(t||typeof e=="string"&&!o.test(n.tagName))return n[r]=e}catch(u){}s(n,i)};return typeof e!="undefined"?this.empty().each(u):this[0]?this[0][r]:""},text:function(e){return this.html(e,!0)},append:function(e){var t=this;return this.each(function(n,r){P(_(e,t,r),function(e){n.appendChild(e)})})},prepend:function(e){var t=this;return this.each(function(n,r){var i=n.firstChild;P(_(e,t,r),function(e){n.insertBefore(e,i)})})},appendTo:function(e,t){return W.call(this,e,t,function(e,t){e.appendChild(t)})},prependTo:function(e,t){return W.call(this,e,t,function(e,t){e.insertBefore(t,e.firstChild)},1)},before:function(e){var t=this;return this.each(function(n,i){P(_(e,t,i),function(e){n[r].insertBefore(e,n)})})},after:function(e){var t=this;return this.each(function(n,i){P(_(e,t,i),function(e){n[r].insertBefore(e,n.nextSibling)},null,1)})},insertBefore:function(e,t){return W.call(this,e,t,function(e,t){e[r].insertBefore(t,e)})},insertAfter:function(e,t){return W.call(this,e,t,function(e,t){var n=e.nextSibling;n?e[r].insertBefore(t,n):e[r].appendChild(t)},1)},replaceWith:function(e){return Y(_(e)).insertAfter(this),this.remove()},addClass:function(e){return e=L.call(e).split(k),this.each(function(t){P(e,function(e){e&&!d(t,V(t,e))&&v(t,V(t,e))})})},removeClass:function(e){return e=L.call(e).split(k),this.each(function(t){P(e,function(e){e&&d(t,V(t,e))&&m(t,V(t,e))})})},hasClass:function(e){return e=L.call(e).split(k),R(this,function(t){return R(e,function(e){return e&&d(t,e)})})},toggleClass:function(e,t){return e=L.call(e).split(k),this.each(function(n){P(e,function(e){e&&(typeof t!="undefined"?t?v(n,e):m(n,e):d(n,e)?m(n,e):v(n,e))})})},show:function(e){return e=typeof e=="string"?e:"",this.each(function(t){t.style.display=e})},hide:function(){return this.each(function(e){e.style.display="none"})},toggle:function(e,t){return t=typeof t=="string"?t:"",typeof e!="function"&&(e=null),this.each(function(n){n.style.display=n.offsetWidth||n.offsetHeight?"none":t,e&&e.call(n)})},first:function(){return Y(this.length?this[0]:[])},last:function(){return Y(this.length?this[this.length-1]:[])},next:function(){return this.related("nextSibling")},previous:function(){return this.related("previousSibling")},parent:function(){return this.related(r)},related:function(e){return this.map(function(t){t=t[e];while(t&&t.nodeType!==1)t=t[e];return t||0},function(e){return e})},focus:function(){return this.length&&this[0].focus(),this},blur:function(){return this.length&&this[0].blur(),this},css:function(n,r){function o(e,t,n){for(var r in s)if(s.hasOwnProperty(r)){n=s[r],(t=U(r))&&b.test(n)&&!(t in A)&&(n+=E);try{e.style[t]=V(e,n)}catch(i){}}}var i,s=n;return r===undefined&&typeof n=="string"?(r=this[0],r?r===t||r===e?(i=r===t?Y.doc():Y.viewport(),n=="width"?i.width:n=="height"?i.height:""):(n=U(n))?z(r,n):null:null):(typeof n=="string"&&(s={},s[n]=r),p&&s.opacity&&(s.filter="alpha(opacity="+s.opacity*100+")",s.zoom=n.zoom||1,delete s.opacity),this.each(o))},offset:function(e,n){if(!e||typeof e!="object"||typeof e.top!="number"&&typeof e.left!="number"){if(typeof e=="number"||typeof n=="number")return this.each(function(t){X(t,e,n)});if(!this[0])return{top:0,left:0,height:0,width:0};var r=this[0],i=r.ownerDocument.documentElement,s=r.getBoundingClientRect(),o=G(),u=r.offsetWidth,a=r.offsetHeight,f=s.top+o.y-Math.max(0,i&&i.clientTop,t.body.clientTop),l=s.left+o.x-Math.max(0,i&&i.clientLeft,t.body.clientLeft);return{top:f,left:l,height:a,width:u}}return this.each(function(t){X(t,e.left,e.top)})},dim:function(){if(!this.length)return{height:0,width:0};var e=this[0],t=e.nodeType==9&&e.documentElement,n=!t&&!!e.style&&!e.offsetWidth&&!e.offsetHeight?function(t){var n={position:e.style.position||"",visibility:e.style.visibility||"",display:e.style.display||""};return t.first().css({position:"absolute",visibility:"hidden",display:"block"}),n}(this):null,r=t?Math.max(e.body.scrollWidth,e.body.offsetWidth,t.scrollWidth,t.offsetWidth,t.clientWidth):e.offsetWidth,i=t?Math.max(e.body.scrollHeight,e.body.offsetHeight,t.scrollWidth,t.offsetWidth,t.clientHeight):e.offsetHeight;return n&&this.first().css(n),{height:i,width:r}},attr:function(e,t){var n=this[0];if(typeof e=="string"||e instanceof String)return typeof t=="undefined"?n?s.test(e)?h.test(e)&&typeof n[e]=="string"?!0:n[e]:e!="href"&&e!="src"||!N.hrefExtended?n[x](e):n[x](e,2):null:this.each(function(n){s.test(e)?n[e]=V(n,t):n[S](e,V(n,t))});for(var r in e)e.hasOwnProperty(r)&&this.attr(r,e[r]);return this},removeAttr:function(e){return this.each(function(t){h.test(e)?t[e]=!1:t.removeAttribute(e)})},val:function(e){return typeof e=="string"?this.attr("value",e):this.length?this[0].value:null},data:function(e,t){var n=this[0],r,i;return typeof t=="undefined"?n?(r=F(n),typeof e=="undefined"?(P(n.attributes,function(e){(i=(""+e.name).match(w))&&(r[B(i[1])]=q(e.value))}),r):(typeof r[e]=="undefined"&&(r[e]=q(this.attr("data-"+j(e)))),r[e])):null:this.each(function(n){F(n)[e]=t})},remove:function(){return this.deepEach(I),this.detach()},empty:function(){return this.each(function(e){H(e.childNodes,I);while(e.firstChild)e.removeChild(e.firstChild)})},detach:function(){return this.each(function(e){e[r]&&e[r].removeChild(e)})},scrollTop:function(e){return K.call(this,null,e,"y")},scrollLeft:function(e){return K.call(this,e,null,"x")}},Y.setQueryEngine=function(e){i=e,delete Y.setQueryEngine},Y.aug=function(e,t){for(var n in e)e.hasOwnProperty(n)&&((t||$.prototype)[n]=e[n])},Y.create=function(e){return typeof e=="string"&&e!==""?function(){var n=/^\s*<([^\s>]+)/.exec(e),i=t.createElement("div"),s=[],o=n?c[n[1].toLowerCase()]:null,u=o?o[2]+1:1,a=o&&o[3],f=r,l=N.autoTbody&&o&&o[0]=="<table>"&&!/<tbody/i.test(e);i.innerHTML=o?o[0]+e+o[1]:e;while(u--)i=i.firstChild;a&&i&&i.nodeType!==1&&(i=i.nextSibling);do(!n||i.nodeType==1)&&(!l||i.tagName.toLowerCase()!="tbody")&&s.push(i);while(i=i.nextSibling);return P(s,function(e){e[f]&&e[f].removeChild(e)}),s}():M(e)?[e.cloneNode(!0)]:[]},Y.doc=function(){var e=Y.viewport();return{width:Math.max(t.body.scrollWidth,n.scrollWidth,e.width),height:Math.max(t.body.scrollHeight,n.scrollHeight,e.height)}},Y.firstChild=function(e){for(var t=e.childNodes,n=0,r=t&&t.length||0,i;n<r;n++)t[n].nodeType===1&&(i=t[r=n]);return i},Y.viewport=function(){return{width:p?n.clientWidth:self.innerWidth,height:p?n.clientHeight:self.innerHeight}},Y.isAncestor="compareDocumentPosition"in n?function(e,t){return(e.compareDocumentPosition(t)&16)==16}:"contains"in n?function(e,t){return e!==t&&e.contains(t)}:function(e,t){while(t=t[r])if(t===e)return!0;return!1},Y})
View
2 component.json
@@ -1,7 +1,7 @@
{
"name": "bonzo"
, "description": "Library agnostic, extensible DOM utility"
- , "version": "1.2.1"
+ , "version": "1.2.8"
, "homepage": "https://github.com/ded/bonzo"
, "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)"
, "contributors": [
View
2 make/build.js
@@ -7,7 +7,7 @@
]
}
, "JSHINT_OPTS": {
- "predef": [ "assert", "refute", "define", "self" ]
+ "predef": ["assert", "refute", "define", "self"]
, "boss": true
, "shadow": true
, "trailing": true
View
4 package.json
@@ -1,7 +1,7 @@
{
"name": "bonzo"
, "description": "Library agnostic, extensible DOM utility"
- , "version": "1.2.7-1"
+ , "version": "1.2.8"
, "homepage": "https://github.com/ded/bonzo"
, "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)"
, "contributors": [
@@ -18,6 +18,6 @@
"qwery": "*"
, "bowser": "*"
, "sink-test": "*"
- , "smoosh": "*"
+ , "smoosh": "0.4.0"
}
}
View
39 src/bonzo.js
@@ -1,8 +1,8 @@
-(function (name, definition, context) {
+(function (name, context, definition) {
if (typeof module != 'undefined' && module.exports) module.exports = definition()
else if (typeof context['define'] == 'function' && context['define']['amd']) define(name, definition)
else context[name] = definition()
-})('bonzo', function() {
+})('bonzo', this, function() {
var win = window
, doc = win.document
, html = doc.documentElement
@@ -68,6 +68,24 @@
}
+ function isNode(node) {
+ return node && node.nodeName && (node.nodeType == 1 || node.nodeType == 11)
+ }
+
+
+ function normalize(node, host, clone) {
+ var i, l, ret
+ if (typeof node == 'string') return bonzo.create(node)
+ if (isNode(node)) node = [ node ]
+ if (clone) {
+ ret = [] // don't change original array
+ for (i = 0, l = node.length; i < l; i++) ret[i] = cloneNode(host, node[i])
+ return ret
+ }
+ return node
+ }
+
+
/**
* @param {string} c a class name to test
* @return {boolean}
@@ -164,10 +182,6 @@
return undefined
}
- function isNode(node) {
- return node && node.nodeName && (node.nodeType == 1 || node.nodeType == 11)
- }
-
/**
* @param {Bonzo|Array} ar
@@ -972,17 +986,6 @@
}
- function normalize(node, host, clone) {
- var i, l, ret
- if (typeof node == 'string') return bonzo.create(node)
- if (isNode(node)) node = [ node ]
- if (clone) {
- ret = [] // don't change original array
- for (i = 0, l = node.length; i < l; i++) ret[i] = cloneNode(host, node[i])
- return ret
- }
- return node
- }
function cloneNode(host, el) {
var c = el.cloneNode(true)
@@ -1118,4 +1121,4 @@
}
return bonzo
-}, this); // the only line we care about using a semi-colon. placed here for concatenation tools
+}); // the only line we care about using a semi-colon. placed here for concatenation tools

0 comments on commit 868db53

Please sign in to comment.