Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jss-extend

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jss-extend - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

44

dist/jss-extend.js

@@ -57,8 +57,2 @@ (function webpackUniversalModuleDefinition(root, factory) {

'use strict';
exports.__esModule = true;
exports['default'] = jssExtend;
var toString = Object.prototype.toString;
/**

@@ -70,26 +64,32 @@ * Handle `extend` property.

*/
'use strict';
function jssExtend(rule) {
var currStyle = rule.style;
exports.__esModule = true;
exports['default'] = jssExtend;
if (!currStyle || !currStyle.extend) return;
function jssExtend() {
return function (rule) {
if (!rule.style || !rule.style.extend) return;
var newStyle = {};(function extend(style) {
if (toString.call(style.extend) === '[object Array]') {
for (var i = 0; i < style.extend.length; i++) {
extend(style.extend[i]);
function extend(newStyle, style) {
if (Array.isArray(style.extend)) {
for (var i = 0; i < style.extend.length; i++) {
extend(newStyle, style.extend[i]);
}
} else {
for (var prop in style.extend) {
if (prop === 'extend') extend(newStyle, style.extend.extend);else newStyle[prop] = style.extend[prop];
}
}
} else {
for (var prop in style.extend) {
if (prop === 'extend') extend(style.extend.extend);else newStyle[prop] = style.extend[prop];
// Copy base style.
for (var prop in style) {
if (prop !== 'extend') newStyle[prop] = style[prop];
}
}
// Copy base style.
for (var prop in style) {
if (prop !== 'extend') newStyle[prop] = style[prop];
return newStyle;
}
})(currStyle);
rule.style = newStyle;
rule.style = extend({}, rule.style);
};
}

@@ -96,0 +96,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.jssExtend=t():e.jssExtend=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";function n(e){var t=e.style;if(t&&t.extend){var n={};!function r(e){if("[object Array]"===o.call(e.extend))for(var t=0;t<e.extend.length;t++)r(e.extend[t]);else for(var d in e.extend)"extend"===d?r(e.extend.extend):n[d]=e.extend[d];for(var d in e)"extend"!==d&&(n[d]=e[d])}(t),e.style=n}}t.__esModule=!0,t["default"]=n;var o=Object.prototype.toString;e.exports=t["default"]}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.jssExtend=t():e.jssExtend=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";function n(){return function(e){function t(e,n){if(Array.isArray(n.extend))for(var r=0;r<n.extend.length;r++)t(e,n.extend[r]);else for(var o in n.extend)"extend"===o?t(e,n.extend.extend):e[o]=n.extend[o];for(var o in n)"extend"!==o&&(e[o]=n[o]);return e}e.style&&e.style.extend&&(e.style=t({},e.style))}}t.__esModule=!0,t["default"]=n,e.exports=t["default"]}])});

@@ -0,1 +1,6 @@

## 1.0.0 / 2015-10-19
- support jss 3.0
- now plugin needs to be called like a middleware
## 0.2.0 / 2015-09-21

@@ -2,0 +7,0 @@

@@ -1,7 +0,1 @@

'use strict';
exports.__esModule = true;
exports['default'] = jssExtend;
var toString = Object.prototype.toString;
/**

@@ -13,28 +7,34 @@ * Handle `extend` property.

*/
'use strict';
function jssExtend(rule) {
var currStyle = rule.style;
exports.__esModule = true;
exports['default'] = jssExtend;
if (!currStyle || !currStyle.extend) return;
function jssExtend() {
return function (rule) {
if (!rule.style || !rule.style.extend) return;
var newStyle = {};(function extend(style) {
if (toString.call(style.extend) === '[object Array]') {
for (var i = 0; i < style.extend.length; i++) {
extend(style.extend[i]);
function extend(newStyle, style) {
if (Array.isArray(style.extend)) {
for (var i = 0; i < style.extend.length; i++) {
extend(newStyle, style.extend[i]);
}
} else {
for (var prop in style.extend) {
if (prop === 'extend') extend(newStyle, style.extend.extend);else newStyle[prop] = style.extend[prop];
}
}
} else {
for (var prop in style.extend) {
if (prop === 'extend') extend(style.extend.extend);else newStyle[prop] = style.extend[prop];
// Copy base style.
for (var prop in style) {
if (prop !== 'extend') newStyle[prop] = style[prop];
}
}
// Copy base style.
for (var prop in style) {
if (prop !== 'extend') newStyle[prop] = style[prop];
return newStyle;
}
})(currStyle);
rule.style = newStyle;
rule.style = extend({}, rule.style);
};
}
module.exports = exports['default'];
{
"name": "jss-extend",
"description": "JSS plugin that enables inheritance",
"version": "0.2.0",
"version": "1.0.0",
"author": {

@@ -42,3 +42,3 @@ "name": "Oleg Slobodskoi",

"eslint-plugin-react": "^2.7.0",
"jss": "^2.3.4",
"jss": ">=3.0.0 < 4.0.0",
"opener": "^1.4.1",

@@ -50,4 +50,4 @@ "qunitjs": "1.15.0",

"peerDependencies": {
"jss": "^2.3.4"
"jss": ">=3.0.0 < 4.0.0"
}
}

@@ -19,3 +19,3 @@ ![JSS logo](https://avatars1.githubusercontent.com/u/9503099?v=3&s=60)

jss.use(extend)
jss.use(extend())

@@ -26,3 +26,3 @@ const redContainer = {

const styleSheet = jss.createStyleSheet({
let sheet = jss.createStyleSheet({
container: {

@@ -40,3 +40,3 @@ extend: redContainer, // Can be an array of styles

// ES7
const styleSheet = jss.createStyleSheet({
let sheet = jss.createStyleSheet({
container: {

@@ -49,3 +49,3 @@ ...redContainer,

// ES6
const styleSheet = jss.createStyleSheet({
let sheet = jss.createStyleSheet({
container: Object.assign({}, redContainer, {

@@ -55,15 +55,6 @@ 'font-size': '20px'

})
// Or with a helper
import xtend from 'xtend' // Does not mutate arguments
const styleSheet = jss.createStyleSheet({
container: xtend(redContainer, {
'font-size': '20px'
})
})
```
```javascript
console.log(styleSheet.toString())
console.log(sheet.toString())
```

@@ -78,9 +69,8 @@ ```css

```javascript
console.log(styleSheet.classes)
console.log(sheet.classes)
```
```javascript
{ container: "jss-0-0" }
{ container: 'jss-0-0" }
```
## Run tests

@@ -93,5 +83,4 @@

## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc