postcss-value-parser
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -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 @@ |
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
13006
280
103