-
-
Notifications
You must be signed in to change notification settings - Fork 32
Feature/add is var meta data #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add is var meta data #83
Conversation
lib/nodes/Func.js
Outdated
lastNode.isColor = colorFunctions.includes(lastNode.name.toLowerCase()); | ||
const lowerName = lastNode.name.toLowerCase(); | ||
lastNode.isColor = colorFunctions.includes(lowerName); | ||
lastNode.isVar = lowerName === 'var'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shellscape So far this is a loose check, ideally it would also check that it's argument is of length 1 and has this pattern: /--.*/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/fixtures/func.js
Outdated
@@ -29,7 +29,8 @@ module.exports = { | |||
'calc(1px + -2vw - 4px)', | |||
'calc(((768px - 100vw) / 2) - 15px)', | |||
'bar(baz(black, 10%), 10%)', | |||
'-webkit-linear-gradient(0)' | |||
'-webkit-linear-gradient(0)', | |||
'var(--foo)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shellscape
The tests for var()
and all color functions above would ideally also check that the related meta property of isVar
or isColor
is set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind, it's all visible within the snapshots
lib/nodes/Func.js
Outdated
const lowerName = lastNode.name.toLowerCase(); | ||
const { nodes } = node; | ||
lastNode.isColor = colorFunctions.includes(lowerName); | ||
lastNode.isVar = lowerName === 'var' && nodes.length === 1 && reVar.test(nodes[0].value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too restrictive, does not allow for default
fallback values to be defined:
<declaration-value>
shall be allowed.
https://developer.mozilla.org/en-US/docs/Web/CSS/var#Values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const lowerName = lastNode.name.toLowerCase(); | ||
const { nodes } = node; | ||
lastNode.isColor = colorFunctions.includes(lowerName); | ||
lastNode.isVar = lowerName === 'var' && nodes.length && reVar.test(nodes[0].value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory no need for custom regex to test for var.
But variable detection could be configured to not include CSS custom properties by { variables: { prefixed: ['\\$'] }}
.
This PR fixes #82 contains:
Breaking Changes?
If yes, please describe the breakage.
Please Describe Your Changes