Comparing version 0.1.5 to 0.1.6
@@ -1,2 +0,2 @@ | ||
/* version: 0.1.4 */ | ||
/* version: 0.1.6 */ | ||
var Absurd = (function(w) { | ||
@@ -151,3 +151,2 @@ var lib = { | ||
var clearing = function(props) { | ||
// plugins | ||
@@ -160,3 +159,2 @@ var plugins = API.getPlugins(); | ||
} | ||
// pseudo classes | ||
@@ -168,3 +166,8 @@ for(var prop in props) { | ||
} | ||
// ampersand | ||
for(var prop in props) { | ||
if(prop.charAt(0) === "&") { | ||
props[prop] = false; | ||
} | ||
} | ||
} | ||
@@ -177,5 +180,5 @@ var checkForNesting = function(selector, props, stylesheet) { | ||
addRule(selector + prop, props[prop], stylesheet); | ||
// check for ampersand operator | ||
} else if(prop.charAt(0) === "&") { | ||
addRule(selector + prop.substr(1, prop.length-1), props[prop], stylesheet); | ||
// check for ampersand operator | ||
} else if(/&/g.test(prop)) { | ||
addRule(prop.replace(/&/g, selector), props[prop], stylesheet); | ||
// check for media query | ||
@@ -182,0 +185,0 @@ } else if(prop.indexOf("@media") === 0 || prop.indexOf("@supports") === 0) { |
@@ -1,1 +0,1 @@ | ||
var Absurd=function(){var a={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{}}}},b=function(b){switch(b){case"/../processors/html/HTML.js":return a.processors.html.HTML}return function(){}},d="",e=function(){return function(b){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:a.processors.css.CSS()},f={},g={},h={},i={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return h},e.getStorage=function(){return g},e.flush=function(){f={},g=[]},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){i[a]||(i[a]=[]);for(var d=!1,e=0;c=i[a][e];e++)c===b&&(d=!0);d===!1?i[a].push(b):null},e.callHooks=function(a,b){if(i[a])for(var d=0;c=i[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var j in a.api)"compile"!==j&&(e[j]=a.api[j](e),e[j]=function(b){return function(){var c=a.api[b](e);return e.callHooks(b,arguments)?e:c.apply(e,arguments)}}(j));for(var k in a.plugins)e.plugin(k,a.plugins[k]());return"function"==typeof b&&b(e),e}};a.api.add=function(a){var b=function(b,c,d,f){var g=a.getPlugins()[c];if("undefined"!=typeof g){var h=g(a,d);return h&&e(b,h,f),!0}return!1},c=function(b){var c=a.getPlugins();for(var d in b)"undefined"!=typeof c[d]&&(b[d]=!1);for(var d in b)":"===d.charAt(0)&&(b[d]=!1)},d=function(a,c,f){for(var g in c)"object"==typeof c[g]?(":"===g.charAt(0)?e(a+g,c[g],f):"&"===g.charAt(0)?e(a+g.substr(1,g.length-1),c[g],f):0===g.indexOf("@media")||0===g.indexOf("@supports")?e(a,c[g],g):b(a,g,c[g],f)===!1&&e(a+" "+g,c[g],f),c[g]=!1):"function"==typeof c[g]?(c[g]=c[g](),d(a,c,f)):b(a,g,c[g],f)&&(c[g]=!1)},e=function(f,g,h){if("undefined"==typeof g.length||"object"!=typeof g){if(!b(null,f,g,h)){if("object"==typeof a.getRules(h||"mainstream")[f]){var i=a.getRules(h||"mainstream")[f];for(var j in g)i[j]=g[j]}else a.getRules(h||"mainstream")[f]=g;d(f,g,h||"mainstream"),c(g)}}else for(var k=0;prop=g[k];k++)e(f,prop,h)},f=function(b,c){a.numOfAddedRules+=1;for(var d in b)if("undefined"!=typeof b[d].length&&"object"==typeof b[d])for(var f=0;r=b[d][f];f++)e(d,r,c||"mainstream");else e(d,b[d],c||"mainstream");return a};return f};var f=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a};a.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var g={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor};d=f(g,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{fs.writeFile(b,e,function(a){c(a,e)})}catch(d){c(d)}else c(d,e);a.flush()},d)}},a.api.compileFile=function(a){return a.compile};var g=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.darken=function(){return function(a,b){return g(a,-(b/100))}},a.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var g=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.lighten=function(){return function(a,b){return g(a,b/100)}};var h={html:function(a){a.defaultProcessor=b(d+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})}};a.api.morph=function(a){return function(b){return h[b]&&(a.flush(),h[b](a)),a}},a.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},a.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}},a.api.register=function(a){return function(b,c){return a[b]=c,a}},a.api.storage=function(a){var b=a.getStorage(),c=function(c,d){if("undefined"==typeof d){if(b[c])return b[c];throw new Error("There is no data in the storage associated with '"+c+"'")}return b[c]=d,a};return c},a.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},a.helpers.RequireUncached=function(a){return delete b.cache[b.resolve(a)],b(a)};var i=b("clean-css"),j="\n",k={combineSelectors:!0,minify:!1,keepCamelCase:!1},l=function(a,b){var c="";for(var d in a)if(0===d.indexOf("____raw"))c+=a[d][d]+j;else{var e=d+" {"+j;for(var f in a[d]){var g=a[d][f];""===g&&(g='""'),e+=" "+(0==b.keepCamelCase?o(f):f)+": "+g+";"+j}e+="}"+j,c+=e}return c},m=function(a){var b={};for(var c in a){var d=!1,e={};for(var f in a[c]){var g=a[c][f];g!==!1&&(d=!0,e[f]=g)}d&&(b[c]=e)}return b},n=function(a){var b={},c={};for(var d in a){var e=a[d];for(var f in e){var g=e[f];b[f]||(b[f]={}),b[f][g]||(b[f][g]=[]),b[f][g].push(d)}}for(var f in b){var h=b[f];for(var g in h){var i=h[g];c[i.join(", ")]||(c[i.join(", ")]={});var d=c[i.join(", ")];d[f]=g}}return c},o=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};a.processors.css.CSS=function(){return function(a,b,c){c=c||k;var d="";for(var e in a){var f=m(a[e]);f=c.combineSelectors?n(f):f,d+="mainstream"===e?l(f,c):e+" {"+j+l(f,c)+"}"+j}return c.minify?(d=i.process(d),b&&b(null,d)):b&&b(null,d),d}},a.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},a.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},a.processors.css.plugins.keyframes=function(){return function(a,c){var e=b(d+"/../CSS.js")();if("object"==typeof c)if("undefined"!=typeof c.frames){var f="@keyframes "+c.name+" {\n";f+=e({mainstream:c.frames}),f+="}",a.raw(f+"\n"+f.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof c.keyframes){for(var f="@keyframes "+c.name+" {\n",g={},h=0;rule=c.keyframes[h];h++)if("keyframe"===rule.type)for(var i=g[rule.values]={},j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value);f+=e({mainstream:g}),f+="}",a.raw(f+"\n"+f.replace("@keyframes","@-webkit-keyframes"))}}},a.processors.css.plugins.media=function(){return function(a,c){var e=b(d+"/../CSS.js")();if("object"==typeof c){for(var f="@media "+c.media+" {\n",g={},h=0;rule=c.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=e({mainstream:g}),f+="}",a.raw(f)}}},a.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},a.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},a.processors.css.plugins.supports=function(){return function(a,c){var e=b(d+"/../CSS.js")();if("object"==typeof c){for(var f="@supports "+c.supports+" {\n",g={},h=0;rule=c.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=e({mainstream:g}),f+="}",a.raw(f)}}};var p=null,j="\n",k={},o=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b},q=function(a){var b="";for(var c in p)if(c==a)for(var d=p[c].length,e=0;d>e;e++)b+=s("",p[c][e]);return b},s=function(a,b){var c="",d="",e="",f=u(a);if(a=f.tag,""!=f.attrs&&(d+=" "+f.attrs),"string"==typeof b)return t(a,d,b);var g=function(a){""!=e&&(e+=j),e+=a};for(var h in b){var i=b[h];switch(h){case"_attrs":for(var k in i)d+="function"==typeof i[k]?" "+o(k)+'="'+i[k]()+'"':" "+o(k)+'="'+i[k]+'"';b[h]=!1;break;case"_":g(i),b[h]=!1;break;case"_tpl":if("string"==typeof i)g(q(i));else if("object"==typeof i&&i.length&&i.length>0){for(var l="",m=0;tpl=i[m];m++)l+=q(tpl),m<i.length-1&&(l+=j);g(l)}b[h]=!1}}for(var n in b){var i=b[n];if(i!==!1){var p=n;switch(typeof i){case"string":g(s(p,i));break;case"object":if(i.length&&i.length>0){for(var l="",m=0;v=i[m];m++)l+=s("","function"==typeof v?v():v),m<i.length-1&&(l+=j);g(s(p,l))}else g(s(p,i));break;case"function":g(s(p,i()))}}}return c+=""!=a?t(a,d,e):e},t=function(a,b,c){var d="";return d+=""!==c?"<"+o(a)+b+">"+j+c+j+"</"+o(a)+">":"<"+o(a)+b+"/>"},u=function(a){for(var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1,k=0;c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b};return a.processors.html.HTML=function(){return function(a,b,c){p=a,b=b||function(){},c=c||k;var d=q("mainstream");return b(null,d),d}},e()}(window); | ||
var Absurd=function(){var a={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{}}}},b=function(b){switch(b){case"/../processors/html/HTML.js":return a.processors.html.HTML}return function(){}},d="",e=function(){return function(b){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:a.processors.css.CSS()},f={},g={},h={},i={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return h},e.getStorage=function(){return g},e.flush=function(){f={},g=[]},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){i[a]||(i[a]=[]);for(var d=!1,e=0;c=i[a][e];e++)c===b&&(d=!0);d===!1?i[a].push(b):null},e.callHooks=function(a,b){if(i[a])for(var d=0;c=i[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var j in a.api)"compile"!==j&&(e[j]=a.api[j](e),e[j]=function(b){return function(){var c=a.api[b](e);return e.callHooks(b,arguments)?e:c.apply(e,arguments)}}(j));for(var k in a.plugins)e.plugin(k,a.plugins[k]());return"function"==typeof b&&b(e),e}};a.api.add=function(a){var b=function(b,c,d,f){var g=a.getPlugins()[c];if("undefined"!=typeof g){var h=g(a,d);return h&&e(b,h,f),!0}return!1},c=function(b){var c=a.getPlugins();for(var d in b)"undefined"!=typeof c[d]&&(b[d]=!1);for(var d in b)":"===d.charAt(0)&&(b[d]=!1);for(var d in b)"&"===d.charAt(0)&&(b[d]=!1)},d=function(a,c,f){for(var g in c)"object"==typeof c[g]?(":"===g.charAt(0)?e(a+g,c[g],f):/&/g.test(g)?e(g.replace(/&/g,a),c[g],f):0===g.indexOf("@media")||0===g.indexOf("@supports")?e(a,c[g],g):b(a,g,c[g],f)===!1&&e(a+" "+g,c[g],f),c[g]=!1):"function"==typeof c[g]?(c[g]=c[g](),d(a,c,f)):b(a,g,c[g],f)&&(c[g]=!1)},e=function(f,g,h){if("undefined"==typeof g.length||"object"!=typeof g){if(!b(null,f,g,h)){if("object"==typeof a.getRules(h||"mainstream")[f]){var i=a.getRules(h||"mainstream")[f];for(var j in g)i[j]=g[j]}else a.getRules(h||"mainstream")[f]=g;d(f,g,h||"mainstream"),c(g)}}else for(var k=0;prop=g[k];k++)e(f,prop,h)},f=function(b,c){a.numOfAddedRules+=1;for(var d in b)if("undefined"!=typeof b[d].length&&"object"==typeof b[d])for(var f=0;r=b[d][f];f++)e(d,r,c||"mainstream");else e(d,b[d],c||"mainstream");return a};return f};var f=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a};a.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var g={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor};d=f(g,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{fs.writeFile(b,e,function(a){c(a,e)})}catch(d){c(d)}else c(d,e);a.flush()},d)}},a.api.compileFile=function(a){return a.compile};var g=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.darken=function(){return function(a,b){return g(a,-(b/100))}},a.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var g=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.lighten=function(){return function(a,b){return g(a,b/100)}};var h={html:function(a){a.defaultProcessor=b(d+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})}};a.api.morph=function(a){return function(b){return h[b]&&(a.flush(),h[b](a)),a}},a.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},a.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}},a.api.register=function(a){return function(b,c){return a[b]=c,a}},a.api.storage=function(a){var b=a.getStorage(),c=function(c,d){if("undefined"==typeof d){if(b[c])return b[c];throw new Error("There is no data in the storage associated with '"+c+"'")}return b[c]=d,a};return c},a.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},a.helpers.RequireUncached=function(a){return delete b.cache[b.resolve(a)],b(a)};var i=b("clean-css"),j="\n",k={combineSelectors:!0,minify:!1,keepCamelCase:!1},l=function(a,b){var c="";for(var d in a)if(0===d.indexOf("____raw"))c+=a[d][d]+j;else{var e=d+" {"+j;for(var f in a[d]){var g=a[d][f];""===g&&(g='""'),e+=" "+(0==b.keepCamelCase?o(f):f)+": "+g+";"+j}e+="}"+j,c+=e}return c},m=function(a){var b={};for(var c in a){var d=!1,e={};for(var f in a[c]){var g=a[c][f];g!==!1&&(d=!0,e[f]=g)}d&&(b[c]=e)}return b},n=function(a){var b={},c={};for(var d in a){var e=a[d];for(var f in e){var g=e[f];b[f]||(b[f]={}),b[f][g]||(b[f][g]=[]),b[f][g].push(d)}}for(var f in b){var h=b[f];for(var g in h){var i=h[g];c[i.join(", ")]||(c[i.join(", ")]={});var d=c[i.join(", ")];d[f]=g}}return c},o=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};a.processors.css.CSS=function(){return function(a,b,c){c=c||k;var d="";for(var e in a){var f=m(a[e]);f=c.combineSelectors?n(f):f,d+="mainstream"===e?l(f,c):e+" {"+j+l(f,c)+"}"+j}return c.minify?(d=i.process(d),b&&b(null,d)):b&&b(null,d),d}},a.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},a.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},a.processors.css.plugins.keyframes=function(){return function(a,c){var e=b(d+"/../CSS.js")();if("object"==typeof c)if("undefined"!=typeof c.frames){var f="@keyframes "+c.name+" {\n";f+=e({mainstream:c.frames}),f+="}",a.raw(f+"\n"+f.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof c.keyframes){for(var f="@keyframes "+c.name+" {\n",g={},h=0;rule=c.keyframes[h];h++)if("keyframe"===rule.type)for(var i=g[rule.values]={},j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value);f+=e({mainstream:g}),f+="}",a.raw(f+"\n"+f.replace("@keyframes","@-webkit-keyframes"))}}},a.processors.css.plugins.media=function(){return function(a,c){var e=b(d+"/../CSS.js")();if("object"==typeof c){for(var f="@media "+c.media+" {\n",g={},h=0;rule=c.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=e({mainstream:g}),f+="}",a.raw(f)}}},a.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},a.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},a.processors.css.plugins.supports=function(){return function(a,c){var e=b(d+"/../CSS.js")();if("object"==typeof c){for(var f="@supports "+c.supports+" {\n",g={},h=0;rule=c.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=e({mainstream:g}),f+="}",a.raw(f)}}};var p=null,j="\n",k={},o=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b},q=function(a){var b="";for(var c in p)if(c==a)for(var d=p[c].length,e=0;d>e;e++)b+=s("",p[c][e]);return b},s=function(a,b){var c="",d="",e="",f=u(a);if(a=f.tag,""!=f.attrs&&(d+=" "+f.attrs),"string"==typeof b)return t(a,d,b);var g=function(a){""!=e&&(e+=j),e+=a};for(var h in b){var i=b[h];switch(h){case"_attrs":for(var k in i)d+="function"==typeof i[k]?" "+o(k)+'="'+i[k]()+'"':" "+o(k)+'="'+i[k]+'"';b[h]=!1;break;case"_":g(i),b[h]=!1;break;case"_tpl":if("string"==typeof i)g(q(i));else if("object"==typeof i&&i.length&&i.length>0){for(var l="",m=0;tpl=i[m];m++)l+=q(tpl),m<i.length-1&&(l+=j);g(l)}b[h]=!1}}for(var n in b){var i=b[n];if(i!==!1){var p=n;switch(typeof i){case"string":g(s(p,i));break;case"object":if(i.length&&i.length>0){for(var l="",m=0;v=i[m];m++)l+=s("","function"==typeof v?v():v),m<i.length-1&&(l+=j);g(s(p,l))}else g(s(p,i));break;case"function":g(s(p,i()))}}}return c+=""!=a?t(a,d,e):e},t=function(a,b,c){var d="";return d+=""!==c?"<"+o(a)+b+">"+j+c+j+"</"+o(a)+">":"<"+o(a)+b+"/>"},u=function(a){for(var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1,k=0;c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b};return a.processors.html.HTML=function(){return function(a,b,c){p=a,b=b||function(){},c=c||k;var d=q("mainstream");return b(null,d),d}},e()}(window); |
@@ -555,2 +555,20 @@ describe("Adding raw data", function() { | ||
}); | ||
it("should replace all ampersand with parent selector", function(done) { | ||
api.add({ | ||
a: { | ||
color: 'red', | ||
':hover': { color: 'blue' }, | ||
'&.fancy': { color: 'green' }, | ||
'.ie6 &:hover, .ie7 &:hover': { color: 'orange' }, | ||
'.ie6 &.fancy': { color: 'yellow' }, | ||
'.ie7 &.fancy': { color: 'black' } | ||
} | ||
}).compile(function(err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toBeDefined(); | ||
expect(css).toBe("a {\n color: red;\n}\na:hover {\n color: blue;\n}\na.fancy {\n color: green;\n}\n.ie6 a:hover, .ie7 a:hover {\n color: orange;\n}\n.ie6 a.fancy {\n color: yellow;\n}\n.ie7 a.fancy {\n color: black;\n}\n"); | ||
done(); | ||
}) | ||
}); | ||
@@ -604,2 +622,42 @@ }); | ||
}); | ||
describe("Fixing bug with ampersand inside a plugin", function() { | ||
var api = require('../../index.js')(); | ||
it("should use remove the ampersand prop", function(done) { | ||
api.plugin("hoverEffect", function(api, color) { | ||
return { | ||
"&:hover": { | ||
color: color, | ||
background: api.lighten(color, 60), | ||
".ie8 &": { | ||
color: "blue" | ||
} | ||
} | ||
}; | ||
}); | ||
api.add({ | ||
a: { | ||
color: "#000", | ||
hoverEffect: "#999" | ||
} | ||
}); | ||
api.compile(function(err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toBeDefined(); | ||
expect(css).toBe("a {\n\ | ||
color: #000;\n\ | ||
}\n\ | ||
a:hover {\n\ | ||
color: #999;\n\ | ||
background: #f5f5f5;\n\ | ||
}\n\ | ||
.ie8 a:hover {\n\ | ||
color: blue;\n\ | ||
}\n"); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("Fixing bug in array usage", function() { | ||
@@ -606,0 +664,0 @@ |
@@ -15,3 +15,2 @@ lib.api.add = function(API) { | ||
var clearing = function(props) { | ||
// plugins | ||
@@ -24,3 +23,2 @@ var plugins = API.getPlugins(); | ||
} | ||
// pseudo classes | ||
@@ -32,3 +30,8 @@ for(var prop in props) { | ||
} | ||
// ampersand | ||
for(var prop in props) { | ||
if(prop.charAt(0) === "&") { | ||
props[prop] = false; | ||
} | ||
} | ||
} | ||
@@ -41,5 +44,5 @@ var checkForNesting = function(selector, props, stylesheet) { | ||
addRule(selector + prop, props[prop], stylesheet); | ||
// check for ampersand operator | ||
} else if(prop.charAt(0) === "&") { | ||
addRule(selector + prop.substr(1, prop.length-1), props[prop], stylesheet); | ||
// check for ampersand operator | ||
} else if(/&/g.test(prop)) { | ||
addRule(prop.replace(/&/g, selector), props[prop], stylesheet); | ||
// check for media query | ||
@@ -46,0 +49,0 @@ } else if(prop.indexOf("@media") === 0 || prop.indexOf("@supports") === 0) { |
@@ -40,4 +40,5 @@ var path = require("path"); | ||
'!tests/common/basics-and-compilation.spec.js', | ||
'!tests/common/cli.spec.js', | ||
'!tests/common/variables-and-functions.spec.js', | ||
'!tests/metamorphosis/html/morph.html.import.spec.js', | ||
'!tests/metamorphosis/html/morph.html.import.spec.js' | ||
], | ||
@@ -44,0 +45,0 @@ dest: 'client-side/tests/tests.from.node.js', |
@@ -15,3 +15,2 @@ module.exports = function(API) { | ||
var clearing = function(props) { | ||
// plugins | ||
@@ -24,3 +23,2 @@ var plugins = API.getPlugins(); | ||
} | ||
// pseudo classes | ||
@@ -32,3 +30,8 @@ for(var prop in props) { | ||
} | ||
// ampersand | ||
for(var prop in props) { | ||
if(prop.charAt(0) === "&") { | ||
props[prop] = false; | ||
} | ||
} | ||
} | ||
@@ -35,0 +38,0 @@ var checkForNesting = function(selector, props, stylesheet) { |
{ | ||
"name": "absurd", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"homepage": "http://krasimir.github.io/absurd", | ||
@@ -5,0 +5,0 @@ "description": "CSS preprocessor", |
Sorry, the diff of this file is not supported yet
278255
138
8705