cssx
Version:
CSS in JavaScript
2 lines • 10.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cssx",[],t):"object"==typeof exports?exports.cssx=t():e.cssx=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(e){var t,n;for("undefined"==typeof e&&(e=c()),n=0;n<u.length;n++)if(u[n].id()===e)return u[n];return t=o.apply(o,arguments),u.push(t),t}var o,i,u,s,c,f=[];n(1),o=n(5),i=n(15),c=n(16),u=[],s=function(e){return r(e,f)},s.domChanges=function(e){o.disableDOMChanges=!e},s.minify=function(e){o.minify=e},s.nextTick=function(e){o.useNextTick=e},s.getStylesheets=function(){return u},s.clear=function(){var e;for(e=0;e<u.length;e++)u[e].clear();return u=[],s},s.getCSS=function(){var e,t="";for(e=0;e<u.length;e++)t+=u[e].getCSS();return t},s.plugins=function(e){f=f.concat(e)},e.exports=s,i(e.exports)},function(e,t,n){n(2),n(3),n(4)},function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e){"use strict";if(void 0===this||null===this)throw new TypeError;var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=[],o=arguments.length>=2?arguments[1]:void 0,i=0;n>i;i++)if(i in t){var u=t[i];e.call(o,u,i,t)&&r.push(u)}return r})},function(e,t){Array.prototype.forEach||(Array.prototype.forEach=function(e,t){var n,r;if(null==this)throw new TypeError(" this is null or not defined");var o=Object(this),i=o.length>>>0;if("function"!=typeof e)throw new TypeError(e+" is not a function");for(arguments.length>1&&(n=t),r=0;i>r;){var u;r in o&&(u=o[r],e.call(n,u,r,o)),r++}})},function(e,t){Array.prototype.map||(Array.prototype.map=function(e,t){var n,r,o;if(null==this)throw new TypeError(" this is null or not defined");var i=Object(this),u=i.length>>>0;if("function"!=typeof e)throw new TypeError(e+" is not a function");for(arguments.length>1&&(n=t),r=new Array(u),o=0;u>o;){var s,c;o in i&&(s=i[o],c=e.call(n,s,o,i),r[o]=c),o++}return r})},function(e,t,n){var r=n(6),o=n(8),i=n(9),u=n(13),s=n(7),c=0,f=function(){return"x"+ ++c};e.exports=function(t,n){var c=t||f(),l={},a=[],p={},d=null,h="",m="",y=function(e,t,n){return e.reduce(function(e,r){return e!==!1?e:r.selector===t?n?r.parent&&n.selector===r.parent.selector?r:!1:r:!1},!1)},v=function(e,t){"undefined"!=typeof t?a.splice(t,0,e):a.push(e),e.index=a.length-1},g=function(e){return"object"!=typeof e?!0:s(e)?"string"==typeof e[0]:!1};return l.id=function(){return c},l.add=l.update=function(e,t,n,o){var i,u,c,f,p,d,h,m,x=[];"string"==typeof e&&(m={},m[e]={},e=m),"function"==typeof e&&(e=e());for(h in e)if(s(e[h]))e[h].forEach(function(e){m={},m[h]=e,l.add(m,t,void 0,!0)});else{if(i=y(a,h,t),f={},p={},d=[],o||!i){p=e[h];for(u in p)g(p[u])?f[u]=p[u]:(c={},c[u]=p[u],d.push(c));i=r(h,this.resolveCustomProps(f),l),t?(i.parent=t,t.registerNested(i)):v(i,n),d.forEach(function(e){l.add(e,i)})}else i.update(e[h]);this.compile(),x.push(i)}return 1===x.length?x[0]:x},l.rules=function(){return a},l.compile=function(){return e.exports.useNextTick?(i(function(){l.compileImmediate()},c),l):l.compileImmediate()},l.compileImmediate=function(){return h=u(a,e.exports.minify,n,m),e.exports.disableDOMChanges||(d=o(h,c)),l},l.clear=function(){return a=[],h="",null!==d&&(d(),d=null),l},l.destroy=function(){return l.clear()},l.getCSS=function(){return this.compileImmediate(),h},l.define=function(e,t){p[e]=t},l.scope=function(e){m=e},l._getCustomProps=function(){return p},l.resolveCustomProps=function(e){var t,n,r,o=e,i=p;for(t in i)if("undefined"!=typeof e[t]){r=i[t](e[t]),delete e[t];for(n in r)e[n]=r[n]}return o},l},e.exports.disableDOMChanges=!1,e.exports.minify=!0,e.exports.useNextTick=!0},function(e,t,n){var r=n(7);e.exports=function o(e,t,n){var i={selector:e,props:t,stylesheet:n,index:null,nestedRules:null,parent:null};return i.clone=function(){var e=o(this.selector,this.props,this.stylesheet);return e.index=this.index,e.nestedRules=this.nestedRules,e.parent=this.parent,e},i.descendant=i.d=function(e){var t;"function"==typeof e&&(e=e());for(t in e)e[i.selector+" "+t]=e[t],delete e[t];return i.stylesheet.add(e,this.parent,this.index)},i.nested=i.n=function(e){return i.stylesheet.add(e,this)},i.update=function(e){var t,n=null!==this.nestedRules;"function"==typeof e&&(e=e()),e=this.stylesheet.resolveCustomProps(e);for(t in e)"object"!=typeof e[t]?this.props[t]=e[t]:n&&this.nestedRules[t]&&this.nestedRules[t].update(e[t]);return this},i.registerNested=function(e){var t;return null===this.nestedRules&&(this.nestedRules={}),t=this.nestedRules[e.selector],t?r(t)?t.push(e):this.nestedRules[e.selector]=[t,e]:this.nestedRules[e.selector]=e,this},i}},function(e,t){e.exports=function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t){var n={},r=function(e){return document.querySelector(e)},o=function(e,t,n){var o,i,u=document.createElement(e);for(o=0;o<t.length;o++)i=t[o],u.setAttribute(i.name,i.value);return u.innerHTML=n,(r("head")||r("body")).appendChild(u),u},i=function(e){return function(){n[e]&&(n[e].el.parentNode.removeChild(n[e].el),delete n[e])}};e.exports=function(e,t){var r;return n[t]?n[t].css!==e&&(n[t].css=e,n[t].el.innerHTML=e):(r=o("style",[{name:"id",value:t},{name:"type",value:"text/css"}],e),n[t]={el:r,css:e,remove:i(t)}),n[t].remove}},function(e,t,n){(function(t){var r={};n(12),e.exports=function(e,n){r[n]||(r[n]=e,t(function(){delete r[n],e()}))}}).call(t,n(10).setImmediate)},function(e,t,n){(function(e,r){function o(e,t){this._id=e,this._clearFn=t}var i=n(11).nextTick,u=Function.prototype.apply,s=Array.prototype.slice,c={},f=0;t.setTimeout=function(){return new o(u.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new o(u.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},t.setImmediate="function"==typeof e?e:function(e){var n=f++,r=arguments.length<2?!1:s.call(arguments,1);return c[n]=!0,i(function(){c[n]&&(r?e.apply(null,r):e.call(null),t.clearImmediate(n))}),n},t.clearImmediate="function"==typeof r?r:function(e){delete c[e]}}).call(t,n(10).setImmediate,n(10).clearImmediate)},function(e,t){function n(){f=!1,u.length?c=u.concat(c):l=-1,c.length&&r()}function r(){if(!f){var e=setTimeout(n);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,clearTimeout(e)}}function o(e,t){this.fun=e,this.array=t}function i(){}var u,s=e.exports={},c=[],f=!1,l=-1;s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new o(e,t)),1!==c.length||f||setTimeout(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=i,s.addListener=i,s.once=i,s.off=i,s.removeListener=i,s.removeAllListeners=i,s.emit=i,s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(e,t,n){(function(e,t,n){!function(e,t){"use strict";function r(e){return m[h]=o.apply(t,e),h++}function o(e){var n=[].slice.call(arguments,1);return function(){"function"==typeof e?e.apply(t,n):new Function(""+e)()}}function i(e){if(y)setTimeout(o(i,e),0);else{var t=m[e];if(t){y=!0;try{t()}finally{u(e),y=!1}}}}function u(e){delete m[e]}function s(){d=function(){var e=r(arguments);return n.nextTick(o(i,e)),e}}function c(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}function f(){var t="setImmediate$"+Math.random()+"$",n=function(n){n.source===e&&"string"==typeof n.data&&0===n.data.indexOf(t)&&i(+n.data.slice(t.length))};e.addEventListener?e.addEventListener("message",n,!1):e.attachEvent("onmessage",n),d=function(){var n=r(arguments);return e.postMessage(t+n,"*"),n}}function l(){var e=new MessageChannel;e.port1.onmessage=function(e){var t=e.data;i(t)},d=function(){var t=r(arguments);return e.port2.postMessage(t),t}}function a(){var e=v.documentElement;d=function(){var t=r(arguments),n=v.createElement("script");return n.onreadystatechange=function(){i(t),n.onreadystatechange=null,e.removeChild(n),n=null},e.appendChild(n),t}}function p(){d=function(){var e=r(arguments);return setTimeout(o(i,e),0),e}}if(!e.setImmediate){var d,h=1,m={},y=!1,v=e.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(e);g=g&&g.setTimeout?g:e,"[object process]"==={}.toString.call(e.process)?s():c()?f():e.MessageChannel?l():v&&"onreadystatechange"in v.createElement("script")?a():p(),g.setImmediate=d,g.clearImmediate=u}}("undefined"==typeof self?"undefined"==typeof e?this:e:self)}).call(t,function(){return this}(),n(10).clearImmediate,n(11))},function(e,t,n){var r=n(14),o=n(7);e.exports=function(e,t,n,i){var u=function(e){return""===i?e:0===e.indexOf(i)||0===e.indexOf("@")?e:i+" "+e},s=function(e){var t;for(t=0;t<n.length;t++)e=n[t](e);return e},c=t?"":"\n",f=t?"":" ",l=t?"":" ",a=function(e,n){var i,p,d,h,m="",y=function(e,t){m+=e+(t?"":c)},v=function(e){if(!r(e.props)||null!==e.nestedRules){y(n+u(e.selector)+f+"{"),d=s(e.props);for(p in d)h="function"==typeof d[p]?d[p]():d[p],o(h)?h.forEach(function(e){y(n+l+p+":"+f+e+";")}):y(n+l+p+":"+f+h+";");e.nestedRules&&y(a(e.nestedRules,n+l),!0),y(n+"}")}};if(n=t?"":n,o(e))e.forEach(v);else for(i in e)o(e[i])?e[i].forEach(v):v(e[i]);return m};return a(e,"")}},function(e,t){e.exports=function(e){var t;for(t in e)if(e.hasOwnProperty(t))return!1;return!0}},function(e,t){(function(t){e.exports=function(e){"undefined"!=typeof t&&(t.cssx=e),"undefined"!=typeof window&&(window.cssx=e)}}).call(t,function(){return this}())},function(e,t){var n=0;e.exports=function(){return"_cssx"+ ++n},e.exports.resetIDs=function(){n=0}}])});
//# sourceMappingURL=cssx.min.js.map