Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

chore: simplify <pre> cleaning #15980

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

Merged
merged 1 commit into from
May 21, 2025
Merged

chore: simplify <pre> cleaning #15980

merged 1 commit into from
May 21, 2025

Conversation

Rich-Harris
Copy link
Member

was looking into how we can make fewer things in #15538 need to be aware of the templating mode (which will make everything more robust) and ran into this <pre> logic. Took me a while to wrap my head round it but it turns out we way overcomplicated things in #14922 — the essence of this logic is that if the first node inside a <pre> is a single newline, we need to strip it because otherwise hydration breaks:

document.body.innerHTML = `<pre>
<div>...</div>
</pre>`;

document.body.querySelector('pre').firstChild; // DIV, not the newline

Instead of doing a convoluted song and dance we can just express that directly. For #15538, we do want to strip any remaining leading newline, but that should happen in template_to_functions, not here

Copy link

changeset-bot bot commented May 21, 2025

🦋 Changeset detected

Latest commit: b709136

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

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

@svelte-docs-bot
Copy link

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@15980

@Rich-Harris
Copy link
Member Author

self-merging to unblock further work on #15538

@Rich-Harris Rich-Harris merged commit c03ea47 into main May 21, 2025
13 checks passed
@Rich-Harris Rich-Harris deleted the simplify-pre-cleaning branch May 21, 2025 19:09
@github-actions github-actions bot mentioned this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.