Comparing version 3.0.0-rc.2 to 3.0.0-rc.3
@@ -16,3 +16,3 @@ var el = typeof document !== 'undefined' && document.createElement('div'); // eslint-disable-line | ||
function px(x) { | ||
if (x in cache) | ||
if ((x[0] === '-' && x[1] === '-') || x in cache) | ||
{ return cache[x] } | ||
@@ -358,3 +358,3 @@ | ||
propParse( | ||
s.slice(x.prop, i + 1).match(/\s*([a-z-]+)[\s:]*([^;]+)/).slice(1) | ||
s.slice(x.prop, i + 1).match(/\s*([a-z-]+)[\s:]*([^;]+)/i).slice(1) | ||
) | ||
@@ -361,0 +361,0 @@ ); |
@@ -22,3 +22,3 @@ (function (global, factory) { | ||
function px(x) { | ||
if (x in cache) | ||
if ((x[0] === '-' && x[1] === '-') || x in cache) | ||
{ return cache[x] } | ||
@@ -364,3 +364,3 @@ | ||
propParse( | ||
s.slice(x.prop, i + 1).match(/\s*([a-z-]+)[\s:]*([^;]+)/).slice(1) | ||
s.slice(x.prop, i + 1).match(/\s*([a-z-]+)[\s:]*([^;]+)/i).slice(1) | ||
) | ||
@@ -367,0 +367,0 @@ ); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).b=t()}(this,(function(){"use strict";var e="undefined"!=typeof document&&document.createElement("div"),t={flex:0,border:1,transform:1,"line-height":0,"box-shadow":1,"border-top":1,"border-left":1,"border-right":1,"border-bottom":1};function n(n){if(n in t)return t[n];try{return e.style[n]="1px",e.style.setProperty(n,"1px"),t[n]="1px"===e.style[n].slice(-3)}catch(e){return t[n]=!1}}var r=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,o=function(e){return e.replace(/(\B[A-Z])/g,"-$1").toLowerCase()},i=function(e){return e?e.hasOwnProperty("width")?e:i(Object.getPrototypeOf(e)):{}},u=["float"].concat(Object.keys("undefined"==typeof document?{}:i(document.documentElement.style))).filter((function(e,t,n){return-1===e.indexOf("-")&&"length"!==e&&n.indexOf(e)===t})).map((function(e){return e.match(r)?"-"+o(e):o(e)})).sort(),l=function(e,t){var n;return Object.assign(e,((n={})[t.split("-").map((function(e){return e[0]})).join("")]=t,n))},a=Object.assign(u.reduce(l,{}),["align-items","bottom","background-color","border-radius","box-shadow","background-image","color","display","float","flex-direction","font-family","font-size","height","justify-content","left","line-height","letter-spacing","margin","margin-bottom","margin-left","margin-right","margin-top","opacity","padding","padding-bottom","padding-left","padding-right","padding-top","right","top","text-align","text-decoration","text-transform","width"].reduce(l,{}));function c(e){return a[e]||e}var s="undefined"!==document&&window.document,f=function(e,t){return t?function(t){return e.indexOf(t.toLowerCase())>-1}:function(t){return e.indexOf(t)>-1}},p=f("abcdefghijklmnopqrstuvwxyz-"),d=f("abcdefghijklmnopqrstuvwxyz0123456789-_",!0),g=f("'\""),m=f(" :"),h=f(" ,)"),v=function(e){return"number"==typeof e},x=Object.create(null,{}),b=Object.create(null,{}),y=function(){return"bss"+("000000"+(Math.random()*Math.pow(36,6)|0).toString(36)).slice(-6)};function O(e){void 0===e&&(e={});var t=e.style;void 0===t&&(t=s&&s.querySelector&&s.querySelector(".bss_style")||s.createElement("style"));var r=e.prefix;void 0===r&&(r=t&&t.getAttribute("id")||y());var o=e.append;void 0===o&&(o=!0);var i={},l=[],a=[],f=O();return f.count=0,f.rules=t&&t.textContent&&t.textContent.split(f.prefix+"{}")||[],f.debug=!1,f.dev=!1,f.prefix=r,f.properties=u,f.at=function(e){return a.unshift("function"==typeof e?e:function(t){return e[t.slice(1)]||t})},f.prop=function(e){return l.unshift(e)},f.create=O,f.ssr=function(){return'<style class="bss_style" id="'+f.prefix+'">'+f.rules.join(f.prefix+"{}")+"</style>"},f.global=function(){$(j(f.apply(f,arguments).content).trim(),"__raw").forEach((function(e){return w(e.replace(/.__raw/g,"").trim())}))},f.prop((function(e){if(-1===u.indexOf(e)){if(x[e])return f.debug&&console.log(e,"prefixed to",x[e]),x[e];f.debug&&console.log(e,"not found")}return e})),f.prop(c),t&&(t.id=f.prefix),f;function b(){return this.className?this.className:(this.className=f.prefix+ ++f.count,$(j(this.content).trim(),this.className).forEach(w),this.className)}function O(e){return function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];for(var o=(e||"")+t[0],u=1;u<t.length;u++){var l=n[u-1];o+=(l&&l.toString===b?l.content:Array.isArray(l)?l.map((function(e){return e.content||e})).join("\n"):l)+t[u]}if(o in i)return i[o];var a=O("\n"+o+"\n");return a.toString=a.valueOf=b,a.content=o,i[o]=a,a}}function j(e){return e.replace(/\/\/.*?(\n|$)/g,"\n").replace(/\/\*[\s\S]*?\*\//g,"")}function w(e){o&&(t&&s.head&&s.head.appendChild(t),o=!1);var n=0===e.indexOf("@import")?0:f.rules.length;if(0===n?f.rules.unshift(e):f.rules.push(e),f.dev&&t)t.textContent=f.rules.map(k).join("\n");else if(t&&t.sheet)try{t.sheet.insertRule(e,n)}catch(e){f.debug&&console.log("Ignored error:",e)}}function k(e){return e.replace(/{/g," {\n").replace(/([;{])\n*/g,"$1\n ").replace(/(.*):(.*);/g,"$1: $2;").replace(/[\s]*}/g,"\n}\n").replace(/,\s*/g,", ").replace(/@.*{[\s\S]*?}[\s]*}/g,(function(e){return e.split("\n").reduce((function(e,t,n,r){return e+(n<r.length-1?"\n":"")+(n>1&&n<r.length-2?" ":"")+t}),"")})).trim().replace("}\n\n}","}\n}")}function $(e,t){for(var n=[],r={prop:null,value:null,out:[],lean:!0,comma:0,end:0,quote:!1},o=[],i=!1,u=!1,l=!1,c=!1,s=0;s<e.length;s++)if(s>0&&c&&!d(e[s])&&(t=e.slice(1,s)+"-"+t,c=!1),c||0===s&&"."===e[s])c=!0;else if(z(e,s,e[s],r),"}"===e[s]||s===e.length-1)q(i||u||l||n,s,t,r,o),i&&!o.length&&((u||l||n).push(i.selector+"{"+i.join("")+"}"),i=!1),u&&!o.length&&((l||n).push(u.selector+"{"+u.join("")+"}"),u=!1),l&&!o.length&&(n.push(l.selector+"{"+l.join("")+"}"),l=!1),o.pop();else if("{"===e[s]){var f=e.slice(r.end,s).trim().replace(/,[\s]*/,",& ");0===f.indexOf("animation")&&r.out.push(["animation",f.slice(10)+" "+t]),q(i||u||l||n,s,t,r,o),r.prop=r.value=null,0===f.indexOf("@supports")?l=Object.assign([],{selector:f}):"@"===f[0]?u=Object.assign([],{selector:a.reduce((function(e,t){return t(e)}),f.trim())}):0===f.indexOf("animation")?i=Object.assign([],{selector:"@keyframes "+t}):o.push(f)}return n}function q(e,t,n,r,o){var i=r.out.length&&r.out.map((function(e){return e.join(":")})).join(";"),u=o.length&&":"!==o[0][0];i&&e.push((o.length&&"&"===o[0][0]||0===(!e.selector||e.selector.indexOf("@keyframes "))?"":(u?"":"."+n)+"."+n+(u?" ":""))+o.join(" ").replace(/&/g,"."+n).replace(/ :/g,":")+"{"+i+";}"),r.end=t+1,r.out=[]}function z(e,t,r,o){!o.value&&null!==o.prop&&o.lean&&":"===r&&(o.lean=!1),!o.value&&null!==o.prop&&o.out.length&&","===r?(o.value=o.comma,o.prop=o.out[o.out.length-1][0]):!o.value&&null===o.prop&&p(r)?o.prop=t:v(o.prop)&&(t===e.length-1||!o.value&&(m(r)||o.lean&&"\n"===r))&&(o.value=t+1),function(e,t,r,o){o.value&&g(r)&&(o.quote=!o.quote);!o.quote&&null!==o.prop&&(t===e.length-1||";"===r||"}"===e[t+1]||o.lean&&","!==e[t-1]&&"\n"===r)&&(o.out.push(function(e){var t=e[0],r=e[1];t=l.reduce((function(e,t){return t(e)}),t.trim());for(var o="",i=0,u="px",a=0;a<r.length;a++){if(h(r[a])||a===r.length-1){var c=r.slice(i,a+1).trim();o+=(u&&n(t)?c.replace(/(^|[( ,])([-0-9.]+)([ ,)]|$)/g,"$1$2"+u+"$3").trim():c)+(","===r[a]?"":" "),i=a+1}"("!==r[a]&&")"!==r[a-1]||(u=0===r.slice(i,a).indexOf("translate")?"px":0===r.slice(i,a).indexOf("rotate")?"deg":"")}return[t,o.trim().replace(/[\n ]+/g," ")]}(e.slice(o.prop,t+1).match(/\s*([a-z-]+)[\s:]*([^;]+)/).slice(1))),o.end=t+1,o.comma=o.value,o.value=o.prop=null,o.lean=!0)}(e,t,r,o)}}u.forEach((function(e){var t=e.match(/-(ms|o|webkit|moz)-/g);if(t){var n=e.replace(/-(ms|o|webkit|moz)-/,"");if(-1===u.indexOf(n))return"flexDirection"===n&&(b.flex="-"+t[1].toLowerCase()+"-flex"),void(x[n]=e)}}));var j=O();return j.create=O,j})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).b=t()}(this,(function(){"use strict";var e="undefined"!=typeof document&&document.createElement("div"),t={flex:0,border:1,transform:1,"line-height":0,"box-shadow":1,"border-top":1,"border-left":1,"border-right":1,"border-bottom":1};function n(n){if("-"===n[0]&&"-"===n[1]||n in t)return t[n];try{return e.style[n]="1px",e.style.setProperty(n,"1px"),t[n]="1px"===e.style[n].slice(-3)}catch(e){return t[n]=!1}}var r=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,o=function(e){return e.replace(/(\B[A-Z])/g,"-$1").toLowerCase()},i=function(e){return e?e.hasOwnProperty("width")?e:i(Object.getPrototypeOf(e)):{}},u=["float"].concat(Object.keys("undefined"==typeof document?{}:i(document.documentElement.style))).filter((function(e,t,n){return-1===e.indexOf("-")&&"length"!==e&&n.indexOf(e)===t})).map((function(e){return e.match(r)?"-"+o(e):o(e)})).sort(),l=function(e,t){var n;return Object.assign(e,((n={})[t.split("-").map((function(e){return e[0]})).join("")]=t,n))},a=Object.assign(u.reduce(l,{}),["align-items","bottom","background-color","border-radius","box-shadow","background-image","color","display","float","flex-direction","font-family","font-size","height","justify-content","left","line-height","letter-spacing","margin","margin-bottom","margin-left","margin-right","margin-top","opacity","padding","padding-bottom","padding-left","padding-right","padding-top","right","top","text-align","text-decoration","text-transform","width"].reduce(l,{}));function c(e){return a[e]||e}var s="undefined"!==document&&window.document,f=function(e,t){return t?function(t){return e.indexOf(t.toLowerCase())>-1}:function(t){return e.indexOf(t)>-1}},p=f("abcdefghijklmnopqrstuvwxyz-"),d=f("abcdefghijklmnopqrstuvwxyz0123456789-_",!0),g=f("'\""),m=f(" :"),h=f(" ,)"),v=function(e){return"number"==typeof e},x=Object.create(null,{}),b=Object.create(null,{}),y=function(){return"bss"+("000000"+(Math.random()*Math.pow(36,6)|0).toString(36)).slice(-6)};function O(e){void 0===e&&(e={});var t=e.style;void 0===t&&(t=s&&s.querySelector&&s.querySelector(".bss_style")||s.createElement("style"));var r=e.prefix;void 0===r&&(r=t&&t.getAttribute("id")||y());var o=e.append;void 0===o&&(o=!0);var i={},l=[],a=[],f=O();return f.count=0,f.rules=t&&t.textContent&&t.textContent.split(f.prefix+"{}")||[],f.debug=!1,f.dev=!1,f.prefix=r,f.properties=u,f.at=function(e){return a.unshift("function"==typeof e?e:function(t){return e[t.slice(1)]||t})},f.prop=function(e){return l.unshift(e)},f.create=O,f.ssr=function(){return'<style class="bss_style" id="'+f.prefix+'">'+f.rules.join(f.prefix+"{}")+"</style>"},f.global=function(){$(j(f.apply(f,arguments).content).trim(),"__raw").forEach((function(e){return w(e.replace(/.__raw/g,"").trim())}))},f.prop((function(e){if(-1===u.indexOf(e)){if(x[e])return f.debug&&console.log(e,"prefixed to",x[e]),x[e];f.debug&&console.log(e,"not found")}return e})),f.prop(c),t&&(t.id=f.prefix),f;function b(){return this.className?this.className:(this.className=f.prefix+ ++f.count,$(j(this.content).trim(),this.className).forEach(w),this.className)}function O(e){return function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];for(var o=(e||"")+t[0],u=1;u<t.length;u++){var l=n[u-1];o+=(l&&l.toString===b?l.content:Array.isArray(l)?l.map((function(e){return e.content||e})).join("\n"):l)+t[u]}if(o in i)return i[o];var a=O("\n"+o+"\n");return a.toString=a.valueOf=b,a.content=o,i[o]=a,a}}function j(e){return e.replace(/\/\/.*?(\n|$)/g,"\n").replace(/\/\*[\s\S]*?\*\//g,"")}function w(e){o&&(t&&s.head&&s.head.appendChild(t),o=!1);var n=0===e.indexOf("@import")?0:f.rules.length;if(0===n?f.rules.unshift(e):f.rules.push(e),f.dev&&t)t.textContent=f.rules.map(k).join("\n");else if(t&&t.sheet)try{t.sheet.insertRule(e,n)}catch(e){f.debug&&console.log("Ignored error:",e)}}function k(e){return e.replace(/{/g," {\n").replace(/([;{])\n*/g,"$1\n ").replace(/(.*):(.*);/g,"$1: $2;").replace(/[\s]*}/g,"\n}\n").replace(/,\s*/g,", ").replace(/@.*{[\s\S]*?}[\s]*}/g,(function(e){return e.split("\n").reduce((function(e,t,n,r){return e+(n<r.length-1?"\n":"")+(n>1&&n<r.length-2?" ":"")+t}),"")})).trim().replace("}\n\n}","}\n}")}function $(e,t){for(var n=[],r={prop:null,value:null,out:[],lean:!0,comma:0,end:0,quote:!1},o=[],i=!1,u=!1,l=!1,c=!1,s=0;s<e.length;s++)if(s>0&&c&&!d(e[s])&&(t=e.slice(1,s)+"-"+t,c=!1),c||0===s&&"."===e[s])c=!0;else if(z(e,s,e[s],r),"}"===e[s]||s===e.length-1)q(i||u||l||n,s,t,r,o),i&&!o.length&&((u||l||n).push(i.selector+"{"+i.join("")+"}"),i=!1),u&&!o.length&&((l||n).push(u.selector+"{"+u.join("")+"}"),u=!1),l&&!o.length&&(n.push(l.selector+"{"+l.join("")+"}"),l=!1),o.pop();else if("{"===e[s]){var f=e.slice(r.end,s).trim().replace(/,[\s]*/,",& ");0===f.indexOf("animation")&&r.out.push(["animation",f.slice(10)+" "+t]),q(i||u||l||n,s,t,r,o),r.prop=r.value=null,0===f.indexOf("@supports")?l=Object.assign([],{selector:f}):"@"===f[0]?u=Object.assign([],{selector:a.reduce((function(e,t){return t(e)}),f.trim())}):0===f.indexOf("animation")?i=Object.assign([],{selector:"@keyframes "+t}):o.push(f)}return n}function q(e,t,n,r,o){var i=r.out.length&&r.out.map((function(e){return e.join(":")})).join(";"),u=o.length&&":"!==o[0][0];i&&e.push((o.length&&"&"===o[0][0]||0===(!e.selector||e.selector.indexOf("@keyframes "))?"":(u?"":"."+n)+"."+n+(u?" ":""))+o.join(" ").replace(/&/g,"."+n).replace(/ :/g,":")+"{"+i+";}"),r.end=t+1,r.out=[]}function z(e,t,r,o){!o.value&&null!==o.prop&&o.lean&&":"===r&&(o.lean=!1),!o.value&&null!==o.prop&&o.out.length&&","===r?(o.value=o.comma,o.prop=o.out[o.out.length-1][0]):!o.value&&null===o.prop&&p(r)?o.prop=t:v(o.prop)&&(t===e.length-1||!o.value&&(m(r)||o.lean&&"\n"===r))&&(o.value=t+1),function(e,t,r,o){o.value&&g(r)&&(o.quote=!o.quote);!o.quote&&null!==o.prop&&(t===e.length-1||";"===r||"}"===e[t+1]||o.lean&&","!==e[t-1]&&"\n"===r)&&(o.out.push(function(e){var t=e[0],r=e[1];t=l.reduce((function(e,t){return t(e)}),t.trim());for(var o="",i=0,u="px",a=0;a<r.length;a++){if(h(r[a])||a===r.length-1){var c=r.slice(i,a+1).trim();o+=(u&&n(t)?c.replace(/(^|[( ,])([-0-9.]+)([ ,)]|$)/g,"$1$2"+u+"$3").trim():c)+(","===r[a]?"":" "),i=a+1}"("!==r[a]&&")"!==r[a-1]||(u=0===r.slice(i,a).indexOf("translate")?"px":0===r.slice(i,a).indexOf("rotate")?"deg":"")}return[t,o.trim().replace(/[\n ]+/g," ")]}(e.slice(o.prop,t+1).match(/\s*([a-z-]+)[\s:]*([^;]+)/i).slice(1))),o.end=t+1,o.comma=o.value,o.value=o.prop=null,o.lean=!0)}(e,t,r,o)}}u.forEach((function(e){var t=e.match(/-(ms|o|webkit|moz)-/g);if(t){var n=e.replace(/-(ms|o|webkit|moz)-/,"");if(-1===u.indexOf(n))return"flexDirection"===n&&(b.flex="-"+t[1].toLowerCase()+"-flex"),void(x[n]=e)}}));var j=O();return j.create=O,j})); | ||
//# sourceMappingURL=bss.min.js.map |
@@ -277,3 +277,3 @@ import px from './px.js' | ||
propParse( | ||
s.slice(x.prop, i + 1).match(/\s*([a-z-]+)[\s:]*([^;]+)/).slice(1) | ||
s.slice(x.prop, i + 1).match(/\s*([a-z-]+)[\s:]*([^;]+)/i).slice(1) | ||
) | ||
@@ -280,0 +280,0 @@ ) |
@@ -16,3 +16,3 @@ const el = typeof document !== 'undefined' && document.createElement('div') // eslint-disable-line | ||
export default function(x) { | ||
if (x in cache) | ||
if ((x[0] === '-' && x[1] === '-') || x in cache) | ||
return cache[x] | ||
@@ -19,0 +19,0 @@ |
{ | ||
"name": "bss", | ||
"version": "3.0.0-rc.2", | ||
"version": "3.0.0-rc.3", | ||
"description": "Better Style Sheets", | ||
@@ -8,3 +8,3 @@ "main": "dist/bss.js", | ||
"scripts": { | ||
"test": "TEST=true npm run build && node tests/index.js", | ||
"test": "TEST=true npm run build && plog tests/index.js", | ||
"lint": "eslint lib && eslint tests", | ||
@@ -11,0 +11,0 @@ "prepublishOnly": "npm run lint && npm run build", |
@@ -105,2 +105,15 @@ const { t, ot, not } = require('./test') | ||
t('css variabless', () => { | ||
b` | ||
--lowercase 1 | ||
--camelCase 1 | ||
--UPPERCASE 1 | ||
`.toString() | ||
return [ | ||
b.rules.pop(), | ||
cn() + cn() + '{--lowercase:1;--camelCase:1;--UPPERCASE:1;}' | ||
] | ||
}) | ||
t('Fails gracefully on bad prop syntax', () => { | ||
@@ -107,0 +120,0 @@ b` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
145761
1739