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

postcss-value-parser

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-value-parser - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

11

lib/parser.js

@@ -25,3 +25,4 @@ var tokenize = require('./tokenize');

function walk(nodes, name, cb, reverse) {
var i, max, node;
var i, max, node, result, type;
for(i = 0, max = nodes.length; i < max; i += 1) {

@@ -31,6 +32,10 @@ node = nodes[i];

if(!reverse) {
cb(node, i, nodes);
result = cb(node, i, nodes);
}
if(node.nodes) {
type = node.type;
if(result !== false && node.nodes && type !== 'string' &&
type !== 'space' &&
type !== 'word' &&
type !== 'div') {
walk(node.nodes, name, cb, reverse);

@@ -37,0 +42,0 @@ }

function stringifyNode(node) {
if(Array.isArray(node.nodes)) {
if(node.type === 'function') {
var type = node.type;
if(type === 'word' || type === 'space') {
return node.value;
} else if(type === 'string') {
return (node.quote || '') + node.value + (node.quote || '');
} else if(type === 'div') {
return (node.before || '') + node.value + (node.after || '');
} else if(Array.isArray(node.nodes)) {
if(type === 'function') {
return node.value + '(' + stringify(node.nodes) + ')';

@@ -8,6 +16,2 @@ } else {

}
} else if(node.type === 'string') {
return (node.quote || '') + node.value + (node.quote || '');
} else if(node.type === 'div') {
return (node.before || '') + node.value + (node.after || '');
} else {

@@ -14,0 +18,0 @@ return node.value;

@@ -123,8 +123,8 @@ 'use strict';

code = value.charCodeAt(next + 1);
if(escape && (code !== slash &&
code !== space &&
code !== newline &&
code !== tab &&
code !== cr &&
code !== feed)) {
if(escape && code !== slash &&
code !== space &&
code !== newline &&
code !== tab &&
code !== cr &&
code !== feed) {
next += 1;

@@ -131,0 +131,0 @@ }

{
"name": "postcss-value-parser",
"version": "1.1.0",
"version": "1.2.0",
"description": "Transforms css values into the tree",

@@ -5,0 +5,0 @@ "main": "lib/parser.js",

@@ -39,2 +39,16 @@ [![Travis CI](https://travis-ci.org/TrySound/postcss-value-parser.svg)](https://travis-ci.org/TrySound/postcss-value-parser)

### Prevent walking into function
```js
parser('url(some url) 50% 50%')
.walk(function (node) {
// Your code
if(node.type === 'functon' && node.value === 'url') {
return false;
}
})
.toString();
```
## Node types

@@ -41,0 +55,0 @@

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