Comparing version 0.1.1 to 0.2.0
@@ -6,17 +6,17 @@ define('j2c', function(){return (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,11 +49,10 @@ } | ||
var m = { // module | ||
/*/-inline-/*/ | ||
return { | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
} | ||
/*/-inline-/*/ | ||
return m; | ||
})() | ||
@@ -64,0 +59,0 @@ |
@@ -1,1 +0,1 @@ | ||
define("j2c",function(){return function(){function n(n,r,e,t){e.forEach(function(e){r.push(t+"-"+e+"-"+n)}),r.push(t+n)}function r(n,r,e){return e={},e[n]=r,e}function e(n){var r=[];return t(n,r,"",u.vendors,""),r.join("\n")}function t(e,u,a,f,s,b,d,h){for(b in e)switch(h=e[b],d=i(h)){case o:h.forEach(function(n){t(r(b,n),u,a,f,s)});break;case c:t(h,u,a+b+"-",f,s);break;default:n((a+b).replace(/_/g,"-")+":"+h+";",u,f,s)}}var c="[object Object]",o="[object Array]",i=e.call.bind({}.toString),u=(".j2c_"+(1e9*Math.random()|0)+"_",{inline:e,vendors:["o","ms","moz","webkit"]});return u}()}); | ||
define("j2c",function(){return function(){function n(n,r,c){c.forEach(function(c){r.push("-"+c+"-"+n)}),r.push(n)}function r(n,r,c){return c={},c[n]=r,c}function c(n){var r=[];return e(n,r,"",j2c.vendors,""),r.join("")}function e(c,u,a,f,s,j){for(s in c)switch(j=c[s],i.call(j)){case o:j.forEach(function(n){e(r(s,n),u,a,f)});break;case t:e(j,u,a+s+"-",f);break;default:n((a+s).replace(/_/g,"-")+":"+j+";",u,f)}}{var t="[object Object]",o="[object Array]",i={}.toString;".j2c_"+(1e9*Math.random()|0)+"_"}return{inline:c,vendors:["o","ms","moz","webkit"]}}()}); |
@@ -6,17 +6,17 @@ module.exports = (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,11 +49,10 @@ } | ||
var m = { // module | ||
/*/-inline-/*/ | ||
return { | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
} | ||
/*/-inline-/*/ | ||
return m; | ||
})() | ||
@@ -64,0 +59,0 @@ |
@@ -6,17 +6,17 @@ export default (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,11 +49,10 @@ } | ||
var m = { // module | ||
/*/-inline-/*/ | ||
return { | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
} | ||
/*/-inline-/*/ | ||
return m; | ||
})() | ||
@@ -64,0 +59,0 @@ |
@@ -6,17 +6,17 @@ ;var j2c = (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,11 +49,10 @@ } | ||
var m = { // module | ||
/*/-inline-/*/ | ||
return { | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
} | ||
/*/-inline-/*/ | ||
return m; | ||
})() | ||
@@ -64,0 +59,0 @@ |
@@ -1,1 +0,1 @@ | ||
var j2c=function(){function n(n,r,c,o){c.forEach(function(c){r.push(o+"-"+c+"-"+n)}),r.push(o+n)}function r(n,r,c){return c={},c[n]=r,c}function c(n){var r=[];return o(n,r,"",i.vendors,""),r.join("\n")}function o(c,i,u,f,s,b,h,j){for(b in c)switch(j=c[b],h=a(j)){case e:j.forEach(function(n){o(r(b,n),i,u,f,s)});break;case t:o(j,i,u+b+"-",f,s);break;default:n((u+b).replace(/_/g,"-")+":"+j+";",i,f,s)}}var t="[object Object]",e="[object Array]",a=c.call.bind({}.toString),i=(".j2c_"+(1e9*Math.random()|0)+"_",{inline:c,vendors:["o","ms","moz","webkit"]});return i}(); | ||
var j2c=function(){function n(n,r,c){c.forEach(function(c){r.push("-"+c+"-"+n)}),r.push(n)}function r(n,r,c){return c={},c[n]=r,c}function c(n){var r=[];return o(n,r,"",j2c.vendors,""),r.join("")}function o(c,i,u,f,s,j){for(s in c)switch(j=c[s],a.call(j)){case e:j.forEach(function(n){o(r(s,n),i,u,f)});break;case t:o(j,i,u+s+"-",f);break;default:n((u+s).replace(/_/g,"-")+":"+j+";",i,f)}}{var t="[object Object]",e="[object Array]",a={}.toString;".j2c_"+(1e9*Math.random()|0)+"_"}return{inline:c,vendors:["o","ms","moz","webkit"]}}(); |
@@ -6,17 +6,17 @@ define('j2c', function(){return (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,4 +49,6 @@ } | ||
/*/-statements-/*/ | ||
function sheet(root) {return new Sheet(root);} | ||
function j2c(root) {return new Sheet(root);} | ||
function Sheet(root) { | ||
@@ -61,6 +59,6 @@ this.root = (root != null ? root : default_root + (counter++)); | ||
var Sp = Sheet.prototype; | ||
Sheet.prototype = Sheet; | ||
Sp.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), m.vendors, ""); | ||
Sheet.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), j2c.vendors); | ||
return this | ||
@@ -77,4 +75,4 @@ }; | ||
function _add(statements, buf, pfx, vendors, indent /*var*/, k, v, t, props) { | ||
switch (type(statements)) { | ||
function _add(statements, buf, pfx, vendors/*var*/, k, v, props) { | ||
switch (type.call(statements)) { | ||
case OBJECT: | ||
@@ -84,8 +82,7 @@ props = {}; | ||
v = statements[k]; | ||
t = type(v); | ||
if (k[0] == "@"){ | ||
if (t == OBJECT) { | ||
buf.push(indent + k + "{"); | ||
_add(v, buf, pfx, vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
if (type.call(v) == OBJECT) { | ||
buf.push(k + "{"); | ||
_add(v, buf, pfx, vendors); | ||
buf.push("}"); | ||
} else { | ||
@@ -97,3 +94,3 @@ buf.push(k + " " + v + ";"); | ||
} else { | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors, indent); | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors); | ||
} | ||
@@ -103,5 +100,5 @@ } | ||
for (k in props){ | ||
buf.push(indent + pfx + "{"); | ||
_declarations(props, buf, "", vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
buf.push(pfx + "{"); | ||
_declarations(props, buf, "", vendors); | ||
buf.push("}"); | ||
break; | ||
@@ -112,41 +109,33 @@ } | ||
statements.forEach(function (statement) { | ||
_add(statement, buf, pfx, vendors, indent); | ||
_add(statement, buf, pfx, vendors); | ||
}) | ||
break; | ||
case STRING: | ||
buf.push(indent + pfx.join(",") + "{\n" + statements + "\n" + indent + "}"); | ||
buf.push(pfx.join(",") + "{" + statements + "}"); | ||
} | ||
} | ||
Sp.keyframes = function(name, frames) { | ||
m.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor], ""); | ||
Sheet.keyframes = function(name, frames) { | ||
j2c.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor]); | ||
}, this) | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], m.vendors, ""); | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], j2c.vendors); | ||
return this; | ||
} | ||
Sp.font = function(o, buf) { | ||
buf = this.buf | ||
buf.push("@font-face{"); | ||
_declarations(o, buf, "", [], m.indent); | ||
buf.push("}"); | ||
Sheet.font = function(o) { | ||
this.buf.push("@font-face{"); | ||
_declarations(o, this.buf, "", []); | ||
this.buf.push("}"); | ||
return this | ||
} | ||
Sp.toString = function () { | ||
return this.buf.join("\n"); | ||
Sheet.toString = function () { | ||
return this.buf.join(""); | ||
}; | ||
j2c.inline = inline; | ||
j2c.vendors = ["o", "ms", "moz", "webkit"]; | ||
return j2c; | ||
/*/-statements-/*/ | ||
var m = { // module | ||
/*/-statements-/*/ | ||
indent: " ", | ||
sheet:sheet, | ||
/*/-statements-/*/ | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
return m; | ||
})() | ||
@@ -153,0 +142,0 @@ |
@@ -1,1 +0,1 @@ | ||
define("j2c",function(){return function(){function n(n,t,r,e){r.forEach(function(r){t.push(e+"-"+r+"-"+n)}),t.push(e+n)}function t(n,t,r){return r={},r[n]=t,r}function r(n){var t=[];return e(n,t,"",l.vendors,""),t.join("\n")}function e(r,i,o,u,s,c,b,p){for(c in r)switch(p=r[c],b=a(p)){case h:p.forEach(function(n){e(t(c,n),i,o,u,s)});break;case f:e(p,i,o+c+"-",u,s);break;default:n((o+c).replace(/_/g,"-")+":"+p+";",i,u,s)}}function i(n){return new o(n)}function o(n){this.root=null!=n?n:b+p++,this.buf=[]}function u(n,t){for(var r,e=[],i=0;i<t.length;i++)for(r=0;r<n.length;r++)e.push(n[r]+t[i]);return e}function s(n,t,r,i,o,b,p,d,j){switch(a(n)){case f:j={};for(b in n)p=n[b],d=a(p),"@"==b[0]?d==f?(t.push(o+b+"{"),s(p,t,r,i,o+l.indent),t.push(o+"}")):t.push(b+" "+p+";"):b.match(/^[-\w]+$/)?j[b]=p:s(p,t,u(r,b.split(",")),i,o);for(b in j){t.push(o+r+"{"),e(j,t,"",i,o+l.indent),t.push(o+"}");break}break;case h:n.forEach(function(n){s(n,t,r,i,o)});break;case c:t.push(o+r.join(",")+"{\n"+n+"\n"+o+"}")}}var f="[object Object]",c="[object String]",h="[object Array]",a=r.call.bind({}.toString),b=".j2c_"+(1e9*Math.random()|0)+"_",p=0,d=o.prototype;d.add=function(n){return s(n,this.buf,this.root.split(","),l.vendors,""),this},d.keyframes=function(n,r){return l.vendors.forEach(function(e){s(t("@-"+e+"-keyframes "+n,r),this.buf,[""],[e],"")},this),s(t("@keyframes "+n,r),this.buf,[""],l.vendors,""),this},d.font=function(n,t){return t=this.buf,t.push("@font-face{"),e(n,t,"",[],l.indent),t.push("}"),this},d.toString=function(){return this.buf.join("\n")};var l={indent:" ",sheet:i,inline:r,vendors:["o","ms","moz","webkit"]};return l}()}); | ||
define("j2c",function(){return function(){function n(n,t,r){r.forEach(function(r){t.push("-"+r+"-"+n)}),t.push(n)}function t(n,t,r){return r={},r[n]=t,r}function r(n){var t=[];return o(n,t,"",i.vendors,""),t.join("")}function o(r,i,u,e,f,c){for(f in r)switch(c=r[f],a.call(c)){case h:c.forEach(function(n){o(t(f,n),i,u,e)});break;case s:o(c,i,u+f+"-",e);break;default:n((u+f).replace(/_/g,"-")+":"+c+";",i,e)}}function i(n){return new u(n)}function u(n){this.root=null!=n?n:b+p++,this.buf=[]}function e(n,t){for(var r,o=[],i=0;i<t.length;i++)for(r=0;r<n.length;r++)o.push(n[r]+t[i]);return o}function f(n,t,r,i,u,b,p){switch(a.call(n)){case s:p={};for(u in n)b=n[u],"@"==u[0]?a.call(b)==s?(t.push(u+"{"),f(b,t,r,i),t.push("}")):t.push(u+" "+b+";"):u.match(/^[-\w]+$/)?p[u]=b:f(b,t,e(r,u.split(",")),i);for(u in p){t.push(r+"{"),o(p,t,"",i),t.push("}");break}break;case h:n.forEach(function(n){f(n,t,r,i)});break;case c:t.push(r.join(",")+"{"+n+"}")}}var s="[object Object]",c="[object String]",h="[object Array]",a={}.toString,b=".j2c_"+(1e9*Math.random()|0)+"_",p=0;return u.prototype=u,u.add=function(n){return f(n,this.buf,this.root.split(","),i.vendors),this},u.keyframes=function(n,r){return i.vendors.forEach(function(o){f(t("@-"+o+"-keyframes "+n,r),this.buf,[""],[o])},this),f(t("@keyframes "+n,r),this.buf,[""],i.vendors),this},u.font=function(n){return this.buf.push("@font-face{"),o(n,this.buf,"",[]),this.buf.push("}"),this},u.toString=function(){return this.buf.join("")},i.inline=r,i.vendors=["o","ms","moz","webkit"],i}()}); |
@@ -6,17 +6,17 @@ module.exports = (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,4 +49,6 @@ } | ||
/*/-statements-/*/ | ||
function sheet(root) {return new Sheet(root);} | ||
function j2c(root) {return new Sheet(root);} | ||
function Sheet(root) { | ||
@@ -61,6 +59,6 @@ this.root = (root != null ? root : default_root + (counter++)); | ||
var Sp = Sheet.prototype; | ||
Sheet.prototype = Sheet; | ||
Sp.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), m.vendors, ""); | ||
Sheet.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), j2c.vendors); | ||
return this | ||
@@ -77,4 +75,4 @@ }; | ||
function _add(statements, buf, pfx, vendors, indent /*var*/, k, v, t, props) { | ||
switch (type(statements)) { | ||
function _add(statements, buf, pfx, vendors/*var*/, k, v, props) { | ||
switch (type.call(statements)) { | ||
case OBJECT: | ||
@@ -84,8 +82,7 @@ props = {}; | ||
v = statements[k]; | ||
t = type(v); | ||
if (k[0] == "@"){ | ||
if (t == OBJECT) { | ||
buf.push(indent + k + "{"); | ||
_add(v, buf, pfx, vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
if (type.call(v) == OBJECT) { | ||
buf.push(k + "{"); | ||
_add(v, buf, pfx, vendors); | ||
buf.push("}"); | ||
} else { | ||
@@ -97,3 +94,3 @@ buf.push(k + " " + v + ";"); | ||
} else { | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors, indent); | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors); | ||
} | ||
@@ -103,5 +100,5 @@ } | ||
for (k in props){ | ||
buf.push(indent + pfx + "{"); | ||
_declarations(props, buf, "", vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
buf.push(pfx + "{"); | ||
_declarations(props, buf, "", vendors); | ||
buf.push("}"); | ||
break; | ||
@@ -112,41 +109,33 @@ } | ||
statements.forEach(function (statement) { | ||
_add(statement, buf, pfx, vendors, indent); | ||
_add(statement, buf, pfx, vendors); | ||
}) | ||
break; | ||
case STRING: | ||
buf.push(indent + pfx.join(",") + "{\n" + statements + "\n" + indent + "}"); | ||
buf.push(pfx.join(",") + "{" + statements + "}"); | ||
} | ||
} | ||
Sp.keyframes = function(name, frames) { | ||
m.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor], ""); | ||
Sheet.keyframes = function(name, frames) { | ||
j2c.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor]); | ||
}, this) | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], m.vendors, ""); | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], j2c.vendors); | ||
return this; | ||
} | ||
Sp.font = function(o, buf) { | ||
buf = this.buf | ||
buf.push("@font-face{"); | ||
_declarations(o, buf, "", [], m.indent); | ||
buf.push("}"); | ||
Sheet.font = function(o) { | ||
this.buf.push("@font-face{"); | ||
_declarations(o, this.buf, "", []); | ||
this.buf.push("}"); | ||
return this | ||
} | ||
Sp.toString = function () { | ||
return this.buf.join("\n"); | ||
Sheet.toString = function () { | ||
return this.buf.join(""); | ||
}; | ||
j2c.inline = inline; | ||
j2c.vendors = ["o", "ms", "moz", "webkit"]; | ||
return j2c; | ||
/*/-statements-/*/ | ||
var m = { // module | ||
/*/-statements-/*/ | ||
indent: " ", | ||
sheet:sheet, | ||
/*/-statements-/*/ | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
return m; | ||
})() | ||
@@ -153,0 +142,0 @@ |
@@ -6,17 +6,17 @@ export default (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,4 +49,6 @@ } | ||
/*/-statements-/*/ | ||
function sheet(root) {return new Sheet(root);} | ||
function j2c(root) {return new Sheet(root);} | ||
function Sheet(root) { | ||
@@ -61,6 +59,6 @@ this.root = (root != null ? root : default_root + (counter++)); | ||
var Sp = Sheet.prototype; | ||
Sheet.prototype = Sheet; | ||
Sp.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), m.vendors, ""); | ||
Sheet.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), j2c.vendors); | ||
return this | ||
@@ -77,4 +75,4 @@ }; | ||
function _add(statements, buf, pfx, vendors, indent /*var*/, k, v, t, props) { | ||
switch (type(statements)) { | ||
function _add(statements, buf, pfx, vendors/*var*/, k, v, props) { | ||
switch (type.call(statements)) { | ||
case OBJECT: | ||
@@ -84,8 +82,7 @@ props = {}; | ||
v = statements[k]; | ||
t = type(v); | ||
if (k[0] == "@"){ | ||
if (t == OBJECT) { | ||
buf.push(indent + k + "{"); | ||
_add(v, buf, pfx, vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
if (type.call(v) == OBJECT) { | ||
buf.push(k + "{"); | ||
_add(v, buf, pfx, vendors); | ||
buf.push("}"); | ||
} else { | ||
@@ -97,3 +94,3 @@ buf.push(k + " " + v + ";"); | ||
} else { | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors, indent); | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors); | ||
} | ||
@@ -103,5 +100,5 @@ } | ||
for (k in props){ | ||
buf.push(indent + pfx + "{"); | ||
_declarations(props, buf, "", vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
buf.push(pfx + "{"); | ||
_declarations(props, buf, "", vendors); | ||
buf.push("}"); | ||
break; | ||
@@ -112,41 +109,33 @@ } | ||
statements.forEach(function (statement) { | ||
_add(statement, buf, pfx, vendors, indent); | ||
_add(statement, buf, pfx, vendors); | ||
}) | ||
break; | ||
case STRING: | ||
buf.push(indent + pfx.join(",") + "{\n" + statements + "\n" + indent + "}"); | ||
buf.push(pfx.join(",") + "{" + statements + "}"); | ||
} | ||
} | ||
Sp.keyframes = function(name, frames) { | ||
m.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor], ""); | ||
Sheet.keyframes = function(name, frames) { | ||
j2c.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor]); | ||
}, this) | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], m.vendors, ""); | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], j2c.vendors); | ||
return this; | ||
} | ||
Sp.font = function(o, buf) { | ||
buf = this.buf | ||
buf.push("@font-face{"); | ||
_declarations(o, buf, "", [], m.indent); | ||
buf.push("}"); | ||
Sheet.font = function(o) { | ||
this.buf.push("@font-face{"); | ||
_declarations(o, this.buf, "", []); | ||
this.buf.push("}"); | ||
return this | ||
} | ||
Sp.toString = function () { | ||
return this.buf.join("\n"); | ||
Sheet.toString = function () { | ||
return this.buf.join(""); | ||
}; | ||
j2c.inline = inline; | ||
j2c.vendors = ["o", "ms", "moz", "webkit"]; | ||
return j2c; | ||
/*/-statements-/*/ | ||
var m = { // module | ||
/*/-statements-/*/ | ||
indent: " ", | ||
sheet:sheet, | ||
/*/-statements-/*/ | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
return m; | ||
})() | ||
@@ -153,0 +142,0 @@ |
@@ -6,17 +6,17 @@ ;var j2c = (function () { | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -26,24 +26,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -53,4 +49,6 @@ } | ||
/*/-statements-/*/ | ||
function sheet(root) {return new Sheet(root);} | ||
function j2c(root) {return new Sheet(root);} | ||
function Sheet(root) { | ||
@@ -61,6 +59,6 @@ this.root = (root != null ? root : default_root + (counter++)); | ||
var Sp = Sheet.prototype; | ||
Sheet.prototype = Sheet; | ||
Sp.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), m.vendors, ""); | ||
Sheet.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), j2c.vendors); | ||
return this | ||
@@ -77,4 +75,4 @@ }; | ||
function _add(statements, buf, pfx, vendors, indent /*var*/, k, v, t, props) { | ||
switch (type(statements)) { | ||
function _add(statements, buf, pfx, vendors/*var*/, k, v, props) { | ||
switch (type.call(statements)) { | ||
case OBJECT: | ||
@@ -84,8 +82,7 @@ props = {}; | ||
v = statements[k]; | ||
t = type(v); | ||
if (k[0] == "@"){ | ||
if (t == OBJECT) { | ||
buf.push(indent + k + "{"); | ||
_add(v, buf, pfx, vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
if (type.call(v) == OBJECT) { | ||
buf.push(k + "{"); | ||
_add(v, buf, pfx, vendors); | ||
buf.push("}"); | ||
} else { | ||
@@ -97,3 +94,3 @@ buf.push(k + " " + v + ";"); | ||
} else { | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors, indent); | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors); | ||
} | ||
@@ -103,5 +100,5 @@ } | ||
for (k in props){ | ||
buf.push(indent + pfx + "{"); | ||
_declarations(props, buf, "", vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
buf.push(pfx + "{"); | ||
_declarations(props, buf, "", vendors); | ||
buf.push("}"); | ||
break; | ||
@@ -112,41 +109,33 @@ } | ||
statements.forEach(function (statement) { | ||
_add(statement, buf, pfx, vendors, indent); | ||
_add(statement, buf, pfx, vendors); | ||
}) | ||
break; | ||
case STRING: | ||
buf.push(indent + pfx.join(",") + "{\n" + statements + "\n" + indent + "}"); | ||
buf.push(pfx.join(",") + "{" + statements + "}"); | ||
} | ||
} | ||
Sp.keyframes = function(name, frames) { | ||
m.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor], ""); | ||
Sheet.keyframes = function(name, frames) { | ||
j2c.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor]); | ||
}, this) | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], m.vendors, ""); | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], j2c.vendors); | ||
return this; | ||
} | ||
Sp.font = function(o, buf) { | ||
buf = this.buf | ||
buf.push("@font-face{"); | ||
_declarations(o, buf, "", [], m.indent); | ||
buf.push("}"); | ||
Sheet.font = function(o) { | ||
this.buf.push("@font-face{"); | ||
_declarations(o, this.buf, "", []); | ||
this.buf.push("}"); | ||
return this | ||
} | ||
Sp.toString = function () { | ||
return this.buf.join("\n"); | ||
Sheet.toString = function () { | ||
return this.buf.join(""); | ||
}; | ||
j2c.inline = inline; | ||
j2c.vendors = ["o", "ms", "moz", "webkit"]; | ||
return j2c; | ||
/*/-statements-/*/ | ||
var m = { // module | ||
/*/-statements-/*/ | ||
indent: " ", | ||
sheet:sheet, | ||
/*/-statements-/*/ | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
return m; | ||
})() | ||
@@ -153,0 +142,0 @@ |
@@ -1,1 +0,1 @@ | ||
var j2c=function(){function n(n,t,r,e){r.forEach(function(r){t.push(e+"-"+r+"-"+n)}),t.push(e+n)}function t(n,t,r){return r={},r[n]=t,r}function r(n){var t=[];return e(n,t,"",l.vendors,""),t.join("\n")}function e(r,i,o,u,s,c,b,p){for(c in r)switch(p=r[c],b=a(p)){case h:p.forEach(function(n){e(t(c,n),i,o,u,s)});break;case f:e(p,i,o+c+"-",u,s);break;default:n((o+c).replace(/_/g,"-")+":"+p+";",i,u,s)}}function i(n){return new o(n)}function o(n){this.root=null!=n?n:b+p++,this.buf=[]}function u(n,t){for(var r,e=[],i=0;i<t.length;i++)for(r=0;r<n.length;r++)e.push(n[r]+t[i]);return e}function s(n,t,r,i,o,b,p,d,v){switch(a(n)){case f:v={};for(b in n)p=n[b],d=a(p),"@"==b[0]?d==f?(t.push(o+b+"{"),s(p,t,r,i,o+l.indent),t.push(o+"}")):t.push(b+" "+p+";"):b.match(/^[-\w]+$/)?v[b]=p:s(p,t,u(r,b.split(",")),i,o);for(b in v){t.push(o+r+"{"),e(v,t,"",i,o+l.indent),t.push(o+"}");break}break;case h:n.forEach(function(n){s(n,t,r,i,o)});break;case c:t.push(o+r.join(",")+"{\n"+n+"\n"+o+"}")}}var f="[object Object]",c="[object String]",h="[object Array]",a=r.call.bind({}.toString),b=".j2c_"+(1e9*Math.random()|0)+"_",p=0,d=o.prototype;d.add=function(n){return s(n,this.buf,this.root.split(","),l.vendors,""),this},d.keyframes=function(n,r){return l.vendors.forEach(function(e){s(t("@-"+e+"-keyframes "+n,r),this.buf,[""],[e],"")},this),s(t("@keyframes "+n,r),this.buf,[""],l.vendors,""),this},d.font=function(n,t){return t=this.buf,t.push("@font-face{"),e(n,t,"",[],l.indent),t.push("}"),this},d.toString=function(){return this.buf.join("\n")};var l={indent:" ",sheet:i,inline:r,vendors:["o","ms","moz","webkit"]};return l}(); | ||
var j2c=function(){function n(n,t,r){r.forEach(function(r){t.push("-"+r+"-"+n)}),t.push(n)}function t(n,t,r){return r={},r[n]=t,r}function r(n){var t=[];return o(n,t,"",i.vendors,""),t.join("")}function o(r,i,u,e,s,c){for(s in r)switch(c=r[s],a.call(c)){case h:c.forEach(function(n){o(t(s,n),i,u,e)});break;case f:o(c,i,u+s+"-",e);break;default:n((u+s).replace(/_/g,"-")+":"+c+";",i,e)}}function i(n){return new u(n)}function u(n){this.root=null!=n?n:b+p++,this.buf=[]}function e(n,t){for(var r,o=[],i=0;i<t.length;i++)for(r=0;r<n.length;r++)o.push(n[r]+t[i]);return o}function s(n,t,r,i,u,b,p){switch(a.call(n)){case f:p={};for(u in n)b=n[u],"@"==u[0]?a.call(b)==f?(t.push(u+"{"),s(b,t,r,i),t.push("}")):t.push(u+" "+b+";"):u.match(/^[-\w]+$/)?p[u]=b:s(b,t,e(r,u.split(",")),i);for(u in p){t.push(r+"{"),o(p,t,"",i),t.push("}");break}break;case h:n.forEach(function(n){s(n,t,r,i)});break;case c:t.push(r.join(",")+"{"+n+"}")}}var f="[object Object]",c="[object String]",h="[object Array]",a={}.toString,b=".j2c_"+(1e9*Math.random()|0)+"_",p=0;return u.prototype=u,u.add=function(n){return s(n,this.buf,this.root.split(","),i.vendors),this},u.keyframes=function(n,r){return i.vendors.forEach(function(o){s(t("@-"+o+"-keyframes "+n,r),this.buf,[""],[o])},this),s(t("@keyframes "+n,r),this.buf,[""],i.vendors),this},u.font=function(n){return this.buf.push("@font-face{"),o(n,this.buf,"",[]),this.buf.push("}"),this},u.toString=function(){return this.buf.join("")},i.inline=r,i.vendors=["o","ms","moz","webkit"],i}(); |
108
j2c.js
@@ -9,17 +9,17 @@ /*/-notice-/*//* | ||
ARRAY = "[object Array]", | ||
type = inline.call.bind(({}).toString), | ||
type = ({}).toString, | ||
default_root = ".j2c_" + (Math.random() * 1e9 | 0) + "_", | ||
counter = 0; | ||
function _vendorify(prop, buf, vendors, indent) { | ||
function _vendorify(prop, buf, vendors) { | ||
vendors.forEach(function (v) { | ||
buf.push(indent + "-" + v + "-" + prop); | ||
buf.push("-" + v + "-" + prop); | ||
}) | ||
buf.push(indent + prop) | ||
buf.push(prop) | ||
} | ||
function _O(k, v, o) { | ||
o = {} | ||
o[k] = v | ||
return o | ||
o = {}; | ||
o[k] = v; | ||
return o; | ||
} | ||
@@ -29,24 +29,20 @@ | ||
var buf = []; | ||
_declarations(o, buf, "", m.vendors, ""); | ||
return buf.join("\n"); | ||
_declarations(o, buf, "", j2c.vendors, ""); | ||
return buf.join(""); | ||
} | ||
function _declarations(o, buf, pfx, vendors, indent /*var*/, k, t, v) { | ||
function _declarations(o, buf, pfx, vendors/*var*/, k, v) { | ||
for (k in o) { | ||
v = o[k]; | ||
t = type(v); | ||
switch (t) { | ||
switch (type.call(v)) { | ||
case ARRAY: | ||
v.forEach(function (vv) { | ||
_declarations(_O(k,vv), buf, pfx, vendors, indent); | ||
_declarations(_O(k, vv), buf, pfx, vendors); | ||
}); | ||
break; | ||
case OBJECT: | ||
_declarations(v, buf, pfx + k + "-", vendors, indent); | ||
_declarations(v, buf, pfx + k + "-", vendors); | ||
break; | ||
default: | ||
_vendorify( | ||
(pfx + k).replace(/_/g, "-") + ":" + v + ";", | ||
buf, vendors, indent | ||
); | ||
_vendorify((pfx + k).replace(/_/g, "-") + ":" + v + ";", buf, vendors); | ||
} | ||
@@ -56,4 +52,11 @@ } | ||
/*/-inline-/*/ | ||
return { | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
} | ||
/*/-inline-/*/ | ||
/*/-statements-/*/ | ||
function sheet(root) {return new Sheet(root);} | ||
function j2c(root) {return new Sheet(root);} | ||
function Sheet(root) { | ||
@@ -64,6 +67,6 @@ this.root = (root != null ? root : default_root + (counter++)); | ||
var Sp = Sheet.prototype; | ||
Sheet.prototype = Sheet; | ||
Sp.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), m.vendors, ""); | ||
Sheet.add = function (statements) { | ||
_add(statements, this.buf, this.root.split(","), j2c.vendors); | ||
return this | ||
@@ -80,4 +83,4 @@ }; | ||
function _add(statements, buf, pfx, vendors, indent /*var*/, k, v, t, props) { | ||
switch (type(statements)) { | ||
function _add(statements, buf, pfx, vendors/*var*/, k, v, props) { | ||
switch (type.call(statements)) { | ||
case OBJECT: | ||
@@ -87,8 +90,7 @@ props = {}; | ||
v = statements[k]; | ||
t = type(v); | ||
if (k[0] == "@"){ | ||
if (t == OBJECT) { | ||
buf.push(indent + k + "{"); | ||
_add(v, buf, pfx, vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
if (type.call(v) == OBJECT) { | ||
buf.push(k + "{"); | ||
_add(v, buf, pfx, vendors); | ||
buf.push("}"); | ||
} else { | ||
@@ -100,3 +102,3 @@ buf.push(k + " " + v + ";"); | ||
} else { | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors, indent); | ||
_add(v, buf, cartesian(pfx, k.split(",")), vendors); | ||
} | ||
@@ -106,5 +108,5 @@ } | ||
for (k in props){ | ||
buf.push(indent + pfx + "{"); | ||
_declarations(props, buf, "", vendors, indent + m.indent); | ||
buf.push(indent + "}"); | ||
buf.push(pfx + "{"); | ||
_declarations(props, buf, "", vendors); | ||
buf.push("}"); | ||
break; | ||
@@ -115,41 +117,33 @@ } | ||
statements.forEach(function (statement) { | ||
_add(statement, buf, pfx, vendors, indent); | ||
_add(statement, buf, pfx, vendors); | ||
}) | ||
break; | ||
case STRING: | ||
buf.push(indent + pfx.join(",") + "{\n" + statements + "\n" + indent + "}"); | ||
buf.push(pfx.join(",") + "{" + statements + "}"); | ||
} | ||
} | ||
Sp.keyframes = function(name, frames) { | ||
m.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor], ""); | ||
Sheet.keyframes = function(name, frames) { | ||
j2c.vendors.forEach(function(vendor) { | ||
_add(_O("@-" + vendor + "-keyframes " + name, frames), this.buf, [""], [vendor]); | ||
}, this) | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], m.vendors, ""); | ||
_add(_O("@keyframes " + name, frames), this.buf, [""], j2c.vendors); | ||
return this; | ||
} | ||
Sp.font = function(o, buf) { | ||
buf = this.buf | ||
buf.push("@font-face{"); | ||
_declarations(o, buf, "", [], m.indent); | ||
buf.push("}"); | ||
Sheet.font = function(o) { | ||
this.buf.push("@font-face{"); | ||
_declarations(o, this.buf, "", []); | ||
this.buf.push("}"); | ||
return this | ||
} | ||
Sp.toString = function () { | ||
return this.buf.join("\n"); | ||
Sheet.toString = function () { | ||
return this.buf.join(""); | ||
}; | ||
j2c.inline = inline; | ||
j2c.vendors = ["o", "ms", "moz", "webkit"]; | ||
return j2c; | ||
/*/-statements-/*/ | ||
var m = { // module | ||
/*/-statements-/*/ | ||
indent: " ", | ||
sheet:sheet, | ||
/*/-statements-/*/ | ||
inline: inline, | ||
vendors:["o", "ms", "moz", "webkit"] | ||
}; | ||
return m; | ||
})() | ||
@@ -156,0 +150,0 @@ |
{ | ||
"name": "j2c", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A JavaScript object to CSS compiler.", | ||
@@ -5,0 +5,0 @@ "main": "dist/j2c.commonjs.js", |
# j2c | ||
A small JavaScript object to CSS compiler. ~820 bytes mingzipped. | ||
A small JavaScript object to CSS compiler. ~730 bytes mingzipped. | ||
@@ -55,3 +55,3 @@ Think SASS, but in JSONish syntax. | ||
r = j2c.sheet("ul.my_root_class") | ||
r = j2c("ul.my_root_class") | ||
@@ -113,3 +113,3 @@ r.add({ | ||
```JavaScript | ||
r = j2c.sheet() | ||
r = j2c() | ||
r.prefix // --> ".j2c_$token_$counter" where `$token` is unique per | ||
@@ -129,3 +129,3 @@ // j2c instance, and `$counter` is incremented to | ||
```JavaScript | ||
r = j2c.sheet("ul.my_root_class") | ||
r = j2c("ul.my_root_class") | ||
@@ -149,3 +149,3 @@ r.add({ | ||
```JavaScript | ||
r = j2c.sheet("ul.my_root_class") | ||
r = j2c("ul.my_root_class") | ||
@@ -182,3 +182,3 @@ r.add([ | ||
```JavaScript | ||
j2c.sheet("").add({ | ||
j2c("").add({ | ||
".block,.blockgroup":{ | ||
@@ -209,3 +209,3 @@ ",:before,:after":{ // Notice the initial coma. | ||
```JavaScript | ||
j2c.sheet("").add({ | ||
j2c("").add({ | ||
".blockgroup": [ | ||
@@ -255,6 +255,6 @@ "*zoom: 1; /* hack */", | ||
### `j2c` object | ||
### `j2c` and static fields | ||
* `j2c([root:String]) : Sheet`: Creates a Sheet object. | ||
* `j2c.inline(props:(Object|Array|String)) : String`: returns a declaration list suitable for inline styles | ||
* `j2c.sheet([root:String]) : Sheet`: Creates a Sheet object. | ||
* `j2c.vendors = ["o", "ms", "moz", "webkit"]` (r/w): list of vendor prefixes. | ||
@@ -261,0 +261,0 @@ |
@@ -9,3 +9,3 @@ #! /usr/bin/env node | ||
versions = { | ||
"j2c": source, | ||
"j2c": surgicate({source:source}).excise("inline"), | ||
"inline/j2c": surgicate({source:source}).excise("statements") + "" | ||
@@ -20,3 +20,3 @@ }, | ||
source: "module.exports = %;", | ||
minify: false // No need to minify before browserification. | ||
minify: true // No need to minify before browserification. | ||
}, | ||
@@ -41,3 +41,4 @@ es6: { | ||
(function(){ | ||
var minified = uglify.minify(wrapped, {fromString: true}).code, | ||
var minified = uglify.minify( | ||
wrapped, {fromString: true}).code, | ||
_name = name, | ||
@@ -44,0 +45,0 @@ _wrp = wrp |
624
test/test.js
@@ -1,379 +0,411 @@ | ||
var j2c = require("../dist/j2c.commonjs"), | ||
var j2c, | ||
crass = require("crass"), | ||
expect = require("expect.js"); | ||
["../dist/j2c.commonjs", "../dist/j2c.commonjs.min", "../dist/inline/j2c.commonjs", "../dist/inline/j2c.commonjs.min"].forEach(function(lib){ | ||
j2c = require(lib) | ||
function check(result, expected){ | ||
result = crass.parse(result).optimize().toString(); | ||
expected = (expected instanceof Array ? expected : [expected]).map(function(s){ | ||
return crass.parse(s).optimize().toString(); | ||
}); | ||
expect(expected).to.contain(result); | ||
} | ||
function check(result, expected){ | ||
result = crass.parse(result).optimize().toString(); | ||
expected = (expected instanceof Array ? expected : [expected]).map(function(s){ | ||
return crass.parse(s).optimize().toString(); | ||
function checkinline(result, expected){ | ||
result = "p{" + j2c.inline(result) + "}" | ||
expected = (expected instanceof Array ? expected : [expected]).map(function(s){ | ||
return "p{" + s + "}" | ||
}); | ||
check(result, expected) | ||
} | ||
var vendors = j2c.vendors; | ||
j2c.vendors = []; | ||
///////////////////////////// | ||
/**/ suite("Inline, ") /**/ | ||
///////////////////////////// | ||
test("a single property", function() { | ||
checkinline( | ||
{foo:"bar"}, | ||
"foo:bar;" | ||
) | ||
}); | ||
expect(expected).to.contain(result); | ||
} | ||
function checkinline(result, expected){ | ||
result = "p{" + j2c.inline(result) + "}" | ||
expected = (expected instanceof Array ? expected : [expected]).map(function(s){ | ||
return "p{" + s + "}" | ||
test("array of values", function() { | ||
checkinline( | ||
{foo:["bar", "baz"]}, | ||
"foo:bar;foo:baz;" | ||
) | ||
}); | ||
check(result, expected) | ||
} | ||
function add(klass, o){ | ||
return j2c.sheet(klass).add(o).toString() | ||
} | ||
test("sub-properties", function(){ | ||
checkinline( | ||
{foo:{bar:"baz"}}, | ||
"foo-bar:baz;" | ||
) | ||
}) | ||
var vendors = j2c.vendors; | ||
j2c.vendors = []; | ||
test("convert underscores", function() { | ||
checkinline( | ||
{"f_o_o":"bar"}, | ||
"f-o-o:bar;" | ||
) | ||
}); | ||
test("CSS Hack", function() { | ||
checkinline( | ||
{"*foo":"bar"}, | ||
"*foo:bar;" | ||
) | ||
}); | ||
/////////////////////////////// | ||
/**/ suite("Root class") /**/ | ||
/////////////////////////////// | ||
}); | ||
test("custom root class", function(){ | ||
var sheet = j2c.sheet("foo") | ||
expect(sheet.root).to.be("foo") | ||
check( | ||
sheet.add({foo:"bar"}).toString(), | ||
sheet.root + "{foo:bar}" | ||
) | ||
}); | ||
test("default root class", function(){ | ||
var sheet = j2c.sheet() | ||
expect(sheet.root[0]).to.be(".") | ||
check( | ||
sheet.add({foo:"bar"}).toString(), | ||
sheet.root + "{foo:bar}" | ||
) | ||
}); | ||
test("default root class must be unique", function(){ | ||
var sheet = j2c.sheet() | ||
expect(j2c.sheet().root).not.to.be(j2c.sheet().root) | ||
}); | ||
["../dist/j2c.commonjs", "../dist/j2c.commonjs.min"].forEach(function(lib){ | ||
j2c = require(lib) | ||
function check(result, expected){ | ||
result = crass.parse(result).optimize().toString(); | ||
expected = (expected instanceof Array ? expected : [expected]).map(function(s){ | ||
return crass.parse(s).optimize().toString(); | ||
}); | ||
expect(expected).to.contain(result); | ||
} | ||
function checkinline(result, expected){ | ||
result = "p{" + j2c.inline(result) + "}" | ||
expected = (expected instanceof Array ? expected : [expected]).map(function(s){ | ||
return "p{" + s + "}" | ||
}); | ||
check(result, expected) | ||
} | ||
///////////////////////////// | ||
/**/ suite("Inline, ") /**/ | ||
///////////////////////////// | ||
function add(klass, o){ | ||
return j2c(klass).add(o).toString() | ||
} | ||
var vendors = j2c.vendors; | ||
j2c.vendors = []; | ||
test("a single property", function() { | ||
checkinline( | ||
{foo:"bar"}, | ||
"foo:bar;" | ||
) | ||
}); | ||
test("array of values", function() { | ||
checkinline( | ||
{foo:["bar", "baz"]}, | ||
"foo:bar;foo:baz;" | ||
) | ||
}); | ||
test("sub-properties", function(){ | ||
checkinline( | ||
{foo:{bar:"baz"}}, | ||
"foo-bar:baz;" | ||
) | ||
}) | ||
/////////////////////////////// | ||
/**/ suite("Root class") /**/ | ||
/////////////////////////////// | ||
test("convert underscores", function() { | ||
checkinline( | ||
{"f_o_o":"bar"}, | ||
"f-o-o:bar;" | ||
) | ||
}); | ||
test("CSS Hack", function() { | ||
checkinline( | ||
{"*foo":"bar"}, | ||
"*foo:bar;" | ||
) | ||
}); | ||
test("custom root class", function(){ | ||
var sheet = j2c("foo") | ||
expect(sheet.root).to.be("foo") | ||
check( | ||
sheet.add({foo:"bar"}).toString(), | ||
sheet.root + "{foo:bar}" | ||
) | ||
}); | ||
test("default root class", function(){ | ||
var sheet = j2c() | ||
expect(sheet.root[0]).to.be(".") | ||
check( | ||
sheet.add({foo:"bar"}).toString(), | ||
sheet.root + "{foo:bar}" | ||
) | ||
}); | ||
////////////////////////////////// | ||
/**/ suite("Definitions, ") /**/ | ||
////////////////////////////////// | ||
test("default root class must be unique", function(){ | ||
var sheet = j2c() | ||
expect(j2c().root).not.to.be(j2c().root) | ||
}); | ||
test("basic", function() { | ||
check( | ||
add("p", { | ||
foo:"bar" | ||
}), | ||
"p{foo:bar}" | ||
) | ||
}); | ||
////////////////////////////////// | ||
/**/ suite("Definitions, ") /**/ | ||
////////////////////////////////// | ||
test("convert underscores", function() { | ||
check( | ||
add("p", { | ||
foo_foo:"bar" | ||
}), | ||
"p{foo-foo:bar}" | ||
) | ||
}); | ||
test("number values", function() { | ||
check( | ||
add("p", { | ||
foo:5 | ||
}), | ||
"p{foo:5}" | ||
) | ||
}); | ||
test("basic", function() { | ||
check( | ||
add("p", { | ||
foo:"bar" | ||
}), | ||
"p{foo:bar}" | ||
) | ||
}); | ||
test("composed property name", function() { | ||
check( | ||
add("p", { | ||
foo:{bar:"baz"} | ||
}), | ||
test("convert underscores", function() { | ||
check( | ||
add("p", { | ||
foo_foo:"bar" | ||
}), | ||
"p{foo-foo:bar}" | ||
) | ||
}); | ||
"p{foo-bar:baz}" | ||
) | ||
}); | ||
test("number values", function() { | ||
check( | ||
add("p", { | ||
foo:5 | ||
}), | ||
"p{foo:5}" | ||
) | ||
}); | ||
test("composed selector : child with a given class", function() { | ||
check( | ||
add("p", { | ||
" .foo":{bar:"baz"} | ||
}), | ||
test("composed property name", function() { | ||
check( | ||
add("p", { | ||
foo:{bar:"baz"} | ||
}), | ||
"p .foo{bar:baz}" | ||
) | ||
}); | ||
"p{foo-bar:baz}" | ||
) | ||
}); | ||
test("composed selector: add a class to the root", function() { | ||
check( | ||
add("p", { | ||
".foo":{bar:"baz"} | ||
}), | ||
test("composed selector : child with a given class", function() { | ||
check( | ||
add("p", { | ||
" .foo":{bar:"baz"} | ||
}), | ||
"p.foo{bar:baz}" | ||
) | ||
}); | ||
"p .foo{bar:baz}" | ||
) | ||
}); | ||
test("mixing definitions and sub-selectors", function() { | ||
check( | ||
add("p", { | ||
foo:"bar", | ||
" .foo":{bar:"baz"} | ||
}), | ||
test("composed selector: add a class to the root", function() { | ||
check( | ||
add("p", { | ||
".foo":{bar:"baz"} | ||
}), | ||
"p .foo{bar:baz} p {foo:bar}" | ||
) | ||
}); | ||
"p.foo{bar:baz}" | ||
) | ||
}); | ||
test("mixing definitions and sub-selectors", function() { | ||
check( | ||
add("p", { | ||
foo:"bar", | ||
" .foo":{bar:"baz"} | ||
}), | ||
"p .foo{bar:baz} p {foo:bar}" | ||
) | ||
}); | ||
/////////////////////////////////////////////// | ||
/**/ suite("Selector Cartesian product, ") /**/ | ||
/////////////////////////////////////////////// | ||
test("1 x 2", function() { | ||
check( | ||
add("p", { | ||
" .foo":{ | ||
":before,:after":{ | ||
foo:"bar" | ||
/////////////////////////////////////////////// | ||
/**/ suite("Selector Cartesian product, ") /**/ | ||
/////////////////////////////////////////////// | ||
test("1 x 2", function() { | ||
check( | ||
add("p", { | ||
" .foo":{ | ||
":before,:after":{ | ||
foo:"bar" | ||
} | ||
} | ||
} | ||
}), | ||
}), | ||
"p .foo:before, p .foo:after {foo:bar}" | ||
) | ||
}); | ||
"p .foo:before, p .foo:after {foo:bar}" | ||
) | ||
}); | ||
test("2 x 1", function() { | ||
check( | ||
add("p", { | ||
" .foo, .bar":{ | ||
":before":{ | ||
foo:"bar" | ||
test("2 x 1", function() { | ||
check( | ||
add("p", { | ||
" .foo, .bar":{ | ||
":before":{ | ||
foo:"bar" | ||
} | ||
} | ||
} | ||
}), | ||
}), | ||
"p .foo:before, p .bar:before {foo:bar}" | ||
) | ||
}); | ||
"p .foo:before, p .bar:before {foo:bar}" | ||
) | ||
}); | ||
test("2 x 2", function() { | ||
check( | ||
add("p", { | ||
" .foo, .bar":{ | ||
":before,:after":{ | ||
foo:"bar" | ||
test("2 x 2", function() { | ||
check( | ||
add("p", { | ||
" .foo, .bar":{ | ||
":before,:after":{ | ||
foo:"bar" | ||
} | ||
} | ||
} | ||
}), | ||
}), | ||
"p .foo:before, p .bar:before, p .foo:after, p .bar:after {foo:bar}" | ||
) | ||
}); | ||
"p .foo:before, p .bar:before, p .foo:after, p .bar:after {foo:bar}" | ||
) | ||
}); | ||
test("2 x 3 one of which is empty", function() { | ||
check( | ||
add("p", { | ||
" .foo, .bar":{ | ||
",:before,:after":{ | ||
foo:"bar" | ||
test("2 x 3 one of which is empty", function() { | ||
check( | ||
add("p", { | ||
" .foo, .bar":{ | ||
",:before,:after":{ | ||
foo:"bar" | ||
} | ||
} | ||
} | ||
}), | ||
}), | ||
"p .foo, p .bar, p .foo:before, p .bar:before, p .foo:after, p .bar:after {foo:bar}" | ||
) | ||
}); | ||
"p .foo, p .bar, p .foo:before, p .bar:before, p .foo:after, p .bar:after {foo:bar}" | ||
) | ||
}); | ||
/////////////////////////////////////// | ||
/**/ suite("Strings and Arrays, ") /**/ | ||
/////////////////////////////////////// | ||
/////////////////////////////////////// | ||
/**/ suite("Strings and Arrays, ") /**/ | ||
/////////////////////////////////////// | ||
test("String literal", function() { | ||
check( | ||
add("p", "foo:bar"), | ||
"p{foo:bar}" | ||
) | ||
}); | ||
test("String literal", function() { | ||
check( | ||
add("p", "foo:bar"), | ||
"p{foo:bar}" | ||
) | ||
}); | ||
test("Array of String literals", function() { | ||
check( | ||
add("p", ["foo:bar", "foo:baz"]), | ||
"p{foo:bar;foo:baz}" | ||
) | ||
}); | ||
test("Array of String literals", function() { | ||
check( | ||
add("p", ["foo:bar", "foo:baz"]), | ||
"p{foo:bar;foo:baz}" | ||
) | ||
}); | ||
test("overloaded properties", function() { | ||
check( | ||
add("p", { | ||
foo:["bar","baz"] | ||
}), | ||
"p{foo:bar;foo:baz}" | ||
) | ||
}); | ||
test("overloaded properties", function() { | ||
check( | ||
add("p", { | ||
foo:["bar","baz"] | ||
}), | ||
"p{foo:bar;foo:baz}" | ||
) | ||
}); | ||
test("overloaded sub-properties", function() { | ||
check( | ||
add("p", { | ||
foo:[{bar:"baz"},{bar:"qux"}] | ||
}), | ||
"p{foo-bar:baz;foo-bar:qux}" | ||
) | ||
}); | ||
test("overloaded sub-properties", function() { | ||
check( | ||
add("p", { | ||
foo:[{bar:"baz"},{bar:"qux"}] | ||
}), | ||
"p{foo-bar:baz;foo-bar:qux}" | ||
) | ||
}); | ||
test("nested Arrays", function(){ | ||
check( | ||
add("p", [ | ||
[ | ||
{bar:"baz"}, | ||
{bar:"qux"} | ||
], | ||
"bar:quux;" | ||
]), | ||
"p {bar:baz;bar:qux;bar:quux}" | ||
) | ||
}) | ||
test("nested Arrays", function(){ | ||
check( | ||
add("p", [ | ||
[ | ||
{bar:"baz"}, | ||
{bar:"qux"} | ||
], | ||
"bar:quux;" | ||
]), | ||
"p {bar:baz;bar:qux;bar:quux}" | ||
) | ||
}) | ||
/////////////////////////////// | ||
/**/ suite("At rules, ") /**/ | ||
/////////////////////////////// | ||
/////////////////////////////// | ||
/**/ suite("At rules, ") /**/ | ||
/////////////////////////////// | ||
before(function(){ | ||
// restore a few vendors to ensure that | ||
// they are not prepended where they shold not. | ||
j2c.vendors = ["o", "p"]; | ||
}); | ||
before(function(){ | ||
// restore a few vendors to ensure that | ||
// they are not prepended where they shold not. | ||
j2c.vendors = ["o", "p"]; | ||
}); | ||
after(function(){ | ||
j2c.vendors = []; | ||
}); | ||
after(function(){ | ||
j2c.vendors = []; | ||
}); | ||
test("standard At rule with text value", function() { | ||
check( | ||
add("p", { | ||
"@import":"'bar'" | ||
}), | ||
test("standard At rule with text value", function() { | ||
check( | ||
add("p", { | ||
"@import":"'bar'" | ||
}), | ||
"@import 'bar';" | ||
) | ||
}); | ||
"@import 'bar';" | ||
) | ||
}); | ||
test("standard At rule with object value", function() { | ||
check( | ||
add("p", { | ||
"@media foo":{bar:"baz"} | ||
}), | ||
test("standard At rule with object value", function() { | ||
check( | ||
add("p", { | ||
"@media foo":{bar:"baz"} | ||
}), | ||
"@media foo {p{-o-bar:baz;-p-bar:baz;bar:baz}}" | ||
) | ||
}); | ||
"@media foo {p{-o-bar:baz;-p-bar:baz;bar:baz}}" | ||
) | ||
}); | ||
test("several At rules with object value", function() { | ||
check( | ||
add("p", { | ||
"@media foo":{bar:"baz"}, | ||
"@media foo2":{bar2:"baz2"} | ||
}), | ||
[ | ||
"@media foo {p{-o-bar:baz;-p-bar:baz;bar:baz}} @media foo2 {p{-o-bar2:baz2;-p-bar2:baz2;bar2:baz2}}", | ||
"@media foo2 {p{-o-bar2:baz2;-p-bar2:baz2;bar2:baz2}} @media foo {p{-o-bar:baz;-p-bar:baz;bar:baz}}" | ||
] | ||
) | ||
}); | ||
test("several At rules with object value", function() { | ||
check( | ||
add("p", { | ||
"@media foo":{bar:"baz"}, | ||
"@media foo2":{bar2:"baz2"} | ||
}), | ||
[ | ||
"@media foo {p{-o-bar:baz;-p-bar:baz;bar:baz}} @media foo2 {p{-o-bar2:baz2;-p-bar2:baz2;bar2:baz2}}", | ||
"@media foo2 {p{-o-bar2:baz2;-p-bar2:baz2;bar2:baz2}} @media foo {p{-o-bar:baz;-p-bar:baz;bar:baz}}" | ||
] | ||
) | ||
}); | ||
test("Array of At rules with text values", function() { | ||
check( | ||
add("p", [ | ||
{"@import":"'bar'"}, | ||
{"@import":"'baz'"} | ||
]), | ||
"@import 'bar'; @import 'baz';" | ||
) | ||
}); | ||
test("Array of At rules with text values", function() { | ||
check( | ||
add("p", [ | ||
{"@import":"'bar'"}, | ||
{"@import":"'baz'"} | ||
]), | ||
"@import 'bar'; @import 'baz';" | ||
) | ||
}); | ||
test("@font-face", function(){ | ||
var sheet = j2c.sheet("p") | ||
check( | ||
sheet.font({foo:"bar"}).toString(), | ||
"@font-face{foo:bar}" | ||
) | ||
}); | ||
test("@font-face", function(){ | ||
var sheet = j2c("p") | ||
check( | ||
sheet.font({foo:"bar"}).toString(), | ||
"@font-face{foo:bar}" | ||
) | ||
}); | ||
test("@keyframes", function(){ | ||
var sheet = j2c.sheet("p") | ||
check( | ||
sheet.keyframes("qux", { | ||
" from":{foo:"bar"}, | ||
" to":{foo:"baz"} | ||
}).toString(), | ||
[ | ||
"@-o-keyframes qux{from{-o-foo:bar;foo:bar}to{-o-foo:baz;foo:baz}}" + | ||
"@-p-keyframes qux{from{-p-foo:bar;foo:bar}to{-p-foo:baz;foo:baz}}" + | ||
"@keyframes qux{from{-o-foo:bar;-p-foo:bar;foo:bar}to{-o-foo:baz;-p-foo:baz;foo:baz}}", | ||
test("@keyframes", function(){ | ||
var sheet = j2c("p") | ||
check( | ||
sheet.keyframes("qux", { | ||
" from":{foo:"bar"}, | ||
" to":{foo:"baz"} | ||
}).toString(), | ||
[ | ||
"@-o-keyframes qux{from{-o-foo:bar;foo:bar}to{-o-foo:baz;foo:baz}}" + | ||
"@-p-keyframes qux{from{-p-foo:bar;foo:bar}to{-p-foo:baz;foo:baz}}" + | ||
"@keyframes qux{from{-o-foo:bar;-p-foo:bar;foo:bar}to{-o-foo:baz;-p-foo:baz;foo:baz}}", | ||
"@-o-keyframes qux{to{-o-foo:baz;foo:baz}from{-o-foo:bar;foo:bar}}" + | ||
"@-p-keyframes qux{to{-p-foo:baz;foo:baz}from{-p-foo:bar;foo:bar}}" + | ||
"@keyframes qux{to{-o-foo:baz;-p-foo:baz;foo:baz}from{-o-foo:bar;-p-foo:bar;foo:bar}}", | ||
] | ||
) | ||
}); | ||
"@-o-keyframes qux{to{-o-foo:baz;foo:baz}from{-o-foo:bar;foo:bar}}" + | ||
"@-p-keyframes qux{to{-p-foo:baz;foo:baz}from{-p-foo:bar;foo:bar}}" + | ||
"@keyframes qux{to{-o-foo:baz;-p-foo:baz;foo:baz}from{-o-foo:bar;-p-foo:bar;foo:bar}}", | ||
] | ||
) | ||
}); | ||
}) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25
67796
1389
3