Comparing version 4.0.0 to 4.0.1
@@ -318,3 +318,3 @@ (function (global, factory) { | ||
renderer.ids = []; | ||
renderer.baseClassName = []; | ||
renderer.baseClassName = {}; | ||
renderer.callStack = []; | ||
@@ -353,4 +353,2 @@ | ||
var ruleId = renderer.ids.indexOf(rule); | ||
var ruleProps = babelHelpers.extends({}, defaultProps, props); | ||
@@ -380,2 +378,4 @@ | ||
var ruleId = renderer.ids.indexOf(rule); | ||
// diff style objects with base styles | ||
@@ -396,6 +396,8 @@ var diffedStyle = diffStyle(processedStyle, renderer.base[ruleId]); | ||
return renderer.rendered[className] ? className : ''; | ||
} else { | ||
renderer.baseClassName[styleId] = renderer.baseClassName[ruleId]; | ||
} | ||
} | ||
var baseClassName = renderer.baseClassName[ruleId]; | ||
var baseClassName = renderer.baseClassName[styleId]; | ||
@@ -402,0 +404,0 @@ // if current className is empty |
@@ -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,t=0,n=void 0,o=e.length;if(0===o)return"";for(;t<o;++t)n=e.charCodeAt(t),r=(r<<5)-r+n,r|=0;return"-"+r.toString(36)}function t(e){return Object.keys(h).reduce(function(r,t){return e.indexOf(t)>-1&&(r=h[t]),r},void 0)}function n(e,r,t){return t.reduce(function(e,t){return t(e,r)},e)}function o(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce(function(t,n){var i=e[n];if(i instanceof Object&&!Array.isArray(i)){var a=o(i,r[n]);Object.keys(a).length>0&&(t[n]=a)}else if(void 0!==i&&r[n]!==i){if("string"==typeof i&&i.indexOf("undefined")>-1)return t;t[n]=i}return t},{})}function i(e){return Object.keys(e).reduce(function(r,t){return r.length>0&&(r+=";"),r+=v(t)+":"+e[t]},"")}function a(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[""],n=Object.keys(e).reduce(function(r,t){return r+t+"{"+i(e[t])+"}"},"");return t.reduce(function(e,t){return e+"@"+t+"keyframes "+r+"{"+n+"}"},"")}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,mediaQueryOrder:e.mediaQueryOrder||[],clear:function(){r.fontFaces="",r.keyframes="",r.statics="",r.rules="",r.mediaRules=r.mediaQueryOrder.reduce(function(e,r){return e[r]="",e},{}),r.rendered={},r.base=[],r.ids=[],r.baseClassName=[],r.callStack=[],r._emitChange({type:"clear"})},renderRule:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r.ids.indexOf(e)===-1){r.ids.push(e);try{r.renderRule(e,i,i)}catch(e){}}var a=r.ids.indexOf(e),u=y.extends({},i,t),s=e(u),c=r._generateStyleId(s),f="c"+c;if(!r.rendered.hasOwnProperty(f)){var l=n(s,{type:"rule",className:f,props:u,rule:e},r.plugins),d=o(l,r.base[a]);if(r.rendered[f]=!1,Object.keys(d).length>0&&r._renderStyle(f,d),r.callStack.push(r.renderRule.bind(r,e,t,i)),t===i)return r.base[a]=d,r.baseClassName[a]=f,r.rendered[f]?f:""}var p=r.baseClassName[a];return r.rendered[f]?f!==p?(r.rendered[p]?p+" ":"")+f:f:r.rendered[p]?p:""},renderKeyframe:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e(t),i=r._generateStyleId(o),u="k"+i;if(!r.rendered.hasOwnProperty(u)){var s=n(o,{type:"keyframe",keyframe:e,props:t,animationName:u},r.plugins),c=a(s,u,r.keyframePrefixes);r.rendered[u]=!0,r.keyframes+=c,r.callStack.push(r.renderKeyframe.bind(r,e,t)),r._emitChange({name:u,style:s,css:c,type:"keyframe"})}return u},renderFont:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=e+p(o);return r.rendered.hasOwnProperty(a)||!function(){var u={fontFamily:"'"+e+"'",src:n.map(function(e){return"url('"+e+"') format('"+t(e)+"')"}).join(",")},s=["fontVariant","fontWeight","fontStretch","fontStyle","unicodeRange"];Object.keys(o).filter(function(e){return s.indexOf(e)>-1}).forEach(function(e){return u[e]=o[e]});var c="@font-face{"+i(u)+"}";r.rendered[a]=!0,r.fontFaces+=c,r.callStack.push(r.renderFont.bind(r,e,n,o)),r._emitChange({fontFamily:e,fontFace:u,css:c,type:"font"})}(),e},renderStatic:function(e,t){var o="string"==typeof e?e:t+JSON.stringify(e);if(!r.rendered.hasOwnProperty(o)){if("string"==typeof e){var a=e.replace(/\s{2,}/g,"");r.statics+=a,r._emitChange({selector:t,type:"static",css:a})}else{var u=n(e,{selector:t,type:"static"},r.plugins),s=i(u);r.statics+=t+"{"+s+"}",r.callStack.push(r.renderStatic.bind(r,e,t)),r._emitChange({selector:t,style:u,css:s,type:"rule"})}r.rendered[o]=!0}},renderToString:function(){var e=r.fontFaces+r.statics+r.rules;for(var t in r.mediaRules){var n=r.mediaRules[t];n.length>0&&(e+="@media "+t+"{"+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})},_generateStyleId:function(e){var t=p(e);return r.ids.indexOf(t)===-1&&r.ids.push(t),r.ids.indexOf(t).toString(36)},_emitChange:function(e){r.listeners.forEach(function(t){return t(e,r)})},_renderStyle:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=Object.keys(t).reduce(function(i,a){var u=t[a];if(u instanceof Object&&!Array.isArray(u)){if(null!==a.match(/^(:|\[|>)/))r._renderStyle(e,u,n+a,o);else if("@media"===a.substr(0,6)){var s=a.slice(6).trim(),c=o.length>0?o+" and "+s:s;r._renderStyle(e,u,n,c)}}else i[a]=u;return i},{});if(Object.keys(a).length>0){r.rendered[e]=!0;var u=i(a),s="."+e+n,c=s+"{"+u+"}";o.length>0?(r.mediaRules.hasOwnProperty(o)||(r.mediaRules[o]=""),r.mediaRules[o]+=c):r.rules+=c,r._emitChange({selector:s,style:a,css:u,media:o,type:"rule"})}}};return r.keyframePrefixes.push(""),r.clear(),e.enhancers&&e.enhancers.forEach(function(e){return r=e(r)}),r}function s(e){for(var r=arguments.length,t=Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return t.reduce(function(e,r){for(var t in r){var n=r[t];e[t]instanceof Object&&n instanceof Object?e[t]=s({},e[t],n):e[t]=n}return e},e)}function c(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return function(e){return r.reduce(function(r,t){return s(r,t(e))},{})}}function f(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return function(e){return function(){return r.reduce(function(e,r){return r(e)},e.apply(void 0,arguments))}}}function l(e,r){var t=!1,n={updateNode:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("hydrate"===n.type&&(t=!n.done),!t)if("rule"!==n.type||n.media)r.textContent=e.renderToString();else{var o=r.sheet;o.insertRule(n.selector+"{"+n.css+"}",o.cssRules.length)}}};return n}function d(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 t=l(e,r);e.subscribe(t.updateNode);var n=e.renderToString();r.textContent!==n&&(r.textContent=n)}var y={};y.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},y.classCallCheck=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},y.createClass=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),y.extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},y.inherits=function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)},y.objectWithoutProperties=function(e,r){var t={};for(var n in e)r.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},y.possibleConstructorReturn=function(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r},y.toConsumableArray=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)};var p=function(e){return r(JSON.stringify(e))},h={".woff":"woff",".eot":"eot",".ttf":"truetype",".svg":"svg"},m=e(function(e){function r(e){return e in o?o[e]:o[e]=e.replace(t,"-$&").toLowerCase().replace(n,"-ms-")}var t=/[A-Z]/g,n=/^ms-/,o={};e.exports=r}),v=m&&"object"==typeof m&&"default"in m?m.default:m,b={createRenderer:u,combineRules:c,enhance:f,render:d};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,t=0,n=void 0,o=e.length;if(0===o)return"";for(;t<o;++t)n=e.charCodeAt(t),r=(r<<5)-r+n,r|=0;return"-"+r.toString(36)}function t(e){return Object.keys(h).reduce(function(r,t){return e.indexOf(t)>-1&&(r=h[t]),r},void 0)}function n(e,r,t){return t.reduce(function(e,t){return t(e,r)},e)}function o(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce(function(t,n){var i=e[n];if(i instanceof Object&&!Array.isArray(i)){var a=o(i,r[n]);Object.keys(a).length>0&&(t[n]=a)}else if(void 0!==i&&r[n]!==i){if("string"==typeof i&&i.indexOf("undefined")>-1)return t;t[n]=i}return t},{})}function i(e){return Object.keys(e).reduce(function(r,t){return r.length>0&&(r+=";"),r+=v(t)+":"+e[t]},"")}function a(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[""],n=Object.keys(e).reduce(function(r,t){return r+t+"{"+i(e[t])+"}"},"");return t.reduce(function(e,t){return e+"@"+t+"keyframes "+r+"{"+n+"}"},"")}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,mediaQueryOrder:e.mediaQueryOrder||[],clear:function(){r.fontFaces="",r.keyframes="",r.statics="",r.rules="",r.mediaRules=r.mediaQueryOrder.reduce(function(e,r){return e[r]="",e},{}),r.rendered={},r.base=[],r.ids=[],r.baseClassName={},r.callStack=[],r._emitChange({type:"clear"})},renderRule:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r.ids.indexOf(e)===-1){r.ids.push(e);try{r.renderRule(e,i,i)}catch(e){}}var a=y.extends({},i,t),u=e(a),s=r._generateStyleId(u),c="c"+s;if(!r.rendered.hasOwnProperty(c)){var f=n(u,{type:"rule",className:c,props:a,rule:e},r.plugins),l=r.ids.indexOf(e),d=o(f,r.base[l]);if(r.rendered[c]=!1,Object.keys(d).length>0&&r._renderStyle(c,d),r.callStack.push(r.renderRule.bind(r,e,t,i)),t===i)return r.base[l]=d,r.baseClassName[l]=c,r.rendered[c]?c:"";r.baseClassName[s]=r.baseClassName[l]}var p=r.baseClassName[s];return r.rendered[c]?c!==p?(r.rendered[p]?p+" ":"")+c:c:r.rendered[p]?p:""},renderKeyframe:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e(t),i=r._generateStyleId(o),u="k"+i;if(!r.rendered.hasOwnProperty(u)){var s=n(o,{type:"keyframe",keyframe:e,props:t,animationName:u},r.plugins),c=a(s,u,r.keyframePrefixes);r.rendered[u]=!0,r.keyframes+=c,r.callStack.push(r.renderKeyframe.bind(r,e,t)),r._emitChange({name:u,style:s,css:c,type:"keyframe"})}return u},renderFont:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=e+p(o);return r.rendered.hasOwnProperty(a)||!function(){var u={fontFamily:"'"+e+"'",src:n.map(function(e){return"url('"+e+"') format('"+t(e)+"')"}).join(",")},s=["fontVariant","fontWeight","fontStretch","fontStyle","unicodeRange"];Object.keys(o).filter(function(e){return s.indexOf(e)>-1}).forEach(function(e){return u[e]=o[e]});var c="@font-face{"+i(u)+"}";r.rendered[a]=!0,r.fontFaces+=c,r.callStack.push(r.renderFont.bind(r,e,n,o)),r._emitChange({fontFamily:e,fontFace:u,css:c,type:"font"})}(),e},renderStatic:function(e,t){var o="string"==typeof e?e:t+JSON.stringify(e);if(!r.rendered.hasOwnProperty(o)){if("string"==typeof e){var a=e.replace(/\s{2,}/g,"");r.statics+=a,r._emitChange({selector:t,type:"static",css:a})}else{var u=n(e,{selector:t,type:"static"},r.plugins),s=i(u);r.statics+=t+"{"+s+"}",r.callStack.push(r.renderStatic.bind(r,e,t)),r._emitChange({selector:t,style:u,css:s,type:"rule"})}r.rendered[o]=!0}},renderToString:function(){var e=r.fontFaces+r.statics+r.rules;for(var t in r.mediaRules){var n=r.mediaRules[t];n.length>0&&(e+="@media "+t+"{"+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})},_generateStyleId:function(e){var t=p(e);return r.ids.indexOf(t)===-1&&r.ids.push(t),r.ids.indexOf(t).toString(36)},_emitChange:function(e){r.listeners.forEach(function(t){return t(e,r)})},_renderStyle:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=Object.keys(t).reduce(function(i,a){var u=t[a];if(u instanceof Object&&!Array.isArray(u)){if(null!==a.match(/^(:|\[|>)/))r._renderStyle(e,u,n+a,o);else if("@media"===a.substr(0,6)){var s=a.slice(6).trim(),c=o.length>0?o+" and "+s:s;r._renderStyle(e,u,n,c)}}else i[a]=u;return i},{});if(Object.keys(a).length>0){r.rendered[e]=!0;var u=i(a),s="."+e+n,c=s+"{"+u+"}";o.length>0?(r.mediaRules.hasOwnProperty(o)||(r.mediaRules[o]=""),r.mediaRules[o]+=c):r.rules+=c,r._emitChange({selector:s,style:a,css:u,media:o,type:"rule"})}}};return r.keyframePrefixes.push(""),r.clear(),e.enhancers&&e.enhancers.forEach(function(e){return r=e(r)}),r}function s(e){for(var r=arguments.length,t=Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return t.reduce(function(e,r){for(var t in r){var n=r[t];e[t]instanceof Object&&n instanceof Object?e[t]=s({},e[t],n):e[t]=n}return e},e)}function c(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return function(e){return r.reduce(function(r,t){return s(r,t(e))},{})}}function f(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return function(e){return function(){return r.reduce(function(e,r){return r(e)},e.apply(void 0,arguments))}}}function l(e,r){var t=!1,n={updateNode:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("hydrate"===n.type&&(t=!n.done),!t)if("rule"!==n.type||n.media)r.textContent=e.renderToString();else{var o=r.sheet;o.insertRule(n.selector+"{"+n.css+"}",o.cssRules.length)}}};return n}function d(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 t=l(e,r);e.subscribe(t.updateNode);var n=e.renderToString();r.textContent!==n&&(r.textContent=n)}var y={};y.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},y.classCallCheck=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},y.createClass=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),y.extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},y.inherits=function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)},y.objectWithoutProperties=function(e,r){var t={};for(var n in e)r.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},y.possibleConstructorReturn=function(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r},y.toConsumableArray=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)};var p=function(e){return r(JSON.stringify(e))},h={".woff":"woff",".eot":"eot",".ttf":"truetype",".svg":"svg"},m=e(function(e){function r(e){return e in o?o[e]:o[e]=e.replace(t,"-$&").toLowerCase().replace(n,"-ms-")}var t=/[A-Z]/g,n=/^ms-/,o={};e.exports=r}),v=m&&"object"==typeof m&&"default"in m?m.default:m,b={createRenderer:u,combineRules:c,enhance:f,render:d};return b}); |
@@ -78,3 +78,3 @@ 'use strict'; | ||
renderer.ids = []; | ||
renderer.baseClassName = []; | ||
renderer.baseClassName = {}; | ||
renderer.callStack = []; | ||
@@ -113,4 +113,2 @@ | ||
var ruleId = renderer.ids.indexOf(rule); | ||
var ruleProps = _extends({}, defaultProps, props); | ||
@@ -140,2 +138,4 @@ | ||
var ruleId = renderer.ids.indexOf(rule); | ||
// diff style objects with base styles | ||
@@ -156,6 +156,8 @@ var diffedStyle = (0, _diffStyle2.default)(processedStyle, renderer.base[ruleId]); | ||
return renderer.rendered[className] ? className : ''; | ||
} else { | ||
renderer.baseClassName[styleId] = renderer.baseClassName[ruleId]; | ||
} | ||
} | ||
var baseClassName = renderer.baseClassName[ruleId]; | ||
var baseClassName = renderer.baseClassName[styleId]; | ||
@@ -162,0 +164,0 @@ // if current className is empty |
{ | ||
"name": "fela", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"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
147755
2328