Comparing version 1.6.3 to 1.6.4
@@ -166,4 +166,5 @@ var pseudos = [ | ||
var hyphenSeparator = /-([a-z])/g; | ||
function hyphenToCamelCase(hyphen) { | ||
return hyphen.slice(hyphen.charAt(0) === '-' ? 1 : 0).replace(/-([a-z])/g, function(match) { | ||
return hyphen.slice(hyphen.charAt(0) === '-' ? 1 : 0).replace(hyphenSeparator, function(match) { | ||
return match[1].toUpperCase() | ||
@@ -173,10 +174,13 @@ }) | ||
var camelSeparator = /(\B[A-Z])/g; | ||
function camelCaseToHyphen(camelCase) { | ||
return camelCase.replace(/(\B[A-Z])/g, '-$1').toLowerCase() | ||
return camelCase.replace(camelSeparator, '-$1').toLowerCase() | ||
} | ||
var initialMatch = /([A-Z])/g; | ||
function initials(camelCase) { | ||
return camelCase.charAt(0) + (camelCase.match(/([A-Z])/g) || []).join('').toLowerCase() | ||
return camelCase.charAt(0) + (camelCase.match(initialMatch) || []).join('').toLowerCase() | ||
} | ||
var ampersandMatch = /&/g; | ||
function objectToRules(style, selector, suffix, single) { | ||
@@ -200,3 +204,3 @@ if ( suffix === void 0 ) suffix = ''; | ||
rules.unshift( | ||
((single || (suffix.charAt(0) === ' ') ? '' : '&') + extra + suffix).replace(/&/g, selector).trim() + | ||
((single || (suffix.charAt(0) === ' ') ? '' : '&') + extra + suffix).replace(ampersandMatch, selector).trim() + | ||
'{' + stylesToCss(base) + '}' | ||
@@ -212,3 +216,3 @@ ); | ||
function stylesToCss(style) { | ||
return Object.keys(style).reduce(function (acc, prop) { return acc + propToString(prop.replace(/!/g, ''), style[prop]); } | ||
return Object.keys(style).reduce(function (acc, prop) { return acc + propToString(prop.charAt(0) === '!' ? prop.slice(1) : prop, style[prop]); } | ||
, '') | ||
@@ -372,3 +376,3 @@ } | ||
if (typeof this$1.__style[key] === 'number' || typeof this$1.__style[key] === 'string') | ||
{ acc[key.replace(/^!/, '')] = this$1.__style[key]; } | ||
{ acc[key.charAt(0) === '!' ? key.slice(1) : key] = this$1.__style[key]; } | ||
return acc | ||
@@ -430,9 +434,8 @@ }, {}) | ||
var hasUrl = /^('|"|url\('|url\(")/i; | ||
function $import(value) { | ||
if (value && !/^('|"|url\('|url\(")/.test(value)) | ||
{ value = '"' + value + '"'; } | ||
value && insert('@import ' | ||
+ (hasUrl.test(value) ? value : '"' + value + '"') | ||
+ ';', 0); | ||
if (value) | ||
{ insert('@import ' + value + ';', 0); } | ||
return chain(this) | ||
@@ -540,2 +543,6 @@ } | ||
var blockEndMatch = /;(?![^("]*[)"])|\n/; | ||
var commentsMatch = /\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g; | ||
var propSeperator = /[ :]+/; | ||
var stringToObject = memoize(function (string) { | ||
@@ -545,7 +552,7 @@ var last = '' | ||
return string.trim().replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g, '').split(/;(?![^("]*[)"])|\n/).reduce(function (acc, line) { | ||
return string.trim().replace(commentsMatch, '').split(blockEndMatch).reduce(function (acc, line) { | ||
if (!line) | ||
{ return acc } | ||
line = last + line.trim(); | ||
var ref = line.replace(/[ :]+/, ' ').split(' '); | ||
var ref = line.replace(propSeperator, ' ').split(' '); | ||
var key = ref[0]; | ||
@@ -552,0 +559,0 @@ var tokens = ref.slice(1); |
37
bss.js
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = global || self, global.b = factory()); | ||
}(this, function () { 'use strict'; | ||
}(this, (function () { 'use strict'; | ||
@@ -173,4 +173,5 @@ var pseudos = [ | ||
var hyphenSeparator = /-([a-z])/g; | ||
function hyphenToCamelCase(hyphen) { | ||
return hyphen.slice(hyphen.charAt(0) === '-' ? 1 : 0).replace(/-([a-z])/g, function(match) { | ||
return hyphen.slice(hyphen.charAt(0) === '-' ? 1 : 0).replace(hyphenSeparator, function(match) { | ||
return match[1].toUpperCase() | ||
@@ -180,10 +181,13 @@ }) | ||
var camelSeparator = /(\B[A-Z])/g; | ||
function camelCaseToHyphen(camelCase) { | ||
return camelCase.replace(/(\B[A-Z])/g, '-$1').toLowerCase() | ||
return camelCase.replace(camelSeparator, '-$1').toLowerCase() | ||
} | ||
var initialMatch = /([A-Z])/g; | ||
function initials(camelCase) { | ||
return camelCase.charAt(0) + (camelCase.match(/([A-Z])/g) || []).join('').toLowerCase() | ||
return camelCase.charAt(0) + (camelCase.match(initialMatch) || []).join('').toLowerCase() | ||
} | ||
var ampersandMatch = /&/g; | ||
function objectToRules(style, selector, suffix, single) { | ||
@@ -207,3 +211,3 @@ if ( suffix === void 0 ) suffix = ''; | ||
rules.unshift( | ||
((single || (suffix.charAt(0) === ' ') ? '' : '&') + extra + suffix).replace(/&/g, selector).trim() + | ||
((single || (suffix.charAt(0) === ' ') ? '' : '&') + extra + suffix).replace(ampersandMatch, selector).trim() + | ||
'{' + stylesToCss(base) + '}' | ||
@@ -219,3 +223,3 @@ ); | ||
function stylesToCss(style) { | ||
return Object.keys(style).reduce(function (acc, prop) { return acc + propToString(prop.replace(/!/g, ''), style[prop]); } | ||
return Object.keys(style).reduce(function (acc, prop) { return acc + propToString(prop.charAt(0) === '!' ? prop.slice(1) : prop, style[prop]); } | ||
, '') | ||
@@ -379,3 +383,3 @@ } | ||
if (typeof this$1.__style[key] === 'number' || typeof this$1.__style[key] === 'string') | ||
{ acc[key.replace(/^!/, '')] = this$1.__style[key]; } | ||
{ acc[key.charAt(0) === '!' ? key.slice(1) : key] = this$1.__style[key]; } | ||
return acc | ||
@@ -437,9 +441,8 @@ }, {}) | ||
var hasUrl = /^('|"|url\('|url\(")/i; | ||
function $import(value) { | ||
if (value && !/^('|"|url\('|url\(")/.test(value)) | ||
{ value = '"' + value + '"'; } | ||
value && insert('@import ' | ||
+ (hasUrl.test(value) ? value : '"' + value + '"') | ||
+ ';', 0); | ||
if (value) | ||
{ insert('@import ' + value + ';', 0); } | ||
return chain(this) | ||
@@ -547,2 +550,6 @@ } | ||
var blockEndMatch = /;(?![^("]*[)"])|\n/; | ||
var commentsMatch = /\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g; | ||
var propSeperator = /[ :]+/; | ||
var stringToObject = memoize(function (string) { | ||
@@ -552,7 +559,7 @@ var last = '' | ||
return string.trim().replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g, '').split(/;(?![^("]*[)"])|\n/).reduce(function (acc, line) { | ||
return string.trim().replace(commentsMatch, '').split(blockEndMatch).reduce(function (acc, line) { | ||
if (!line) | ||
{ return acc } | ||
line = last + line.trim(); | ||
var ref = line.replace(/[ :]+/, ' ').split(' '); | ||
var ref = line.replace(propSeperator, ' ').split(' '); | ||
var key = ref[0]; | ||
@@ -659,3 +666,3 @@ var tokens = ref.slice(1); | ||
})); | ||
}))); | ||
//# sourceMappingURL=bss.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).b=e()}(this,function(){"use strict";var r={ai:"alignItems",b:"bottom",bc:"backgroundColor",br:"borderRadius",bs:"boxShadow",bi:"backgroundImage",c:"color",d:"display",f:"float",fd:"flexDirection",ff:"fontFamily",fs:"fontSize",h:"height",jc:"justifyContent",l:"left",lh:"lineHeight",ls:"letterSpacing",m:"margin",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mt:"marginTop",o:"opacity",p:"padding",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",pt:"paddingTop",r:"right",t:"top",ta:"textAlign",td:"textDecoration",tt:"textTransform",w:"width"},i=["float"].concat(Object.keys("undefined"==typeof document?{}:function t(e){return e?e.hasOwnProperty("width")?e:t(Object.getPrototypeOf(e)):{}}(document.documentElement.style)).filter(function(t){return-1===t.indexOf("-")&&"length"!==t}));function t(e,n){return void 0===n&&(n={}),function(t){return t in n?n[t]:n[t]=e(t)}}var a=/^-?-?[a-z][a-z-_0-9]*$/i;function l(t,e,n){e in t?l(t,"!"+e,n):t[e]=function t(e,n){return Array.isArray(n)?n.map(function(t){return h(e,t)}).join(" "):"string"==typeof n?t(e,n.split(" ")):h(e,n)}(e,n)}var o=Object.create(null,{}),c=Object.create(null,{}),u=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,n=t(function(t){var e=document.createElement("div");try{return e.style[t]="1px",e.style.setProperty(t,"1px"),"1px"===e.style[t].slice(-3)?"px":""}catch(t){return""}},{flex:"",boxShadow:"px",border:"px",borderTop:"px",borderRight:"px",borderBottom:"px",borderLeft:"px"});function f(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]="string"==typeof e[n]?e[n]:f(t[n]||{},e[n]));return t}function s(t){return t.slice("-"===t.charAt(0)?1:0).replace(/-([a-z])/g,function(t){return t[1].toUpperCase()})}function p(e,n,r,i){void 0===r&&(r="");var o={},t=-1<r.indexOf("&")&&-1===r.indexOf(",")?"":"&",c=[];return Object.keys(e).forEach(function(t){"@"===t.charAt(0)?c.push(t+"{"+p(e[t],n,r,i).join("")+"}"):"object"==typeof e[t]?c=c.concat(p(e[t],n,r+t,i)):o[t]=e[t]}),Object.keys(o).length&&c.unshift(((i||" "===r.charAt(0)?"":"&")+t+r).replace(/&/g,n).trim()+"{"+d(o)+"}"),c}var y=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/;function d(n){return Object.keys(n).reduce(function(t,e){return t+function(t,e){return t=t in o?o[t]:t,(u.test(t)?"-":"")+(g(t)?t:function(t){return t.replace(/(\B[A-Z])/g,"-$1").toLowerCase()}(t))+":"+e+";"}(e.replace(/!/g,""),n[e])},"")}function h(t,e){return e in c?c[e]:e+(isNaN(e)||null===e||0===e||"0"===e||"boolean"==typeof e||g(t)?"":n(t))}function g(t){return"-"===t.charAt(0)&&"-"===t.charAt(1)}var b="b"+("000"+(46656*Math.random()|0).toString(36)).slice(-3)+("000"+(46656*Math.random()|0).toString(36)).slice(-3),m="object"==typeof document&&document.createElement("style");m&&document.head&&document.head.appendChild(m),m&&(m.id=b);var _=m&&m.sheet,v=!1,j=Object.create(null,{}),O=[],x=0;function A(t,e){if(O.push(t),v)return m.textContent=O.join("\n");try{_&&_.insertRule(t,1<arguments.length?e:_.cssRules.length)}catch(t){}}var k=Object.create(null);function w(t,e){var n=$(w);return t&&f(n.__style,D.apply(null,arguments)),n}function S(t,e){Object.defineProperty(w,t,{configurable:!0,value:e})}function $(t){var e=Object.create(w,{__style:{value:f({},t.__style)},style:{enumerable:!0,get:function(){var n=this;return Object.keys(this.__style).reduce(function(t,e){return"number"!=typeof n.__style[e]&&"string"!=typeof n.__style[e]||(t[e.replace(/^!/,"")]=n.__style[e]),t},{})}}});return t===w&&(w.__style={}),e}function E(t,e,n){var r=e.split(y).map(function(t){return(":"===(t=t.trim()).charAt(0)||"["===t.charAt(0)?"":" ")+t}).join(",&");r in t?f(t[r],D(n)):t[r]=D(n)}function P(n){return function(t){var e=$(this);return t||0===t?0<arguments.length&&l(e.__style,n,Array.prototype.slice.call(arguments)):delete e.__style[n],e}}function C(t,e){p(D(e),t,"",!0).forEach(function(t){return A(t)})}function L(e,r){if(1===arguments.length)return Object.keys(e).forEach(function(t){return L(t,e[t])});delete w[e],"function"==typeof r?(L[e]=r,Object.defineProperty(w,e,{configurable:!0,value:function(t){var e=$(this),n=T(t)?r(N(t,arguments)):r.apply(null,arguments);return f(e.__style,n.__style),e}})):(L[e]=D(r),Object.defineProperty(w,e,{configurable:!0,get:function(){var t=$(this);return f(t.__style,D(r)),t}}))}function R(t){var e=function(t){return t.charAt(0)+(t.match(/([A-Z])/g)||[]).join("").toLowerCase()}(t),n=r[e]&&r[e]!==t?t:e;return k[n]=t,n}Object.defineProperties(w,{__style:{configurable:!0,writable:!0,value:{}},valueOf:{configurable:!0,writable:!0,value:function(){return"."+this.class}},toString:{configurable:!0,writable:!0,value:function(){return this.class}}}),S("setDebug",function(t){v=t}),S("$keyframes",function(n){var t=Object.keys(n).reduce(function(t,e){return t+e+"{"+d(D(n[e]))+"}"},"");if(t in B)return B[t];var e=b+M++;return A("@keyframes "+(B[t]=e)+"{"+t+"}"),e}),S("$media",function(t,e){var n=$(this);t&&(n.__style["@media "+t]=D(e));return n}),S("$import",function(t){t&&!/^('|"|url\('|url\(")/.test(t)&&(t='"'+t+'"');t&&A("@import "+t+";",0);return $(this)}),S("$nest",function(e,t){var n=$(this);1===arguments.length?Object.keys(e).forEach(function(t){return E(n.__style,t,e[t])}):e&&E(n.__style,e,t);return n}),S("getSheet",function(){var t=O.join("");return O=[],j=Object.create(null,{}),x=0,t}),S("getRules",function(){return O}),S("helper",L),S("css",function(e,t){1===arguments.length?Object.keys(e).forEach(function(t){return C(t,e[t])}):C(e,t);return $(this)}),S("classPrefix",b),i.forEach(function(t){var e=t.match(u);if(e){var n=function(t){return t.charAt(0).toLowerCase()+t.slice(1)}(t.replace(u,"$2"));if(-1===i.indexOf(n))return"flexDirection"===n&&(c.flex="-"+e[1].toLowerCase()+"-flex"),S(n,P(o[n]=t)),void S(R(n),w[n])}S(t,P(t)),S(R(t),w[t])}),S("content",function(t){var e=$(this);return null==t||!1===t?delete e.__style.content:e.__style.content='"'+t+'"',e}),Object.defineProperty(w,"class",{set:function(t){this.__class=t},get:function(){return this.__class||function(t){var e=JSON.stringify(t);if(e in j)return j[e];for(var n=b+ ++x,r=p(t,"."+n),i=0;i<r.length;i++)A(r[i]);return j[e]=n}(this.__style)}}),[":active",":any",":checked",":default",":disabled",":empty",":enabled",":first",":first-child",":first-of-type",":fullscreen",":focus",":hover",":indeterminate",":in-range",":invalid",":last-child",":last-of-type",":left",":link",":only-child",":only-of-type",":optional",":out-of-range",":read-only",":read-write",":required",":right",":root",":scope",":target",":valid",":visited",":dir",":lang",":not",":nth-child",":nth-last-child",":nth-last-of-type",":nth-of-type","::after","::before","::first-letter","::first-line","::selection","::backdrop","::placeholder","::marker","::spelling-error","::grammar-error"].forEach(function(r){return S("$"+s(r.replace(/:/g,"")),function(t,e){var n=$(this);return T(t)?n.__style[r]=D.apply(null,arguments):(t||e)&&(n.__style[r+(e?"("+t+")":"")]=D(e||t)),n})}),w.helper("$animate",function(t,e){return w.animation(w.$keyframes(e)+" "+t)});var z=t(function(t){var c,u="";return t.trim().replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g,"").split(/;(?![^("]*[)"])|\n/).reduce(function(t,e){if(!e)return t;var n=(e=u+e.trim()).replace(/[ :]+/," ").split(" "),r=n[0],i=n.slice(1);if(u=","===e.charAt(e.length-1)?e:"")return t;if(","===e.charAt(0)||!a.test(r))return t[c]+=" "+e,t;if(!r)return t;var o="-"===r.charAt(0)&&"-"===r.charAt(1)?r:s(r);return c=k[o]||o,r in L?f(t,"function"==typeof L[r]?L[r].apply(L,i).__style:L[r]):o in L?f(t,"function"==typeof L[o]?L[o].apply(L,i).__style:L[o]):0<i.length&&l(t,c,i),t},{})}),M=0,B={};function D(t,e){var n;return"string"==typeof t?"string"==typeof e||"number"==typeof e?((n={})[t]=e,n):z(t):T(t)?z(N(t,arguments)):t.__style||function r(i){return Object.keys(i).reduce(function(t,e){var n=i[e];return e=k[e]||e,(n||0===n||""===n)&&("content"===e&&'"'!==n.charAt(0)?t[e]='"'+n+'"':"object"==typeof n?t[e]=r(n):l(t,e,n)),t},{})}(t)}function T(t){return Array.isArray(t)&&"string"==typeof t[0]}function N(t,e){for(var n="",r=0;r<t.length;r++)n+=t[r]+(e[r+1]||0===e[r+1]?e[r+1]:"");return n}return w}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).b=e()}(this,function(){"use strict";var i={ai:"alignItems",b:"bottom",bc:"backgroundColor",br:"borderRadius",bs:"boxShadow",bi:"backgroundImage",c:"color",d:"display",f:"float",fd:"flexDirection",ff:"fontFamily",fs:"fontSize",h:"height",jc:"justifyContent",l:"left",lh:"lineHeight",ls:"letterSpacing",m:"margin",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mt:"marginTop",o:"opacity",p:"padding",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",pt:"paddingTop",r:"right",t:"top",ta:"textAlign",td:"textDecoration",tt:"textTransform",w:"width"},o=["float"].concat(Object.keys("undefined"==typeof document?{}:function t(e){return e?e.hasOwnProperty("width")?e:t(Object.getPrototypeOf(e)):{}}(document.documentElement.style)).filter(function(t){return-1===t.indexOf("-")&&"length"!==t}));function t(e,r){return void 0===r&&(r={}),function(t){return t in r?r[t]:r[t]=e(t)}}var u=/^-?-?[a-z][a-z-_0-9]*$/i;function l(t,e,r){e in t?l(t,"!"+e,r):t[e]=function t(e,r){return Array.isArray(r)?r.map(function(t){return n(e,t)}).join(" "):"string"==typeof r?t(e,r.split(" ")):n(e,r)}(e,r)}var c=Object.create(null,{}),a=Object.create(null,{}),f=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,r=t(function(t){var e=document.createElement("div");try{return e.style[t]="1px",e.style.setProperty(t,"1px"),"1px"===e.style[t].slice(-3)?"px":""}catch(t){return""}},{flex:"",boxShadow:"px",border:"px",borderTop:"px",borderRight:"px",borderBottom:"px",borderLeft:"px"});function s(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]="string"==typeof e[r]?e[r]:s(t[r]||{},e[r]));return t}var e=/-([a-z])/g;function p(t){return t.slice("-"===t.charAt(0)?1:0).replace(e,function(t){return t[1].toUpperCase()})}var y=/(\B[A-Z])/g;var h=/([A-Z])/g;var d=/&/g;function g(e,r,n,i){void 0===n&&(n="");var o={},t=-1<n.indexOf("&")&&-1===n.indexOf(",")?"":"&",c=[];return Object.keys(e).forEach(function(t){"@"===t.charAt(0)?c.push(t+"{"+g(e[t],r,n,i).join("")+"}"):"object"==typeof e[t]?c=c.concat(g(e[t],r,n+t,i)):o[t]=e[t]}),Object.keys(o).length&&c.unshift(((i||" "===n.charAt(0)?"":"&")+t+n).replace(d,r).trim()+"{"+m(o)+"}"),c}var b=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/;function m(i){return Object.keys(i).reduce(function(t,e){return t+(r="!"===e.charAt(0)?e.slice(1):e,n=i[e],r=r in c?c[r]:r,(f.test(r)?"-":"")+(v(r)?r:function(t){return t.replace(y,"-$1").toLowerCase()}(r))+":"+n+";");var r,n},"")}function n(t,e){return e in a?a[e]:e+(isNaN(e)||null===e||0===e||"0"===e||"boolean"==typeof e||v(t)?"":r(t))}function v(t){return"-"===t.charAt(0)&&"-"===t.charAt(1)}var _="b"+("000"+(46656*Math.random()|0).toString(36)).slice(-3)+("000"+(46656*Math.random()|0).toString(36)).slice(-3),j="object"==typeof document&&document.createElement("style");j&&document.head&&document.head.appendChild(j),j&&(j.id=_);var O=j&&j.sheet,x=!1,A=Object.create(null,{}),k=[],w=0;function S(t,e){if(k.push(t),x)return j.textContent=k.join("\n");try{O&&O.insertRule(t,1<arguments.length?e:O.cssRules.length)}catch(t){}}var $=Object.create(null);function E(t,e){var r=C(E);return t&&s(r.__style,F.apply(null,arguments)),r}function P(t,e){Object.defineProperty(E,t,{configurable:!0,value:e})}function C(t){var e=Object.create(E,{__style:{value:s({},t.__style)},style:{enumerable:!0,get:function(){var r=this;return Object.keys(this.__style).reduce(function(t,e){return"number"!=typeof r.__style[e]&&"string"!=typeof r.__style[e]||(t["!"===e.charAt(0)?e.slice(1):e]=r.__style[e]),t},{})}}});return t===E&&(E.__style={}),e}Object.defineProperties(E,{__style:{configurable:!0,writable:!0,value:{}},valueOf:{configurable:!0,writable:!0,value:function(){return"."+this.class}},toString:{configurable:!0,writable:!0,value:function(){return this.class}}}),P("setDebug",function(t){x=t}),P("$keyframes",function(r){var t=Object.keys(r).reduce(function(t,e){return t+e+"{"+m(F(r[e]))+"}"},"");if(t in q)return q[t];var e=_+W++;return S("@keyframes "+(q[t]=e)+"{"+t+"}"),e}),P("$media",function(t,e){var r=C(this);t&&(r.__style["@media "+t]=F(e));return r}),P("$import",function(t){return t&&S("@import "+(L.test(t)?t:'"'+t+'"')+";",0),C(this)}),P("$nest",function(e,t){var r=C(this);1===arguments.length?Object.keys(e).forEach(function(t){return R(r.__style,t,e[t])}):e&&R(r.__style,e,t);return r}),P("getSheet",function(){var t=k.join("");return k=[],A=Object.create(null,{}),w=0,t}),P("getRules",function(){return k}),P("helper",B),P("css",function(e,t){1===arguments.length?Object.keys(e).forEach(function(t){return M(t,e[t])}):M(e,t);return C(this)}),P("classPrefix",_),o.forEach(function(t){var e,r=t.match(f);if(r){var n=(e=t.replace(f,"$2")).charAt(0).toLowerCase()+e.slice(1);if(-1===o.indexOf(n))return"flexDirection"===n&&(a.flex="-"+r[1].toLowerCase()+"-flex"),P(n,z(c[n]=t)),void P(D(n),E[n])}P(t,z(t)),P(D(t),E[t])}),P("content",function(t){var e=C(this);return null==t||!1===t?delete e.__style.content:e.__style.content='"'+t+'"',e}),Object.defineProperty(E,"class",{set:function(t){this.__class=t},get:function(){return this.__class||function(t){var e=JSON.stringify(t);if(e in A)return A[e];for(var r=_+ ++w,n=g(t,"."+r),i=0;i<n.length;i++)S(n[i]);return A[e]=r}(this.__style)}});var L=/^('|"|url\('|url\(")/i;function R(t,e,r){var n=e.split(b).map(function(t){return(":"===(t=t.trim()).charAt(0)||"["===t.charAt(0)?"":" ")+t}).join(",&");n in t?s(t[n],F(r)):t[n]=F(r)}function z(r){return function(t){var e=C(this);return t||0===t?0<arguments.length&&l(e.__style,r,Array.prototype.slice.call(arguments)):delete e.__style[r],e}}function M(t,e){g(F(e),t,"",!0).forEach(function(t){return S(t)})}function B(e,n){if(1===arguments.length)return Object.keys(e).forEach(function(t){return B(t,e[t])});delete E[e],"function"==typeof n?(B[e]=n,Object.defineProperty(E,e,{configurable:!0,value:function(t){var e=C(this),r=H(t)?n(J(t,arguments)):n.apply(null,arguments);return s(e.__style,r.__style),e}})):(B[e]=F(n),Object.defineProperty(E,e,{configurable:!0,get:function(){var t=C(this);return s(t.__style,F(n)),t}}))}function D(t){var e,r=(e=t).charAt(0)+(e.match(h)||[]).join("").toLowerCase(),n=i[r]&&i[r]!==t?t:r;return $[n]=t,n}[":active",":any",":checked",":default",":disabled",":empty",":enabled",":first",":first-child",":first-of-type",":fullscreen",":focus",":hover",":indeterminate",":in-range",":invalid",":last-child",":last-of-type",":left",":link",":only-child",":only-of-type",":optional",":out-of-range",":read-only",":read-write",":required",":right",":root",":scope",":target",":valid",":visited",":dir",":lang",":not",":nth-child",":nth-last-child",":nth-last-of-type",":nth-of-type","::after","::before","::first-letter","::first-line","::selection","::backdrop","::placeholder","::marker","::spelling-error","::grammar-error"].forEach(function(n){return P("$"+p(n.replace(/:/g,"")),function(t,e){var r=C(this);return H(t)?r.__style[n]=F.apply(null,arguments):(t||e)&&(r.__style[n+(e?"("+t+")":"")]=F(e||t)),r})}),E.helper("$animate",function(t,e){return E.animation(E.$keyframes(e)+" "+t)});var T=/;(?![^("]*[)"])|\n/,N=/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g,Z=/[ :]+/,I=t(function(t){var c,a="";return t.trim().replace(N,"").split(T).reduce(function(t,e){if(!e)return t;var r=(e=a+e.trim()).replace(Z," ").split(" "),n=r[0],i=r.slice(1);if(a=","===e.charAt(e.length-1)?e:"")return t;if(","===e.charAt(0)||!u.test(n))return t[c]+=" "+e,t;if(!n)return t;var o="-"===n.charAt(0)&&"-"===n.charAt(1)?n:p(n);return c=$[o]||o,n in B?s(t,"function"==typeof B[n]?B[n].apply(B,i).__style:B[n]):o in B?s(t,"function"==typeof B[o]?B[o].apply(B,i).__style:B[o]):0<i.length&&l(t,c,i),t},{})}),W=0,q={};function F(t,e){var r;return"string"==typeof t?"string"==typeof e||"number"==typeof e?((r={})[t]=e,r):I(t):H(t)?I(J(t,arguments)):t.__style||function n(i){return Object.keys(i).reduce(function(t,e){var r=i[e];return e=$[e]||e,(r||0===r||""===r)&&("content"===e&&'"'!==r.charAt(0)?t[e]='"'+r+'"':"object"==typeof r?t[e]=n(r):l(t,e,r)),t},{})}(t)}function H(t){return Array.isArray(t)&&"string"==typeof t[0]}function J(t,e){for(var r="",n=0;n<t.length;n++)r+=t[n]+(e[n+1]||0===e[n+1]?e[n+1]:"");return r}return E}); | ||
//# sourceMappingURL=bss.min.js.map |
@@ -90,3 +90,3 @@ /* eslint no-invalid-this: 0 */ | ||
if (typeof this.__style[key] === 'number' || typeof this.__style[key] === 'string') | ||
acc[key.replace(/^!/, '')] = this.__style[key] | ||
acc[key.charAt(0) === '!' ? key.slice(1) : key] = this.__style[key] | ||
return acc | ||
@@ -148,9 +148,8 @@ }, {}) | ||
const hasUrl = /^('|"|url\('|url\(")/i | ||
function $import(value) { | ||
if (value && !/^('|"|url\('|url\(")/.test(value)) | ||
value = '"' + value + '"' | ||
value && insert('@import ' | ||
+ (hasUrl.test(value) ? value : '"' + value + '"') | ||
+ ';', 0) | ||
if (value) | ||
insert('@import ' + value + ';', 0) | ||
return chain(this) | ||
@@ -260,2 +259,6 @@ } | ||
const blockEndMatch = /;(?![^("]*[)"])|\n/ | ||
const commentsMatch = /\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g | ||
const propSeperator = /[ :]+/ | ||
const stringToObject = memoize(string => { | ||
@@ -265,7 +268,7 @@ let last = '' | ||
return string.trim().replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g, '').split(/;(?![^("]*[)"])|\n/).reduce((acc, line) => { | ||
return string.trim().replace(commentsMatch, '').split(blockEndMatch).reduce((acc, line) => { | ||
if (!line) | ||
return acc | ||
line = last + line.trim() | ||
const [key, ...tokens] = line.replace(/[ :]+/, ' ').split(' ') | ||
const [key, ...tokens] = line.replace(propSeperator, ' ').split(' ') | ||
@@ -272,0 +275,0 @@ last = line.charAt(line.length - 1) === ',' ? line : '' |
@@ -69,4 +69,5 @@ export const cssProperties = ['float'].concat(Object.keys( | ||
const hyphenSeparator = /-([a-z])/g | ||
export function hyphenToCamelCase(hyphen) { | ||
return hyphen.slice(hyphen.charAt(0) === '-' ? 1 : 0).replace(/-([a-z])/g, function(match) { | ||
return hyphen.slice(hyphen.charAt(0) === '-' ? 1 : 0).replace(hyphenSeparator, function(match) { | ||
return match[1].toUpperCase() | ||
@@ -76,10 +77,13 @@ }) | ||
const camelSeparator = /(\B[A-Z])/g | ||
export function camelCaseToHyphen(camelCase) { | ||
return camelCase.replace(/(\B[A-Z])/g, '-$1').toLowerCase() | ||
return camelCase.replace(camelSeparator, '-$1').toLowerCase() | ||
} | ||
const initialMatch = /([A-Z])/g | ||
export function initials(camelCase) { | ||
return camelCase.charAt(0) + (camelCase.match(/([A-Z])/g) || []).join('').toLowerCase() | ||
return camelCase.charAt(0) + (camelCase.match(initialMatch) || []).join('').toLowerCase() | ||
} | ||
const ampersandMatch = /&/g | ||
export function objectToRules(style, selector, suffix = '', single) { | ||
@@ -101,3 +105,3 @@ const base = {} | ||
rules.unshift( | ||
((single || (suffix.charAt(0) === ' ') ? '' : '&') + extra + suffix).replace(/&/g, selector).trim() + | ||
((single || (suffix.charAt(0) === ' ') ? '' : '&') + extra + suffix).replace(ampersandMatch, selector).trim() + | ||
'{' + stylesToCss(base) + '}' | ||
@@ -114,3 +118,3 @@ ) | ||
return Object.keys(style).reduce((acc, prop) => | ||
acc + propToString(prop.replace(/!/g, ''), style[prop]) | ||
acc + propToString(prop.charAt(0) === '!' ? prop.slice(1) : prop, style[prop]) | ||
, '') | ||
@@ -117,0 +121,0 @@ } |
{ | ||
"name": "bss", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "Better Style Sheets", | ||
@@ -16,8 +16,8 @@ "main": "bss.js", | ||
"devDependencies": { | ||
"ospec": "3.1.0", | ||
"rollup": "1.14.6", | ||
"rollup-plugin-buble": "0.19.6", | ||
"rollup-plugin-filesize": "6.1.0", | ||
"rollup-plugin-uglify": "6.0.2" | ||
"ospec": "4.0.1", | ||
"rollup": "1.31.0", | ||
"rollup-plugin-buble": "0.19.8", | ||
"rollup-plugin-filesize": "6.2.1", | ||
"rollup-plugin-uglify": "6.0.4" | ||
} | ||
} |
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
193323
2329