-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdombrew.min.js
1 lines (1 loc) · 2.48 KB
/
dombrew.min.js
1
(function(){var e,t,n;n=document,t=function(){function e(e,t,s){var l,p,a,c,f;if(null==t&&(t={}),e.nodeType)return void(this.e=e);if(""===e)return void(this.e=n.createTextNode(t));if("string"==typeof t&&(s||(s={}),s.text=t,t=s),this.e=n.createElement(o(e,t)),t["class"]&&(this.e.className=i(t["class"]))&&delete t["class"],t.text&&(this.e.innerText=i(t.text))&&delete t.text,t.html&&(this.e.innerHTML=i(t.html))&&delete t.html,t.css&&(c=this.e.style)&&(l=t.css)&&delete t.css)for(a in l)f=l[a],null!=f&&(c[a]=f);r(t);for(p in t)f=t[p],this.e.setAttribute(p,f)}var t,r,i,o;return r=function(e){var t,n,r,i;for(t in e)if(n=e[t],"object"==typeof e[t]){for(r in n)i=n[r],e[t+"-"+r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()]=i;delete e[t]}},t=/[.#]/,o=function(e,n){var r,i,o,s,l,p,a;if(!t.test(e))return e;for(n["class"]||(n["class"]=[]),"string"==typeof n["class"]&&(n["class"]=[n["class"]]),t.test(e.charAt(0))&&(e="div"+e),s=e.split(t),i=s.shift(),l=i.length,r=n["class"],p=0,a=s.length;a>p;p++)o=s[p],"#"===e.charAt(l)?n.id=o:r.push(o),l+=o.length+1;return n["class"].length||delete n["class"],i},i=function(e){var t,n,r;if("object"!=typeof e)return e;for(r=[],t=-1,n=e.length;++t<n;)e[t]&&r.push(e[t]);return r.join(" ")},e.prototype.append=function(){var e,t,n,r;e=arguments,e&&e[0]&&"splice"in e[0]&&(e=e[0]);for(n=0,r=e.length;r>n;n++)t=e[n],t&&("_brew"in t&&(t=t.dom()),this.e.appendChild(t));return this},e.prototype.prepend=function(){var e,t,n,r;e=arguments,e&&e[0]&&"splice"in e[0]&&(e=e[0]);for(n=0,r=e.length;r>n;n++)t=e[n],t&&("_brew"in t&&(t=t.dom()),this.e.insertBefore(t,this.e.firstChild));return this},e.prototype.dom=function(){return this.e},e.prototype.html=function(){var e;return e=n.createElement("div"),e.appendChild(this.e),e.innerHTML},e}(),t.prototype.asDOM=t.prototype.dom,t.prototype.asHTML=t.prototype.html,t.prototype._brew=1,this.DOMBrew=e=function(){var e,r,i,o,s,l;if(e=arguments,"object"==typeof e[0]&&"splice"in e[0]?o=e[0]:e.length>1&&"object"==typeof e[1]&&"_brew"in e[1]&&(o=e),o){for(r=n.createDocumentFragment(),s=0,l=o.length;l>s;s++)i=o[s],r.appendChild(i.e?i.e:i);e=[r]}return new t(e[0],e[1],e[2])},e.text=function(e){return new t("",e)},e.VERSION=e.version="1.5.0","Microsoft Internet Explorer"!==navigator.appName&&!("innerText"in HTMLElement.prototype)&&"__defineGetter__"in HTMLElement&&(HTMLElement.prototype.__defineGetter__("innerText",function(){return this.textContent}),HTMLElement.prototype.__defineSetter__("innerText",function(e){return this.textContent=e}))}).call(this);