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
Fix regex in resolve-value.js to allow nested CSS functions #97
Conversation
This fix will make work, when using nested CSS functions in the same declaration. See #96
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.
Thanks for taking a look at this!
Needs some new test cases and pass existing tests
First, thank you @MadLittleMods for the opportunity to let me help with this small fix 😄 My Scenario: Previously, I just did a hotfix, without testing it properly, because deadline was short. Due IE11 browser, we had to convert every My new merge proposal: I decided to change my approach, and improved the In addition, I had to change your approach on how replace results. I added a To finish, I just updated Please check if my logic makes sense to you and if you can imagine any extra scenario to test. Cheers from Brazil 🇧🇷 |
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.
A lot of change in the diff because of the new indentation. If there were any changes inside, please point them out with some comments
…iables with CSS functions) and added few more tests.
…, using match-recursive libr .editorconfig removed
@MadLittleMods I made more code changes, just to adapt your logic in some special scenarios. I was facing issues with I spent a good time trying to create a good regex to help, but due the fact JS The I added more related tests and worked ok. Could you take a look and make some tests? I believe this is a good candidate to merge 🤓 Cheers! |
package.json preinstall instruction added, to avoid npm not installing required package dependencies.
…more tests added for css nested functions.
@MadLittleMods I did code changes again, please review. I think we are in the right track :) Now, it will use a In addition, I added one more test for css nested functions. It should be all covered now. Cheers! |
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.
Thanks for the changes and extra tests for our confidence. Some new review points to address
This reverts commit 9088a86.
@MadLittleMods Another code review round done. Please check. |
@MadLittleMods any updates? |
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.
Sorry for the delay. Here is the latest
Thanks everyone for your hard work on this – I've been watching this bit of the HiQ framework --radio-border-width: var(--hiq-radio-border-width, 1px) solid var(--hiq-radio-border-color, transparent);
--radio-border-color: var(--hiq-radio-border-color, transparent);
border: var(--radio-border-width) solid var(--radio-border-color); get compiled to: border: 1px) solid var(--hiq-radio-border-color, transparent solid transparent; and had no clue why. If it was defeated by regex, that'd make sense ... |
@MadLittleMods Done with the requested changes. Could you take a look? :) @colinhowells You are right, it was defeated by regex. The intend of my proposal is to fix when some complex |
lib/resolve-value.js
Outdated
@@ -27,26 +29,61 @@ function toString(value) { | |||
var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal debugging*/_debugIsInternal) { | |||
var debugIndent = _debugIsInternal ? '\t' : ''; | |||
|
|||
var matchingVarDecl = undefined; | |||
var RE_VAR_FUNC_G = new RegExp(RE_VAR_FUNC.source, 'g'); |
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.
We can get rid of RE_VAR_FUNC_G
and RE_VAR_FUNC
now
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.
RE_VAR_FUNC_G
was removed.
But, It seems we can't remove RE_VAR_FUNC
, since it is being called in index.js
.
postcss-css-variables/index.js
Lines 216 to 227 in 5695b77
var doesRuleUseVariables = rule.nodes.some(function(node) { | |
if(node.type === 'decl') { | |
var decl = node; | |
// If it uses variables | |
// and is not a variable declarations that we may be preserving from earlier | |
if(resolveValue.RE_VAR_FUNC.test(decl.value) && !RE_VAR_PROP.test(decl.prop)) { | |
return true; | |
} | |
} | |
return false; | |
}); |
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.
Looking good, just a few remaining points 👍
@MadLittleMods I did some of your requests, could you review again? Also, check my comment #97 (diff) |
@MadLittleMods any news? |
@MadLittleMods sorry to bump this PR, but could you take a look in the latest changes sent? |
I've left this for a while. Just feeling the effects of going back and fourth with things not actually changing or being quite finished. I only spotted one thing and the tests are passing so we can merge after that 😥 |
No worries @MadLittleMods I just did the request change. Feel free to to approve ;) |
Thanks for the quick update @juliovedovatto ❤️ This is now part of |
This fix will make work, when using nested CSS functions in the same declaration.
See #96