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 ampersand in jsx href and src #1056
Merged
vjeux
merged 18 commits into
prettier:master
from
yamafaktory:1051-fix-ampersand-in-jsx-href-and-src
Apr 8, 2017
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
52a22ef
Add exceptions for html escape usage in href and src attributes.
yamafaktory 9684dcb
Add new test cases.
yamafaktory f727380
Remove useless spaces.
yamafaktory 7722580
Do not escape if the parser does not do so.
yamafaktory f7fe929
Implement a different heuristic for keeping along with the parser.
yamafaktory aaae029
Update tests.
yamafaktory b96d537
Forgot passing options as param.
yamafaktory 546e6c2
Experimental alternative implementation.
yamafaktory 394f1b4
Remove other function.
yamafaktory 12bdb89
Merge branch 'master' of https://github.com/jlongster/prettier into 1…
yamafaktory 5c41b55
Push test after merge.
yamafaktory 17c6661
Merge branch 'master' of https://github.com/jlongster/prettier into 1…
yamafaktory 384539e
Update getJsXRawValue in order to return the unprocessed raw value.
yamafaktory a8930ca
Drop unused htmlEscapeInsideDoubleQuote function.
yamafaktory 96e3641
Move getJSXRawValue function logic to the its only call, drop it.
yamafaktory 8238382
Remove ambiguous comment.
yamafaktory 13074f0
Add Babylon parser.
yamafaktory 2da92a2
Update test cases accordingly, revert regression introduced previously.
yamafaktory 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 |
---|---|---|
|
@@ -1200,7 +1200,10 @@ function genericPrintNoParens(path, options, print) { | |
(n.value.type === "StringLiteral" || n.value.type === "Literal") && | ||
typeof n.value.value === "string" | ||
) { | ||
res = '"' + util.htmlEscapeInsideDoubleQuote(n.value.value) + '"'; | ||
const value = n.value.extra ? n.value.extra.raw : n.value.raw; | ||
res = '"' + | ||
value.slice(1, value.length - 1).replace(/"/g, """) + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi, you can do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yeah you're right! |
||
'"'; | ||
} else { | ||
res = path.call(print, "value"); | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default () => <a href="https://foo.bar?q1=foo&q2=bar" />; | ||
|
||
() => <img src="https://bar.foo?param1=1¶m2=2" />; |
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 |
---|---|---|
@@ -1 +1 @@ | ||
run_spec(__dirname, null, ["typescript"]); | ||
run_spec(__dirname, null, ["babylon", "typescript"]); |
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
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.
Can you delete that function from util since it's no longer being used?