Comparing version 0.0.33 to 0.0.34
@@ -229,2 +229,10 @@ var Absurd = (function(w) { | ||
// if array is passed as props | ||
if(typeof props.length !== 'undefined' && typeof props === "object") { | ||
for(var i=0; prop=props[i]; i++) { | ||
addRule(selector, prop, stylesheet); | ||
} | ||
return; | ||
} | ||
// check for plugin | ||
@@ -231,0 +239,0 @@ if(checkAndExecutePlugin(null, selector, props, stylesheet)) return; |
@@ -1,1 +0,1 @@ | ||
var Absurd=function(){function a(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}var b={api:{},helpers:{},plugins:{}},d=function(){},e=function(){return function(a){var c={},d={},e={},f={};c.getRules=function(a){return"undefined"==typeof a?d:("undefined"==typeof d[a]&&(d[a]=[]),d[a])},c.getPlugins=function(){return f},c.getStorage=function(){return e},c.flush=function(){d={},e=[]},c.numOfAddedRules=0,c.compile=function(a){b.Processor(c.getRules(),a||function(){},{combineSelectors:!0})},c.getPath=function(){return{}};for(var g in b.api)c[g]=b.api[g](c);for(var h in b.plugins)c.plugin(h,b.plugins[h]());return"function"==typeof a&&a(c),c}},f=d("clean-css"),g="\n",h={combineSelectors:!0,minify:!1},i=function(a){var b="";for(var c in a)if(0===c.indexOf("____raw"))b+=a[c].value+g;else{var d=c+" {"+g;for(var e in a[c])a[c][e],d+=" "+l(e)+": "+a[c][e]+";"+g;d+="}"+g,b+=d}return b},j=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},k=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},l=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};return b.Processor=function(a,b,c){c=c||h;var d="";for(var e in a){var l=j(a[e]);l=c.combineSelectors?k(l):l,d+="mainstream"===e?i(l):e+" {"+g+i(l)+"}"+g}return c.minify?(d=f.process(d),b&&b(null,d)):b&&b(null,d),d},b.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)},d=function(a,c,d){for(var f in c)"object"==typeof c[f]?(":"===f.charAt(0)?e(a+f,c[f],d):0===f.indexOf("@media")||0===f.indexOf("@supports")?e(a,c[f],f):b(a,f,c[f],d)===!1&&e(a+" "+f,c[f],d),c[f]=!1):b(a,f,c[f],d)&&(c[f]=!1)},e=function(e,f,g){if(!b(null,e,f,g)){if("object"==typeof a.getRules(g||"mainstream")[e]){var h=a.getRules(g||"mainstream")[e];for(var i in f)h[i]=f[i]}else a.getRules(g||"mainstream")[e]=f;d(e,f,g||"mainstream"),c(f)}},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},b.api.colors=function(b){var c=b.darken=function(b,c){return a(b,-(c/100))},d=b.lighten=function(b,c){return a(b,c/100)};return{darken:c,lighten:d}},b.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},b.api.raw=function(a){return function(b){var c={};return c["____raw_"+a.numOfAddedRules]={value:b},a.add(c),a}},b.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},b.helpers.PathFormatter=function(a){var b={};return a?b="string"==typeof a?{source:a}:a:!1},b.helpers.RequireUncached=function(a){return delete d.cache[d.resolve(a)],d(a)},b.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+'";'))}},b.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)}}},b.plugins.keyframes=function(){return function(a,b){var c=d(__dirname+"/../Processor");if("object"==typeof b)if("undefined"!=typeof b.frames){var e="@keyframes "+b.name+" {\n";e+=c({mainstream:b.frames}),e+="}",a.raw(e+"\n"+e.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof b.keyframes){for(var e="@keyframes "+b.name+" {\n",f={},g=0;rule=b.keyframes[g];g++)if("keyframe"===rule.type)for(var h=f[rule.values]={},i=0;declaration=rule.declarations[i];i++)"declaration"===declaration.type&&(h[declaration.property]=declaration.value);e+=c({mainstream:f}),e+="}",a.raw(e+"\n"+e.replace("@keyframes","@-webkit-keyframes"))}}},b.plugins.media=function(){return function(a,b){var c=d(__dirname+"/../Processor");if("object"==typeof b){for(var e="@media "+b.media+" {\n",f={},g=0;rule=b.rules[g];g++){var h=f[rule.selectors.toString()]={};if("rule"===rule.type)for(var i=0;declaration=rule.declarations[i];i++)"declaration"===declaration.type&&(h[declaration.property]=declaration.value)}e+=c({mainstream:f}),e+="}",a.raw(e)}}},b.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+'";'))}},b.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)}}},b.plugins.supports=function(){return function(a,b){var c=d(__dirname+"/../Processor");if("object"==typeof b){for(var e="@supports "+b.supports+" {\n",f={},g=0;rule=b.rules[g];g++){var h=f[rule.selectors.toString()]={};if("rule"===rule.type)for(var i=0;declaration=rule.declarations[i];i++)"declaration"===declaration.type&&(h[declaration.property]=declaration.value)}e+=c({mainstream:f}),e+="}",a.raw(e)}}},e()}(window); | ||
var Absurd=function(){function a(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}var b={api:{},helpers:{},plugins:{}},d=function(){},e=function(){return function(a){var c={},d={},e={},f={};c.getRules=function(a){return"undefined"==typeof a?d:("undefined"==typeof d[a]&&(d[a]=[]),d[a])},c.getPlugins=function(){return f},c.getStorage=function(){return e},c.flush=function(){d={},e=[]},c.numOfAddedRules=0,c.compile=function(a){b.Processor(c.getRules(),a||function(){},{combineSelectors:!0})},c.getPath=function(){return{}};for(var g in b.api)c[g]=b.api[g](c);for(var h in b.plugins)c.plugin(h,b.plugins[h]());return"function"==typeof a&&a(c),c}},f=d("clean-css"),g="\n",h={combineSelectors:!0,minify:!1},i=function(a){var b="";for(var c in a)if(0===c.indexOf("____raw"))b+=a[c].value+g;else{var d=c+" {"+g;for(var e in a[c])a[c][e],d+=" "+l(e)+": "+a[c][e]+";"+g;d+="}"+g,b+=d}return b},j=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},k=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},l=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};return b.Processor=function(a,b,c){c=c||h;var d="";for(var e in a){var l=j(a[e]);l=c.combineSelectors?k(l):l,d+="mainstream"===e?i(l):e+" {"+g+i(l)+"}"+g}return c.minify?(d=f.process(d),b&&b(null,d)):b&&b(null,d),d},b.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)},d=function(a,c,d){for(var f in c)"object"==typeof c[f]?(":"===f.charAt(0)?e(a+f,c[f],d):0===f.indexOf("@media")||0===f.indexOf("@supports")?e(a,c[f],f):b(a,f,c[f],d)===!1&&e(a+" "+f,c[f],d),c[f]=!1):b(a,f,c[f],d)&&(c[f]=!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},b.api.colors=function(b){var c=b.darken=function(b,c){return a(b,-(c/100))},d=b.lighten=function(b,c){return a(b,c/100)};return{darken:c,lighten:d}},b.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},b.api.raw=function(a){return function(b){var c={};return c["____raw_"+a.numOfAddedRules]={value:b},a.add(c),a}},b.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},b.helpers.PathFormatter=function(a){var b={};return a?b="string"==typeof a?{source:a}:a:!1},b.helpers.RequireUncached=function(a){return delete d.cache[d.resolve(a)],d(a)},b.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+'";'))}},b.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)}}},b.plugins.keyframes=function(){return function(a,b){var c=d(__dirname+"/../Processor");if("object"==typeof b)if("undefined"!=typeof b.frames){var e="@keyframes "+b.name+" {\n";e+=c({mainstream:b.frames}),e+="}",a.raw(e+"\n"+e.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof b.keyframes){for(var e="@keyframes "+b.name+" {\n",f={},g=0;rule=b.keyframes[g];g++)if("keyframe"===rule.type)for(var h=f[rule.values]={},i=0;declaration=rule.declarations[i];i++)"declaration"===declaration.type&&(h[declaration.property]=declaration.value);e+=c({mainstream:f}),e+="}",a.raw(e+"\n"+e.replace("@keyframes","@-webkit-keyframes"))}}},b.plugins.media=function(){return function(a,b){var c=d(__dirname+"/../Processor");if("object"==typeof b){for(var e="@media "+b.media+" {\n",f={},g=0;rule=b.rules[g];g++){var h=f[rule.selectors.toString()]={};if("rule"===rule.type)for(var i=0;declaration=rule.declarations[i];i++)"declaration"===declaration.type&&(h[declaration.property]=declaration.value)}e+=c({mainstream:f}),e+="}",a.raw(e)}}},b.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+'";'))}},b.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)}}},b.plugins.supports=function(){return function(a,b){var c=d(__dirname+"/../Processor");if("object"==typeof b){for(var e="@supports "+b.supports+" {\n",f={},g=0;rule=b.rules[g];g++){var h=f[rule.selectors.toString()]={};if("rule"===rule.type)for(var i=0;declaration=rule.declarations[i];i++)"declaration"===declaration.type&&(h[declaration.property]=declaration.value)}e+=c({mainstream:f}),e+="}",a.raw(e)}}},e()}(window); |
@@ -401,2 +401,37 @@ describe("Adding raw data", function() { | ||
}); | ||
describe("Fixing bug in array usage", function() { | ||
var Absurd = require('../../index.js'); | ||
var themeColor = "#BADA55"; | ||
var textStyles = function(size) { | ||
return { | ||
color: themeColor, | ||
fontSize: size + "px", | ||
lineHeight: size + "px" | ||
} | ||
} | ||
it("should use array", function(done) { | ||
Absurd(function(api) { | ||
api.add({ | ||
body: { | ||
color: themeColor, | ||
p: textStyles(16), | ||
h1: [ | ||
textStyles(50), | ||
{ | ||
lineHeight: "60px" | ||
} | ||
] | ||
} | ||
}); | ||
}).compile(function(err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toBeDefined(); | ||
expect(css).toBe("body, body p, body h1 {\n color: #BADA55;\n}\nbody p {\n font-size: 16px;\n line-height: 16px;\n}\nbody h1 {\n font-size: 50px;\n line-height: 60px;\n}\n"); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -153,2 +153,10 @@ var cleanCSS = require('clean-css'), | ||
// if array is passed as props | ||
if(typeof props.length !== 'undefined' && typeof props === "object") { | ||
for(var i=0; prop=props[i]; i++) { | ||
addRule(selector, prop, stylesheet); | ||
} | ||
return; | ||
} | ||
// check for plugin | ||
@@ -155,0 +163,0 @@ if(checkAndExecutePlugin(null, selector, props, stylesheet)) return; |
@@ -31,2 +31,3 @@ var path = require("path"); | ||
'tests/common/*.js', | ||
'tests/bugs/*.js', | ||
'!tests/common/api.import.spec.js', | ||
@@ -38,3 +39,3 @@ '!tests/common/compile-and-save.spec.js', | ||
'!tests/common/basics-and-compilation.spec.js', | ||
'!tests/common/variables-and-functions.spec.js' | ||
'!tests/common/variables-and-functions.spec.js', | ||
], | ||
@@ -41,0 +42,0 @@ dest: 'client-side/tests/tests.from.node.js', |
@@ -45,2 +45,10 @@ module.exports = function(API) { | ||
// if array is passed as props | ||
if(typeof props.length !== 'undefined' && typeof props === "object") { | ||
for(var i=0; prop=props[i]; i++) { | ||
addRule(selector, prop, stylesheet); | ||
} | ||
return; | ||
} | ||
// check for plugin | ||
@@ -47,0 +55,0 @@ if(checkAndExecutePlugin(null, selector, props, stylesheet)) return; |
{ | ||
"name": "absurd", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"homepage": "https://github.com/krasimir/absurd", | ||
@@ -5,0 +5,0 @@ "description": "CSS preprocessor", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
215486
109
6094
0