Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

rework

Package Overview
Dependencies
20
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.16.0 to 0.17.0

5

component.json
{
"name": "rework",
"version": "0.16.0",
"version": "0.17.0",
"description": "CSS manipulations built on CSSOM",
"keywords": ["css", "manipulation", "preprocess", "transform"],
"dependencies": {
"visionmedia/css": "1.3.0",
"visionmedia/css": "1.4.0",
"visionmedia/debug": "*",
"visionmedia/rework-visit": "1.0.0",
"component/color-parser": "0.1.0",

@@ -10,0 +11,0 @@ "component/path": "1.0.0",

0.17.0 / 2013-06-18
==================
* add this == Rework to mixin functions. Closes #101
* update css
* remove .vars() plugin. Closes #77
* move visitor into rework-visit
0.16.0 / 2013-06-12

@@ -3,0 +11,0 @@ ==================

7

lib/plugins/mixin.js

@@ -17,3 +17,3 @@

visit.declarations(style, function(declarations){
mixin(declarations, mixins);
mixin(rework, declarations, mixins);
});

@@ -26,2 +26,3 @@ }

*
* @param {Rework} rework
* @param {Array} declarations

@@ -32,3 +33,3 @@ * @param {Object} mixins

function mixin(declarations, mixins) {
function mixin(rework, declarations, mixins) {
for (var i = 0; i < declarations.length; ++i) {

@@ -44,3 +45,3 @@ var decl = declarations[i];

// invoke mixin
var ret = fn(val);
var ret = fn.call(rework, val);

@@ -47,0 +48,0 @@ // apply properties

/**
* Module dependencies.
*/
var visit = require('../visit');
/**
* Add variable support.
*
* :root {
* var-header-color: #06c;
* }
*
* h1 {
* background-color: var(header-color);
* }
*
* yields:
*
* h1 {
* background-color: #06c;
* }
*
*/
module.exports = function(map) {
map = map || {};
function replace(str) {
return str.replace(/\bvar\((.*?)\)/g, function(_, name){
var val = map[name];
if (!val) throw new Error('variable "' + name + '" is undefined');
if (val.match(/\bvar\(/)) val = replace(val);
return val;
});
}
return function vars(style){
visit.declarations(style, function(declarations, node){
// map vars
declarations.forEach(function(decl){
if (0 != decl.property.indexOf('var-')) return;
var name = decl.property.replace('var-', '');
map[name] = decl.value;
});
// substitute values
declarations.forEach(function(decl){
if (!decl.value.match(/\bvar\(/)) return;
decl.value = replace(decl.value);
});
});
}
module.exports = function(){
console.warn('Warning: vars() has been removed, please use: https://github.com/visionmedia/rework-vars');
return function(){}
};
/**
* Visit `node`'s declarations recursively and
* invoke `fn(declarations, node)`.
*
* @param {Object} node
* @param {Function} fn
* @api private
*/
exports.declarations = function(node, fn){
node.rules.forEach(function(rule){
// @media etc
if (rule.rules) {
exports.declarations(rule, fn);
return;
}
// keyframes
if (rule.keyframes) {
rule.keyframes.forEach(function(keyframe){
fn(keyframe.declarations, rule);
});
return;
}
// @charset, @import etc
if (!rule.declarations) return;
fn(rule.declarations, node);
});
};
// TODO: require() directly in plugins...
exports.declarations = require('rework-visit');
{
"name": "rework",
"version": "0.16.0",
"version": "0.17.0",
"description": "CSS manipulations built on CSSOM",

@@ -12,3 +12,3 @@ "keywords": ["css", "manipulation", "preprocess", "transform"],

"dependencies": {
"css": "1.3.1",
"css": "1.4.0",
"commander": "1.0.4",

@@ -18,3 +18,4 @@ "color-parser": "0.1.0",

"debug": "*",
"rework-inherit": "0.1.5"
"rework-inherit": "0.1.5",
"rework-visit": "1.0.0"
},

@@ -21,0 +22,0 @@ "devDependencies": {

@@ -70,5 +70,4 @@ # rework

- [references](#references) — add property references support `height: @width` etc
- [vars](#varsobject) — add css variable support
- third-party [plugins](https://github.com/visionmedia/rework/wiki/Plugins)
### .extend()

@@ -96,3 +95,3 @@

a.button
a.button,
input[type='submit'],

@@ -172,2 +171,5 @@ input[type='button'] {

This plugin is stored in its own repo at [jonathanong/rework-inherit](https://github.com/jonathanong/rework-inherit).
Please delegate any issues with `.extend()` to that repository instead of rework.
### .ease()

@@ -355,2 +357,5 @@

The receiver (`this`) is the `Rework` instance, allowing the mixin to reference
properties such as the vendor `.prefixes` array.
```js

@@ -491,48 +496,2 @@ var css = rework(css)

### .vars([object])
Add variable support. Note that this does not cascade like the CSS variable
spec does, thus this is _not_ some sort of fallback mechanism, just a useful
feature. Optionally you may pass an `object` of variables from js-land.
```css
:root {
var-header-color: #06c;
var-main-color: #c06;
}
div {
var-accent-background: linear-gradient(to top, var(main-color), white);
}
h1 {
background-color: var(header-color);
}
.content {
background: var(accent-background) !important;
}
```
yields:
```css
:root {
var-header-color: #06c;
var-main-color: #c06
}
div {
var-accent-background: linear-gradient(to top, #c06, white)
}
h1 {
background-color: #06c
}
.content {
background: linear-gradient(to top, #c06, white) !important
}
```
### .colors()

@@ -539,0 +498,0 @@

@@ -8,4 +8,38 @@

function displayFlex(val) {
if ('flex' == val) {
return {
display: [
'-webkit-flex',
'-moz-flex',
'flex'
]
}
}
return {
display: val
}
}
function displayInlineFlex(val) {
if ('inline-flex' == val) {
return {
display: [
'-webkit-inline-flex',
'-moz-inline-flex',
'inline-flex'
]
}
}
return {
display: val
}
}
str = rework(str)
.use(rework.prefixSelector(''))
// .use(rework.prefixSelector(''))
.use(rework.mixin({ display: displayFlex }))
.use(rework.mixin({ display: displayInlineFlex }))
.toString();

@@ -12,0 +46,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc