postcss-value-parser
Advanced tools
Comparing version 3.3.1 to 4.0.0
@@ -10,2 +10,6 @@ var openParentheses = "(".charCodeAt(0); | ||
var star = "*".charCodeAt(0); | ||
var uLower = "u".charCodeAt(0); | ||
var uUpper = "U".charCodeAt(0); | ||
var plus = "+".charCodeAt(0); | ||
var isUnicodeRange = /^[a-f0-9?-]+$/i; | ||
@@ -16,3 +20,10 @@ module.exports = function(input) { | ||
var next, quote, prev, token, escape, escapePos, whitespacePos; | ||
var next, | ||
quote, | ||
prev, | ||
token, | ||
escape, | ||
escapePos, | ||
whitespacePos, | ||
parenthesesOpenPos; | ||
var pos = 0; | ||
@@ -109,2 +120,18 @@ var code = value.charCodeAt(pos); | ||
// Operation within calc | ||
} else if ( | ||
(code === slash || code === star) && | ||
parent && | ||
parent.type === "function" && | ||
parent.value === "calc" | ||
) { | ||
token = value[pos]; | ||
tokens.push({ | ||
type: "word", | ||
sourceIndex: pos - before.length, | ||
value: token | ||
}); | ||
pos += 1; | ||
code = value.charCodeAt(pos); | ||
// Dividers | ||
@@ -134,2 +161,3 @@ } else if (code === slash || code === comma || code === colon) { | ||
} while (code <= 32); | ||
parenthesesOpenPos = pos; | ||
token = { | ||
@@ -139,3 +167,3 @@ type: "function", | ||
value: name, | ||
before: value.slice(pos + 1, next) | ||
before: value.slice(parenthesesOpenPos + 1, next) | ||
}; | ||
@@ -167,23 +195,28 @@ pos = next; | ||
} while (code <= 32); | ||
if (pos !== whitespacePos + 1) { | ||
token.nodes = [ | ||
{ | ||
type: "word", | ||
sourceIndex: pos, | ||
value: value.slice(pos, whitespacePos + 1) | ||
} | ||
]; | ||
if (parenthesesOpenPos < whitespacePos) { | ||
if (pos !== whitespacePos + 1) { | ||
token.nodes = [ | ||
{ | ||
type: "word", | ||
sourceIndex: pos, | ||
value: value.slice(pos, whitespacePos + 1) | ||
} | ||
]; | ||
} else { | ||
token.nodes = []; | ||
} | ||
if (token.unclosed && whitespacePos + 1 !== next) { | ||
token.after = ""; | ||
token.nodes.push({ | ||
type: "space", | ||
sourceIndex: whitespacePos + 1, | ||
value: value.slice(whitespacePos + 1, next) | ||
}); | ||
} else { | ||
token.after = value.slice(whitespacePos + 1, next); | ||
} | ||
} else { | ||
token.after = ""; | ||
token.nodes = []; | ||
} | ||
if (token.unclosed && whitespacePos + 1 !== next) { | ||
token.after = ""; | ||
token.nodes.push({ | ||
type: "space", | ||
sourceIndex: whitespacePos + 1, | ||
value: value.slice(whitespacePos + 1, next) | ||
}); | ||
} else { | ||
token.after = value.slice(whitespacePos + 1, next); | ||
} | ||
pos = next + 1; | ||
@@ -233,2 +266,9 @@ code = value.charCodeAt(pos); | ||
code === openParentheses || | ||
(code === star && | ||
parent && | ||
parent.type === "function" && | ||
parent.value === "calc") || | ||
(code === slash && | ||
parent.type === "function" && | ||
parent.value === "calc") || | ||
(code === closeParentheses && balanced) | ||
@@ -241,2 +281,12 @@ ) | ||
name = token; | ||
} else if ( | ||
(uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) && | ||
plus === token.charCodeAt(1) && | ||
isUnicodeRange.test(token.slice(2)) | ||
) { | ||
tokens.push({ | ||
type: "unicode-range", | ||
sourceIndex: pos, | ||
value: token | ||
}); | ||
} else { | ||
@@ -243,0 +293,0 @@ tokens.push({ |
@@ -21,3 +21,3 @@ var minus = "-".charCodeAt(0); | ||
} else if (code === exp || code === EXP) { | ||
if (sciPos > -1) { | ||
if (sciPos > -1 || pos === 0) { | ||
break; | ||
@@ -24,0 +24,0 @@ } |
{ | ||
"name": "postcss-value-parser", | ||
"version": "3.3.1", | ||
"version": "4.0.0", | ||
"description": "Transforms css values and at-rule params into the tree", | ||
@@ -10,8 +10,8 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"eslint": "^5.6.1", | ||
"husky": "^1.0.0", | ||
"lint-staged": "^7.3.0", | ||
"prettier": "^1.4.4", | ||
"eslint": "^5.16.0", | ||
"husky": "^2.3.0", | ||
"lint-staged": "^8.1.7", | ||
"prettier": "^1.17.1", | ||
"tap-spec": "^5.0.0", | ||
"tape": "^4.2.0" | ||
"tape": "^4.10.2" | ||
}, | ||
@@ -18,0 +18,0 @@ "scripts": { |
@@ -186,2 +186,12 @@ # postcss-value-parser | ||
### unicode-range | ||
The unicode-range CSS descriptor sets the specific range of characters to be | ||
used from a font defined by @font-face and made available | ||
for use on the current page (`unicode-range: U+0025-00FF`). | ||
Node-specific properties: | ||
- **value**: The "unicode-range" itself. | ||
## API | ||
@@ -188,0 +198,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20716
403
264
0