Comparing version 3.0.4 to 3.0.5
@@ -250,2 +250,4 @@ (function (global, factory) { | ||
var _selectorPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
// rendering a rule for the first time | ||
@@ -259,3 +261,3 @@ // will create an ID reference | ||
if (Object.keys(props).length > 0) { | ||
renderer.renderRule(rule, {}); | ||
renderer.renderRule(rule, {}, _selectorPrefix); | ||
} | ||
@@ -268,3 +270,3 @@ } | ||
var classNamePrefix = renderer.prettySelectors && rule.name ? rule.name + '_' : 'c'; | ||
var className = classNamePrefix + ruleId + generatePropsReference(props); | ||
var className = _selectorPrefix + classNamePrefix + ruleId + generatePropsReference(props); | ||
@@ -613,3 +615,3 @@ // only if the cached rule has not already been rendered | ||
return function (props) { | ||
return function combined(props) { | ||
return rules.reduce(function (style, rule) { | ||
@@ -616,0 +618,0 @@ return assign(style, rule(props)); |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.Fela=r()}(this,function(){"use strict";function e(e,r){return r={exports:{}},e(r,r.exports),r.exports}function r(e){var r=0,n=0,t=void 0,i=e.length;if(0===i)return"";for(;n<i;++n)t=e.charCodeAt(n),r=(r<<5)-r+t,r|=0;return"-"+r.toString(36)}function n(e){return Object.keys(e).sort().reduce(function(r,n){return r+n+e[n]},"")}function t(e){return Object.keys(m).reduce(function(r,n){return e.indexOf(n)>-1&&(r=m[n]),r},void 0)}function i(e,r,n){return n.reduce(function(e,n){return n(e,r)},e)}function o(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce(function(n,t){var i=e[t];if(i instanceof Object&&!Array.isArray(i)){var a=o(i,r[t]);Object.keys(a).length>0&&(n[t]=a)}else if(void 0!==i&&!r.hasOwnProperty(t)||r[t]!==i){if("string"==typeof i&&i.indexOf("undefined")>-1)return n;n[t]=i}return n},{})}function a(e){return Object.keys(e).reduce(function(r,n){return r.length>0&&(r+=";"),r+=g(n)+":"+e[n]},"")}function s(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[""],t=Object.keys(e).reduce(function(r,n){return r+n+"{"+a(e[n])+"}"},"");return n.reduce(function(e,n){return e+"@"+n+"keyframes "+r+"{"+t+"}"},"")}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={listeners:[],keyframePrefixes:e.keyframePrefixes||["-webkit-","-moz-"],plugins:e.plugins||[],prettySelectors:e.prettySelectors&&!1,clear:function(){r.fontFaces="",r.keyframes="",r.statics="",r.rules="",r.mediaRules={},r.rendered={},r.base={},r.ids=[],r.callStack=[],r._emitChange({type:"clear"})},renderRule:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r.ids.indexOf(e)<0&&(r.ids.push(e),Object.keys(n).length>0&&r.renderRule(e,{}));var t=r.ids.indexOf(e),a=r.prettySelectors&&e.name?e.name+"_":"c",s=a+t+h(n);if(!r.rendered.hasOwnProperty(s)){var u=i(e(n),{type:"rule",className:s,id:t,props:n,rule:e},r.plugins),c=o(u,r.base[t]);r.rendered[s]=!1,Object.keys(c).length>0&&r._renderStyle(s,c),s===a+t&&(r.base[t]=c)}var f=a+t;return r.rendered[s]?(r.callStack.push(r.renderRule.bind(r,e,n)),s!==f?(r.rendered[f]?f+" ":"")+s:s):r.rendered[f]?f:""},renderKeyframe:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r.ids.indexOf(e)<0&&r.ids.push(e);var t=h(n),o=r.prettySelectors&&e.name?e.name+"_":"k",a=o+r.ids.indexOf(e)+t;if(!r.rendered.hasOwnProperty(a)){var u=i(e(n),{type:"keyframe",keyframe:e,props:n,animationName:a,id:r.ids.indexOf(e)},r.plugins),c=s(u,a,r.keyframePrefixes);r.rendered[a]=!0,r.keyframes+=c,r.callStack.push(r.renderKeyframe.bind(r,e,n)),r._emitChange({name:a,style:u,css:c,type:"keyframe"})}return a},renderFont:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e+h(i);return r.rendered.hasOwnProperty(o)||!function(){var s={fontFamily:"'"+e+"'",src:n.map(function(e){return"url('"+e+"') format('"+t(e)+"')"}).join(",")},u=["fontVariant","fontWeight","fontStretch","fontStyle","unicodeRange"];Object.keys(i).filter(function(e){return u.indexOf(e)>-1}).forEach(function(e){return s[e]=i[e]});var c="@font-face{"+a(s)+"}";r.rendered[o]=!0,r.fontFaces+=c,r.callStack.push(r.renderFont.bind(r,e,n,i)),r._emitChange({fontFamily:e,fontFace:s,css:c,type:"font"})}(),e},renderStatic:function(e,t){var o="string"==typeof e?e:t+n(e);if(!r.rendered.hasOwnProperty(o)){if("string"==typeof e){var s=e.replace(/\s{2,}/g,"");r.statics+=s,r._emitChange({selector:t,type:"static",css:s})}else{var u=i(e,{selector:t,type:"static"},r.plugins),c=a(u);r.statics+=t+"{"+c+"}",r.callStack.push(r.renderStatic.bind(r,e,t)),r._emitChange({selector:t,style:u,css:c,type:"rule"})}r.rendered[o]=!0}},renderToString:function(){var e=r.fontFaces+r.statics+r.rules;for(var n in r.mediaRules)e+="@media "+n+"{"+r.mediaRules[n]+"}";return e+r.keyframes},subscribe:function(e){return r.listeners.push(e),{unsubscribe:function(){return r.listeners.splice(r.listeners.indexOf(e),1)}}},rehydrate:function(){var e=r.callStack.slice(0);r.clear(),r._emitChange({type:"rehydrate",done:!1}),e.forEach(function(e){return e()}),r._emitChange({type:"rehydrate",done:!0})},_emitChange:function(e){r.listeners.forEach(function(n){return n(e,r)})},_renderStyle:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=Object.keys(n).reduce(function(o,a){var s=n[a];if(s instanceof Object&&!Array.isArray(s)){if(null!==a.match(/^(:|\[|>)/))r._renderStyle(e,s,t+a,i);else if("@media"===a.substr(0,6)){var u=a.slice(6).trim(),c=i.length>0?i+" and "+u:u;r._renderStyle(e,s,t,c)}}else o[a]=s;return o},{});if(Object.keys(o).length>0){r.rendered[e]=!0;var s=a(o),u="."+e+t,c=u+"{"+s+"}";i.length>0?(r.mediaRules.hasOwnProperty(i)||(r.mediaRules[i]=""),r.mediaRules[i]+=c):r.rules+=c,r._emitChange({selector:u,style:o,css:s,media:i,type:"rule"})}}};return r.keyframePrefixes.push(""),r.clear(),e.enhancers&&e.enhancers.forEach(function(e){return r=e(r)}),r}function c(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return n.reduce(function(e,r){for(var n in r){var t=r[n];e[n]instanceof Object&&t instanceof Object?e[n]=c({},e[n],t):e[n]=t}return e},e)}function f(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(e){return r.reduce(function(r,n){return c(r,n(e))},{})}}function d(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(e){return function(){return r.reduce(function(e,r){return r(e)},e.apply(void 0,arguments))}}}function l(e,r){var n=0,t=!1,i={updateNode:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("hydrate"===i.type&&(t=!i.done),!t)if("rule"===i.type){var o=i.selector,a=i.css,s=i.media,u=o+"{"+a+"}",c=r.sheet,f=c.cssRules.length;s&&s.length>0?(c.insertRule("@media "+s+"{"+u+"}",f-n),n+=1):c.insertRule(u,0)}else r.textContent=e.renderToString(),n=0}};return i}function y(e,r){if(!r||1!==r.nodeType)throw new Error("You need to specify a valid element node (nodeType = 1) to render into.");r.setAttribute("data-fela-stylesheet","");var n=l(e,r);e.subscribe(n.updateNode);var t=e.renderToString();r.textContent!==t&&(r.textContent=t)}var p={};p.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p.extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e};var h=function(e){return r(n(e))},m={".woff":"woff",".eof":"eof",".ttf":"truetype",".svg":"svg"},v=e(function(e){function r(e){return e.replace(n,"-$&").toLowerCase().replace(t,"-ms-")}var n=/[A-Z]/g,t=/^ms-/;e.exports=r}),g=v&&"object"==typeof v&&"default"in v?v.default:v,b={createRenderer:u,combineRules:f,enhance:d,render:y};return b}); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.Fela=r()}(this,function(){"use strict";function e(e,r){return r={exports:{}},e(r,r.exports),r.exports}function r(e){var r=0,n=0,t=void 0,i=e.length;if(0===i)return"";for(;n<i;++n)t=e.charCodeAt(n),r=(r<<5)-r+t,r|=0;return"-"+r.toString(36)}function n(e){return Object.keys(e).sort().reduce(function(r,n){return r+n+e[n]},"")}function t(e){return Object.keys(m).reduce(function(r,n){return e.indexOf(n)>-1&&(r=m[n]),r},void 0)}function i(e,r,n){return n.reduce(function(e,n){return n(e,r)},e)}function o(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce(function(n,t){var i=e[t];if(i instanceof Object&&!Array.isArray(i)){var a=o(i,r[t]);Object.keys(a).length>0&&(n[t]=a)}else if(void 0!==i&&!r.hasOwnProperty(t)||r[t]!==i){if("string"==typeof i&&i.indexOf("undefined")>-1)return n;n[t]=i}return n},{})}function a(e){return Object.keys(e).reduce(function(r,n){return r.length>0&&(r+=";"),r+=g(n)+":"+e[n]},"")}function s(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[""],t=Object.keys(e).reduce(function(r,n){return r+n+"{"+a(e[n])+"}"},"");return n.reduce(function(e,n){return e+"@"+n+"keyframes "+r+"{"+t+"}"},"")}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={listeners:[],keyframePrefixes:e.keyframePrefixes||["-webkit-","-moz-"],plugins:e.plugins||[],prettySelectors:e.prettySelectors&&!1,clear:function(){r.fontFaces="",r.keyframes="",r.statics="",r.rules="",r.mediaRules={},r.rendered={},r.base={},r.ids=[],r.callStack=[],r._emitChange({type:"clear"})},renderRule:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";r.ids.indexOf(e)<0&&(r.ids.push(e),Object.keys(n).length>0&&r.renderRule(e,{},t));var a=r.ids.indexOf(e),s=r.prettySelectors&&e.name?e.name+"_":"c",u=t+s+a+h(n);if(!r.rendered.hasOwnProperty(u)){var c=i(e(n),{type:"rule",className:u,id:a,props:n,rule:e},r.plugins),f=o(c,r.base[a]);r.rendered[u]=!1,Object.keys(f).length>0&&r._renderStyle(u,f),u===s+a&&(r.base[a]=f)}var d=s+a;return r.rendered[u]?(r.callStack.push(r.renderRule.bind(r,e,n)),u!==d?(r.rendered[d]?d+" ":"")+u:u):r.rendered[d]?d:""},renderKeyframe:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r.ids.indexOf(e)<0&&r.ids.push(e);var t=h(n),o=r.prettySelectors&&e.name?e.name+"_":"k",a=o+r.ids.indexOf(e)+t;if(!r.rendered.hasOwnProperty(a)){var u=i(e(n),{type:"keyframe",keyframe:e,props:n,animationName:a,id:r.ids.indexOf(e)},r.plugins),c=s(u,a,r.keyframePrefixes);r.rendered[a]=!0,r.keyframes+=c,r.callStack.push(r.renderKeyframe.bind(r,e,n)),r._emitChange({name:a,style:u,css:c,type:"keyframe"})}return a},renderFont:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e+h(i);return r.rendered.hasOwnProperty(o)||!function(){var s={fontFamily:"'"+e+"'",src:n.map(function(e){return"url('"+e+"') format('"+t(e)+"')"}).join(",")},u=["fontVariant","fontWeight","fontStretch","fontStyle","unicodeRange"];Object.keys(i).filter(function(e){return u.indexOf(e)>-1}).forEach(function(e){return s[e]=i[e]});var c="@font-face{"+a(s)+"}";r.rendered[o]=!0,r.fontFaces+=c,r.callStack.push(r.renderFont.bind(r,e,n,i)),r._emitChange({fontFamily:e,fontFace:s,css:c,type:"font"})}(),e},renderStatic:function(e,t){var o="string"==typeof e?e:t+n(e);if(!r.rendered.hasOwnProperty(o)){if("string"==typeof e){var s=e.replace(/\s{2,}/g,"");r.statics+=s,r._emitChange({selector:t,type:"static",css:s})}else{var u=i(e,{selector:t,type:"static"},r.plugins),c=a(u);r.statics+=t+"{"+c+"}",r.callStack.push(r.renderStatic.bind(r,e,t)),r._emitChange({selector:t,style:u,css:c,type:"rule"})}r.rendered[o]=!0}},renderToString:function(){var e=r.fontFaces+r.statics+r.rules;for(var n in r.mediaRules)e+="@media "+n+"{"+r.mediaRules[n]+"}";return e+r.keyframes},subscribe:function(e){return r.listeners.push(e),{unsubscribe:function(){return r.listeners.splice(r.listeners.indexOf(e),1)}}},rehydrate:function(){var e=r.callStack.slice(0);r.clear(),r._emitChange({type:"rehydrate",done:!1}),e.forEach(function(e){return e()}),r._emitChange({type:"rehydrate",done:!0})},_emitChange:function(e){r.listeners.forEach(function(n){return n(e,r)})},_renderStyle:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=Object.keys(n).reduce(function(o,a){var s=n[a];if(s instanceof Object&&!Array.isArray(s)){if(null!==a.match(/^(:|\[|>)/))r._renderStyle(e,s,t+a,i);else if("@media"===a.substr(0,6)){var u=a.slice(6).trim(),c=i.length>0?i+" and "+u:u;r._renderStyle(e,s,t,c)}}else o[a]=s;return o},{});if(Object.keys(o).length>0){r.rendered[e]=!0;var s=a(o),u="."+e+t,c=u+"{"+s+"}";i.length>0?(r.mediaRules.hasOwnProperty(i)||(r.mediaRules[i]=""),r.mediaRules[i]+=c):r.rules+=c,r._emitChange({selector:u,style:o,css:s,media:i,type:"rule"})}}};return r.keyframePrefixes.push(""),r.clear(),e.enhancers&&e.enhancers.forEach(function(e){return r=e(r)}),r}function c(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return n.reduce(function(e,r){for(var n in r){var t=r[n];e[n]instanceof Object&&t instanceof Object?e[n]=c({},e[n],t):e[n]=t}return e},e)}function f(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(e){return r.reduce(function(r,n){return c(r,n(e))},{})}}function d(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(e){return function(){return r.reduce(function(e,r){return r(e)},e.apply(void 0,arguments))}}}function l(e,r){var n=0,t=!1,i={updateNode:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("hydrate"===i.type&&(t=!i.done),!t)if("rule"===i.type){var o=i.selector,a=i.css,s=i.media,u=o+"{"+a+"}",c=r.sheet,f=c.cssRules.length;s&&s.length>0?(c.insertRule("@media "+s+"{"+u+"}",f-n),n+=1):c.insertRule(u,0)}else r.textContent=e.renderToString(),n=0}};return i}function y(e,r){if(!r||1!==r.nodeType)throw new Error("You need to specify a valid element node (nodeType = 1) to render into.");r.setAttribute("data-fela-stylesheet","");var n=l(e,r);e.subscribe(n.updateNode);var t=e.renderToString();r.textContent!==t&&(r.textContent=t)}var p={};p.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p.extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e};var h=function(e){return r(n(e))},m={".woff":"woff",".eof":"eof",".ttf":"truetype",".svg":"svg"},v=e(function(e){function r(e){return e.replace(n,"-$&").toLowerCase().replace(t,"-ms-")}var n=/[A-Z]/g,t=/^ms-/;e.exports=r}),g=v&&"object"==typeof v&&"default"in v?v.default:v,b={createRenderer:u,combineRules:f,enhance:d,render:y};return b}); |
@@ -19,3 +19,3 @@ 'use strict'; | ||
return function (props) { | ||
return function combined(props) { | ||
return rules.reduce(function (style, rule) { | ||
@@ -22,0 +22,0 @@ return (0, _assign2.default)(style, rule(props)); |
@@ -86,2 +86,4 @@ 'use strict'; | ||
var _selectorPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
// rendering a rule for the first time | ||
@@ -95,3 +97,3 @@ // will create an ID reference | ||
if (Object.keys(props).length > 0) { | ||
renderer.renderRule(rule, {}); | ||
renderer.renderRule(rule, {}, _selectorPrefix); | ||
} | ||
@@ -104,3 +106,3 @@ } | ||
var classNamePrefix = renderer.prettySelectors && rule.name ? rule.name + '_' : 'c'; | ||
var className = classNamePrefix + ruleId + (0, _generatePropsReference2.default)(props); | ||
var className = _selectorPrefix + classNamePrefix + ruleId + (0, _generatePropsReference2.default)(props); | ||
@@ -107,0 +109,0 @@ // only if the cached rule has not already been rendered |
{ | ||
"name": "fela", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Fast & Dynamic Styling in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
128173
53989
1963