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: Whitespace in pasted HTML is not handled according to the HTML spec #2715

Closed
wants to merge 1 commit into from
Closed

Conversation

rishi-raj-jain
Copy link
Contributor

fix #2713
/claim #2713

@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2023

⚠️ No Changeset found

Latest commit: dec8a23

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 25, 2023 9:07pm

@rishi-raj-jain
Copy link
Contributor Author

Waiting on how to run the spec test so that can add and test again: #2713 (comment).


if (stripWhitespace) {
node.innerHTML = node.innerHTML.replaceAll(/(\r\n|[\t\n\r])/g, '');
const computedStyle = window.getComputedStyle(node);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure checking the computed style of the top-level element is going to work. The HTML to be deserialized may contain a mixture of different whitespace modes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this doesn't work, you could try walking the DOM tree in a recursive function while keeping track of the current whitespace mode. Then you could transform each text node as you arrive at it according to the rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim small Pull request is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whitespace in pasted HTML is not handled according to the HTML spec
2 participants