-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
feat(format/html): port JsxChildList
formatting to HtmlElementList
#3782
feat(format/html): port JsxChildList
formatting to HtmlElementList
#3782
Conversation
CodSpeed Performance ReportMerging #3782 will degrade performances by 17.4%Comparing Summary
Benchmarks breakdown
|
4d8aefe
to
215eecd
Compare
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
215eecd
to
62af8c2
Compare
61cc7b0
to
369d145
Compare
369d145
to
e80e82c
Compare
e80e82c
to
edfb351
Compare
} else if c == '\n' { | ||
has_newline = true; | ||
} |
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.
Is it useful to add a comment explaining the newline detection?
} else if c == '\n' { | |
has_newline = true; | |
} | |
} else if c == '\n' { | |
// A newline is detected. This is tracked separately, | |
// potentially to differentiate text with just line breaks from other whitespace. | |
has_newline = true; | |
} |
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.
This is explained in the doc comment for the function.
AnyHtmlElement::HtmlContent(text) => { | ||
// Split the text into words | ||
// Keep track if there's any leading/trailing empty line, new line or whitespace | ||
|
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.
Is this space intentional?
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.
This is mostly copied straight from the formatter for JsxChildList
.
This comment was marked as resolved.
This comment was marked as resolved.
edfb351
to
044471b
Compare
I think I've resolved the comments thing in other PRs. I've tested this with the prettier test suite, and it gets most of the way there in terms of compatibility. |
044471b
to
dacc167
Compare
Summary
Given the similarity of JSX and HTML, I figured it would save a lot of time to simply port over the applicable portions of JSX formatting to HTML.
This PR attempts to do so for
JsxChildList
->HtmlElementList
.Test Plan
quick_test
should run without panicking.