diff --git a/bonzo.js b/bonzo.js index 7642e91..4a3c085 100644 --- a/bonzo.js +++ b/bonzo.js @@ -270,10 +270,10 @@ return classReg(c).test(el.className) } addClass = function (el, c) { - el.className = (el.className + ' ' + c).trim() + el.className = (el.className + ' ' + c).replace(/^\s/, ''); } removeClass = function (el, c) { - el.className = (el.className.replace(classReg(c), ' ')).trim() + el.className = (el.className.replace(classReg(c), ' ')).replace(/^\s|\s$/g, ''); } } diff --git a/bonzo.min.js b/bonzo.min.js index 7ebe25d..e19f0ee 100644 --- a/bonzo.min.js +++ b/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=n():typeof define=="function"&&define.amd?define(n):t[e]=n()})("bonzo",this,function(){function L(e,n){var r=null,i=t.defaultView.getComputedStyle(e,"");return i&&(r=i[n]),e.style[n]||r}function A(e){return e&&e.nodeName&&(e.nodeType==1||e.nodeType==11)}function O(e,t,n){var r,i,s;if(typeof e=="string")return Q.create(e);A(e)&&(e=[e]);if(n){s=[];for(r=0,i=e.length;r0?V(s,r):r)},null,r)},this,r),s.length=i,_(o,function(e){s[--i]=e},null,!r),s}function U(e,t,n){var r=Q(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]+w),n!=null&&(e.style.top=n-s.top+a[1]+w)}function z(e,t){return typeof t=="function"?t.call(e,e):t}function W(t,n,r){var i=this[0];return i?t==null&&n==null?($(i)?J():{x:i.scrollLeft,y:i.scrollTop})[r]:($(i)?e.scrollTo(t,n):(t!=null&&(i.scrollLeft=t),n!=null&&(i.scrollTop=n)),this):this}function X(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/,u=["","
",1],a=["","
",3],f=["",1],l=["_","",0,1],c={thead:u,tbody:u,tfoot:u,colgroup:u,caption:u,tr:["","
",2],th:a,td:a,col:["","
",2],fieldset:["
","
",1],legend:["
","
",2],option:f,optgroup:f,script:l,style:l,link:l,param:l,base:l},h=/^(checked|selected|disabled)$/,p,d,v,m={},g=0,y=/^-?[\d\.]+$/,b=/^data-(.+)$/,w="px",E="setAttribute",S="getAttribute",x=function(){var e=t.createElement("p");return{transform:function(){var t=["transform","webkitTransform","MozTransform","OTransform","msTransform"],n;for(n=0;n]+)/),i=t.createElement("div"),s=[],u=n?c[n[1].toLowerCase()]:null,a=u?u[2]+1:1,f=u&&u[3],l=r;i.innerHTML=u?u[0]+e+u[1]:e;while(a--)i=i.firstChild;f&&i&&i.nodeType!==1&&(i=i.nextSibling);do(!n||i.nodeType==1)&&s.push(i);while(i=i.nextSibling);return _(s,function(e){e[l]&&e[l].removeChild(e)}),s}():A(e)?[e.cloneNode(!0)]:[]},Q.doc=function(){var e=Q.viewport();return{width:Math.max(t.body.scrollWidth,n.scrollWidth,e.width),height:Math.max(t.body.scrollHeight,n.scrollHeight,e.height)}},Q.firstChild=function(e){for(var t=e.childNodes,n=0,r=t&&t.length||0,i;n0?V(s,r):r)},null,r)},this,r),s.length=i,_(o,function(e){s[--i]=e},null,!r),s}function U(e,t,n){var r=Q(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]+w),n!=null&&(e.style.top=n-s.top+a[1]+w)}function z(e,t){return typeof t=="function"?t.call(e,e):t}function W(t,n,r){var i=this[0];return i?t==null&&n==null?($(i)?J():{x:i.scrollLeft,y:i.scrollTop})[r]:($(i)?e.scrollTo(t,n):(t!=null&&(i.scrollLeft=t),n!=null&&(i.scrollTop=n)),this):this}function X(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/,u=["","
",1],a=["","
",3],f=["",1],l=["_","",0,1],c={thead:u,tbody:u,tfoot:u,colgroup:u,caption:u,tr:["","
",2],th:a,td:a,col:["","
",2],fieldset:["
","
",1],legend:["
","
",2],option:f,optgroup:f,script:l,style:l,link:l,param:l,base:l},h=/^(checked|selected|disabled)$/,p,d,v,m={},g=0,y=/^-?[\d\.]+$/,b=/^data-(.+)$/,w="px",E="setAttribute",S="getAttribute",x=function(){var e=t.createElement("p");return{transform:function(){var t=["transform","webkitTransform","MozTransform","OTransform","msTransform"],n;for(n=0;n]+)/),i=t.createElement("div"),s=[],u=n?c[n[1].toLowerCase()]:null,a=u?u[2]+1:1,f=u&&u[3],l=r;i.innerHTML=u?u[0]+e+u[1]:e;while(a--)i=i.firstChild;f&&i&&i.nodeType!==1&&(i=i.nextSibling);do(!n||i.nodeType==1)&&s.push(i);while(i=i.nextSibling);return _(s,function(e){e[l]&&e[l].removeChild(e)}),s}():A(e)?[e.cloneNode(!0)]:[]},Q.doc=function(){var e=Q.viewport();return{width:Math.max(t.body.scrollWidth,n.scrollWidth,e.width),height:Math.max(t.body.scrollHeight,n.scrollHeight,e.height)}},Q.firstChild=function(e){for(var t=e.childNodes,n=0,r=t&&t.length||0,i;n