postcss-values-parser
Advanced tools
Comparing version
@@ -83,2 +83,3 @@ /* | ||
} | ||
opts.parentNode = node; | ||
// use a new parser to parse the params of the function. recursion here makes for easier maint | ||
@@ -85,0 +86,0 @@ // we must require this here due to circular dependency resolution |
@@ -12,2 +12,3 @@ /* | ||
const colors = require('color-name'); | ||
const isUrl = require('is-url-superb'); | ||
const Node = require('postcss/lib/node'); | ||
@@ -28,2 +29,3 @@ | ||
this.isHex = false; | ||
this.isUrl = false; | ||
this.isVariable = false; | ||
@@ -36,4 +38,6 @@ } | ||
const { lastNode } = parser; | ||
lastNode.isHex = hexRegex.test(lastNode.value); | ||
lastNode.isColor = colorRegex.test(lastNode.value) || colorNames.includes(lastNode.value); | ||
const { value } = lastNode; | ||
lastNode.isColor = colorRegex.test(value) || colorNames.includes(value); | ||
lastNode.isHex = hexRegex.test(value); | ||
lastNode.isUrl = isUrl(value); | ||
lastNode.isVariable = Word.testVariable(tokens[0], parser); | ||
@@ -40,0 +44,0 @@ } |
@@ -28,2 +28,3 @@ /* | ||
interpolation: false, | ||
parentNode: null, | ||
variables: { | ||
@@ -40,2 +41,3 @@ prefixes: ['--'] | ||
this.options = Object.assign({}, defaults, opts); | ||
this.parentNode = this.options.parentNode; | ||
} | ||
@@ -168,3 +170,10 @@ | ||
} else if (Comment.testInline(first)) { | ||
Comment.tokenizeInline(tokens, this); | ||
// catch protocol-relative urls in a url() function | ||
// https://github.com/shellscape/postcss-values-parser/issues/65 | ||
const { parentNode } = this; | ||
if (parentNode && parentNode.type === 'func' && parentNode.name === 'url') { | ||
Word.fromTokens(tokens, this); | ||
} else { | ||
Comment.tokenizeInline(tokens, this); | ||
} | ||
} else if (value.includes(',')) { | ||
@@ -171,0 +180,0 @@ Punctuation.tokenizeCommas(tokens, this); |
{ | ||
"name": "postcss-values-parser", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"publishConfig": { | ||
@@ -41,2 +41,3 @@ "tag": "next" | ||
"is-number": "^7.0.0", | ||
"is-url-superb": "^2.0.0", | ||
"postcss": "^7.0.5", | ||
@@ -43,0 +44,0 @@ "url-regex": "^4.1.1" |
51065
1.1%880
1.62%5
25%+ Added
+ Added
+ Added