-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 a bug: css urls are incorrectly stripped of commas #14476
Merged
fisker
merged 24 commits into
prettier:main
from
seiyab:14237-css-urls-are-incorrectly-stripped-of-commas-2
Mar 29, 2023
+129
−15
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
44ca4fc
test for #14237 "@font-face urls are incorrectly stripped of commas"
seiyab dda6511
fix #14237
seiyab 4a92d92
update snapshot for #14237
seiyab 3f86644
add changelog
seiyab 5e96943
fix typo in changelog
seiyab 3e31769
Update changelog_unreleased/css/14476.md
seiyab 0f60624
add test for broken edge case
seiyab 3dccc3e
fix some edge cases
seiyab 2ca6512
Add edge cases
seiyab 2977c89
add trailing triple backquotes into changelog
seiyab 2fcf543
prevent AST change false positive
seiyab 4d4d2a6
change approach
seiyab dd9158b
Minor refactor
fisker aaf0417
Rename
fisker d76003f
Simplify
fisker 234fe6c
Rename function
fisker 4186594
Test space
fisker b5fa585
More test
fisker aa52707
Rename functions
fisker b7751a8
Fix path
fisker d0b816e
Fix
fisker 3579c7e
Merge remote-tracking branch 'origin/main' into 14237-css-urls-are-in…
seiyab 4935c44
revert line unexpectedly written by editor
seiyab ff86851
Update 14476.md
fisker File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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,19 @@ | ||
#### Fix url contains comma (#14476 by @seiyab) | ||
|
||
<!-- prettier-ignore --> | ||
```css | ||
/* Input */ | ||
@font-face { | ||
src: url(RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf); | ||
} | ||
|
||
/* Prettier stable */ | ||
@font-face { | ||
src: url(RobotoFlex-VariableFont_GRADXTRAYOPQYTASYTDEYTFIYTLCYTUCopszslntwdthwght.ttf); | ||
} | ||
|
||
/* Prettier main */ | ||
@font-face { | ||
src: url(RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf); | ||
} | ||
``` |
This file contains 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 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,13 @@ | ||
import getValueRoot from "./get-value-root.js"; | ||
|
||
/** | ||
* @param {*} node | ||
* @returns {string} | ||
*/ | ||
function getFunctionArgumentsText(node) { | ||
return getValueRoot(node) | ||
.text.slice(node.group.open.sourceIndex + 1, node.group.close.sourceIndex) | ||
.trim(); | ||
} | ||
|
||
export default getFunctionArgumentsText; |
This file contains 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 @@ | ||
const getValueRoot = (node) => { | ||
while (node.parent) { | ||
node = node.parent; | ||
} | ||
|
||
return node; | ||
}; | ||
|
||
export default getValueRoot; |
This file contains 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 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 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
Oops, something went wrong.
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.
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.
Should we trim here?
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.
I thought yes, at the first time.
But I feel I need to know CSS Specification more...
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.
As I tested with in chrome
and
They all requesting urls without space.
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.
postcss-values-parser throws.
I think it should be a bug.
I'll try newer versions.
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.
v3.2.1 seems good.
But v3.0.0 is a big breaking release. https://github.com/shellscape/postcss-values-parser/releases
Which way do you like?
'url( https://example.com/\\(\\(.jpg )'
and merge this PR first. And then try to bump postcss-values-parser on next branch. Finally, tackle'url( https://example.com/\\(\\(.jpg )'
(or, perhaps it will be resolved by update).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.
Will it conflict with your work if I'll try to bump postcss-value-parser?
Referring following, I'm asking you.
#14480
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.
No. Go a head, but it won't be easy, I've tried few times since maybe 2~3 years ago.
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.
Last attempt by other maintainer. #11667
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.
Thank you for your replies.
Sounds so hard!
Any way, I'll try it, though I will be likely to give up 🔥
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.
@fisker
Hi, I have tried migrating postcss-values parser from v2 to v6.
Eventually, I gave up because shellscape/postcss-values-parser#140 prevents us from migrating.
May I summarize what I investigated for migration somewhere (perhaps an issue or a discussion)?