fela-plugin-extend
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -14,2 +14,17 @@ (function (global, factory) { | ||
babelHelpers.defineProperty = function (obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
}; | ||
babelHelpers.extends = Object.assign || function (target) { | ||
@@ -33,17 +48,21 @@ for (var i = 1; i < arguments.length; i++) { | ||
function assign(base) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
for (var _len = arguments.length, extendingStyles = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
extendingStyles[_key - 1] = arguments[_key]; | ||
} | ||
return args.reduce(function (extend, obj) { | ||
for (var property in obj) { | ||
var value = obj[property]; | ||
if (extend[property] instanceof Object && value instanceof Object) { | ||
extend[property] = assign({}, extend[property], value); | ||
for (var i = 0, len = extendingStyles.length; i < len; ++i) { | ||
var style = extendingStyles[i]; | ||
for (var property in style) { | ||
var value = style[property]; | ||
if (base[property] instanceof Object && value instanceof Object) { | ||
base[property] = assign({}, base[property], value); | ||
} else { | ||
extend[property] = value; | ||
base[property] = value; | ||
} | ||
} | ||
return extend; | ||
}, base); | ||
} | ||
return base; | ||
} | ||
@@ -64,9 +83,10 @@ | ||
function extend(style) { | ||
Object.keys(style).forEach(function (property) { | ||
for (var property in style) { | ||
var value = style[property]; | ||
if (property === 'extend') { | ||
// arrayify to loop each extension to support arrays and single extends | ||
[].concat(value).forEach(function (extension) { | ||
return extendStyle(style, extension); | ||
}); | ||
var extensions = [].concat(value); | ||
for (var i = 0, len = extensions.length; i < len; ++i) { | ||
extendStyle(style, extensions[i]); | ||
} | ||
delete style[property]; | ||
@@ -77,3 +97,3 @@ } else if (value instanceof Object && !Array.isArray(value)) { | ||
} | ||
}); | ||
} | ||
@@ -80,0 +100,0 @@ return style; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.FelaPluginExtend=n()}(this,function(){"use strict";function t(n){for(var e=arguments.length,o=Array(e>1?e-1:0),r=1;r<e;r++)o[r-1]=arguments[r];return o.reduce(function(n,e){for(var o in e){var r=e[o];n[o]instanceof Object&&r instanceof Object?n[o]=t({},n[o],r):n[o]=r}return n},n)}function n(n,o){o.hasOwnProperty("condition")?o.condition&&t(n,e(o.style)):t(n,o)}function e(t){return Object.keys(t).forEach(function(o){var r=t[o];"extend"===o?([].concat(r).forEach(function(e){return n(t,e)}),delete t[o]):r instanceof Object&&!Array.isArray(r)&&(t[o]=e(r))}),t}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o.extends=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t};var r=function(){return e};return r}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.FelaPluginExtend=n()}(this,function(){"use strict";function e(n){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];for(var f=0,i=r.length;f<i;++f){var c=r[f];for(var a in c){var u=c[a];n[a]instanceof Object&&u instanceof Object?n[a]=e({},n[a],u):n[a]=u}}return n}function n(n,r){r.hasOwnProperty("condition")?r.condition&&e(n,t(r.style)):e(n,r)}function t(e){for(var r in e){var o=e[r];if("extend"===r){for(var f=[].concat(o),i=0,c=f.length;i<c;++i)n(e,f[i]);delete e[r]}else o instanceof Object&&!Array.isArray(o)&&(e[r]=t(o))}return e}var r={};r.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},r.defineProperty=function(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e},r.extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};var o=function(){return t};return o}); |
{ | ||
"name": "fela-plugin-extend", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Fela plugin to extend style objects", | ||
@@ -21,4 +21,4 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"fela": "4.0.1" | ||
"fela": "4.1.0" | ||
} | ||
} |
@@ -5,3 +5,3 @@ # fela-plugin-extend | ||
<img alt="npm downloads" src="https://img.shields.io/npm/dm/fela-plugin-extend.svg"> | ||
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-0.54kb-brightgreen.svg"> | ||
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-0.61kb-brightgreen.svg"> | ||
@@ -14,9 +14,9 @@ Allows styles to be extended with other style objects. Supports a condition-based API. | ||
``` | ||
Assuming you are using [npm](https://www.npmjs.com) as your package mananger you can just `npm install`.<br> | ||
Assuming you are using [npm](https://www.npmjs.com) as your package manager you can just `npm install`.<br> | ||
Otherwise we also provide a [UMD](https://github.com/umdjs/umd). You can easily use it via [unpkg](https://unpkg.com/). It registers a `FelaPluginExtend` global. | ||
```HTML | ||
<!-- Fela (Development): Unminified version including all warnings --> | ||
<script src="https://unpkg.com/fela-plugin-extend@4.0.1/dist/fela-plugin-extend.js"></script> | ||
<script src="https://unpkg.com/fela-plugin-extend@4.1.0/dist/fela-plugin-extend.js"></script> | ||
<!-- Fela (Production): Minified version --> | ||
<script src="https://unpkg.com/fela-plugin-extend@4.0.1/dist/fela-plugin-extend.min.js"></script> | ||
<script src="https://unpkg.com/fela-plugin-extend@4.1.0/dist/fela-plugin-extend.min.js"></script> | ||
``` | ||
@@ -23,0 +23,0 @@ |
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
11867
88