-
Notifications
You must be signed in to change notification settings - Fork 62
Fix regex in resolve-value.js to allow nested CSS functions #97
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
adcc69c
fixed regex in resolve-value.js
juliovedovatto 398a88e
package.json version bump
juliovedovatto 6ce15de
undo version bump
juliovedovatto dff2e3a
Fixed a problem with var() declarations in nested functions
juliovedovatto bd81a6f
small code improvement to map css variables correctly (for nested var…
juliovedovatto bf638e1
.editorconfig added, to fix indentation problems (tab vs spaces)
juliovedovatto cd5c5dc
Code improviments to match var() declarations in nested CSS functions…
juliovedovatto 9088a86
Update package.json
juliovedovatto f3b8ea5
Code improvements: changed regex match library to balanced-match and …
juliovedovatto 5f51a60
Merge branch 'master' of https://github.com/Konnng/postcss-css-variables
juliovedovatto ba6e178
Revert "Update package.json"
juliovedovatto 94eb0aa
Code refactor, to make lib more robust and compatible with older node…
juliovedovatto 45ffc6c
more use-case tests added
juliovedovatto 5a75deb
Comment capitalization, to match the rest of the comments
juliovedovatto b3b3fb0
Changed match strategy for variables names, to make better use of bal…
juliovedovatto ca24d60
Small changes and code cleanup
juliovedovatto eb8adbe
Unused method removed
juliovedovatto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/fixtures/nested-inside-calc-func-with-fallback-var.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| :root { | ||
| --some-width: 150px; | ||
| --some-other-width: 50px; | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - var(--missing, var(--some-width, 100px))); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - var(--missing, var(--missing2, 100px))); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - var(--missing, var(--missing2, var(--some-other-width)))); | ||
| } |
11 changes: 11 additions & 0 deletions
11
test/fixtures/nested-inside-calc-func-with-fallback-var.expected.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| .box-foo { | ||
| width: calc(58.3333333333% - 150px); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - 100px); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - 50px); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| :root { | ||
| --some-width: 150px; | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - var(--some-width, 100px)); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - var(--missing, 100px)); | ||
| } |
7 changes: 7 additions & 0 deletions
7
test/fixtures/nested-inside-calc-func-with-fallback.expected.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .box-foo { | ||
| width: calc(58.3333333333% - 150px); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(58.3333333333% - 100px); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| :root { | ||
| --some-width: 150px; | ||
| --some-other-width: 50px; | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(1000% - var(--some-width)); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(1000% - var(--missing-width)); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(var(--some-width) - var(--some-other-width)); | ||
| } | ||
|
|
||
| .box-foo { | ||
| --widthA: 100px; | ||
| --widthB: calc(var(--widthA) / 2); | ||
| --widthC: calc(var(--widthB) / 2); | ||
| width: var(--widthC); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .box-foo { | ||
| width: calc(1000% - 150px); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: undefined; | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(150px - 50px); | ||
| } | ||
|
|
||
| .box-foo { | ||
| width: calc(calc(100px / 2) / 2); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| :root { | ||
| --some-color: red; | ||
| } | ||
| .box-foo { | ||
| background-color: color(var(--missing, white)); | ||
| } | ||
| .box-foo { | ||
| background-color: color(var(--some-color, white)); | ||
| } |
6 changes: 6 additions & 0 deletions
6
test/fixtures/nested-inside-other-func-with-fallback.expected.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .box-foo { | ||
| background-color: color(white); | ||
| } | ||
| .box-foo { | ||
| background-color: color(red); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| :root { | ||
| --some-color: red; | ||
| --some-opacity: 0.3; | ||
| } | ||
|
|
||
| .box-foo { | ||
| background-color: color(var(--some-color)); | ||
| } | ||
|
|
||
| .box-foo { | ||
| background-color: color(var(--some-color, white)); | ||
| background-color: rgba(255, 0, 0, var(--some-opacity)); | ||
| } | ||
juliovedovatto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .box-foo { | ||
| background-color: hsla(120,100%,50%, var(--missing-opacity)); | ||
| } | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| .box-foo { | ||
| background-color: color(white); | ||
| background-color: color(red); | ||
| } | ||
|
|
||
| .box-foo { | ||
| background-color: rgba(255, 0, 0, 0.3); | ||
| } | ||
|
|
||
| .box-foo { | ||
| background-color: undefined; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.