Skip to content
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: properly handle arbitrary var names with dashed digits #176

Merged
merged 3 commits into from
Apr 20, 2021

Conversation

sibbng
Copy link
Contributor

@sibbng sibbng commented Apr 17, 2021

For some reason w-[calc(100%/3-1rem*2)] test fails.

But when I run that on browser console it gives me expected result.
"w-[calc(100%/3-1rem*2)]".replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*]))(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ')

I really would like to learn why it fails.

@sastan
Copy link
Collaborator

sastan commented Apr 17, 2021

I do not know. I tried a different regexp ((var\(--[^)]+?\)|-?\d*\.?\d(?:%|[a-z]+)?|\))([+\-/*])) but than the test for var with calc fallback fails.

As I understand these tests: they are for variables that start with --<number>. Is this really an issue?

@sibbng
Copy link
Contributor Author

sibbng commented Apr 17, 2021

As I understand these tests: they are for variables that start with --<number>. Is this really an issue?

Yes

@sibbng
Copy link
Contributor Author

sibbng commented Apr 17, 2021

As I understand these tests: they are for variables that start with --<number>. Is this really an issue?

Yes

To clarify actual issue is --<number>-<number>

@sibbng
Copy link
Contributor Author

sibbng commented Apr 18, 2021

@sastan I fixed the issue on latest commit.

At first try I wasn't aware of that square brackets are getting removed in handleArbitraryValues. My regex were only working if that key wrapped with square brackets. Actually at least one more character at the end of string was fix that regex.

calc(100%/3-1rem*2) => calc(100% / 3-1rem * 2)] ❌
calc(100%/3-1rem*2)] => calc(100% / 3 - 1rem * 2)] ✅

Anyway I fixed issue by modifying the regex slightly. Probably it could be more simplified.

Looks like CI failing because of size limits right now.

@sastan
Copy link
Collaborator

sastan commented Apr 20, 2021

Great! Awesome job.

@sastan
Copy link
Collaborator

sastan commented Apr 20, 2021

Regarding the failed size report could you increase the size limit to 12.1 and then we can get this merged.

@sibbng
Copy link
Contributor Author

sibbng commented Apr 20, 2021

Great! Awesome job.

Thanks 🤗

Regarding the failed size report could you increase the size limit to 12.1 and then we can get this merged.

Done 👍

@sastan sastan merged commit 20239b0 into tw-in-js:main Apr 20, 2021
@sastan
Copy link
Collaborator

sastan commented Apr 20, 2021

I'll create a release soon within the next day.

@sibbng sibbng deleted the fix-digit-var-names branch April 20, 2021 20:56
@sastan
Copy link
Collaborator

sastan commented Apr 21, 2021

There you go: v0.16.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants