Skip to content

Commit

Permalink
update postcss-values-parser to 3.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman committed Jul 2, 2019
1 parent 62ec70a commit 83a60e8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -68,7 +68,7 @@
"is-vendor-prefixed": "^3.3.0",
"path": "^0.12.7",
"postcss": "^7.0.17",
"postcss-values-parser": "^3.0.4",
"postcss-values-parser": "^3.0.5",
"specificity": "^0.4.1",
"split-lines": "^2.0.0",
"string-natural-compare": "^2.0.3",
Expand Down
15 changes: 13 additions & 2 deletions src/analyzer/values/colors.js
Expand Up @@ -7,14 +7,25 @@ const uniquer = require('../../utils/uniquer')
function extractColorsFromDeclaration(declaration) {
const colors = []

// Temporary try-catch until https://github.com/shellscape/postcss-values-parser/issues/76 is fixed
// Try-catch to ignore values that cannot be parsed with postcss-values-parser
// Examples:
// - Base64-encoded images
// - startColorstr=\'#5243AA\', endColorstr=\'#0079bf\', GradientType=1
// - opacity=50
// - 1.5deg
try {
parse(declaration.value, {loose: true}).walk(node => {
if (node.isColor) {
return colors.push(node)
}
})
} catch (error) {}
} catch (error) {
console.error(
`Ignoring this value: ${error.input.source} because: *${
error.input.reason
}*`
)
}

if (colors.length > 0) {
declaration.colors = colors.map(color => color.toString().trim())
Expand Down

0 comments on commit 83a60e8

Please sign in to comment.