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(format/html): resolve some edge cases with whitespace and how inline elements are treated #5148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dyc3
Copy link
Contributor

@dyc3 dyc3 commented Feb 17, 2025

Summary

This PR aims to resolve some mismatches with prettier preservation of whitespace in whitespace sensitive contexts. Also it deals with how inline elements are treated in the multiline layout case. It also does some refactoring to help make determining whitespace sensitivity easier.

Test Plan

Snapshots updated, added a test.

@github-actions github-actions bot added A-Formatter Area: formatter L-HTML Language: HTML labels Feb 17, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most notably, this PR resolves the mismatch with prettier for this test case:

<span>123</span>
<span>
123</span>
<span>123
</span>
<span>
123
</span>

<div>123</div>
<div>
123</div>
<div>123
</div>
<div>
123
</div>

@dyc3 dyc3 force-pushed the html-whitespace-quirks branch 2 times, most recently from 644a2f7 to bec640a Compare February 17, 2025 21:21
Copy link

codspeed-hq bot commented Feb 17, 2025

CodSpeed Performance Report

Merging #5148 will improve performances by 6.23%

Comparing html-whitespace-quirks (f0f1adf) with main (177f005)

Summary

⚡ 1 improvements
✅ 96 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
react.production.min_3378072959512366797.js[uncached] 2.3 ms 2.1 ms +6.23%

@dyc3 dyc3 force-pushed the html-whitespace-quirks branch from bec640a to 7003df2 Compare February 21, 2025 17:31
@dyc3 dyc3 changed the title fix(format/html): resolve some edge cases with whitespace fix(format/html): resolve some edge cases with whitespace and how inline elements are treated Feb 21, 2025
@dyc3 dyc3 force-pushed the html-whitespace-quirks branch from 7003df2 to f0f1adf Compare February 21, 2025 17:34
@dyc3 dyc3 marked this pull request as ready for review February 21, 2025 17:34
@dyc3 dyc3 requested review from a team February 21, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-HTML Language: HTML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant