Skip to content

fix(core): allow invalid harmless tag nesting#8809

Open
wmertens wants to merge 1 commit into
build/v2from
lenient-spec
Open

fix(core): allow invalid harmless tag nesting#8809
wmertens wants to merge 1 commit into
build/v2from
lenient-spec

Conversation

@wmertens

@wmertens wmertens commented Jul 8, 2026

Copy link
Copy Markdown
Member

We should only refuse DOM structures that change when the browser parses the HTML. <div> inside <button> is retained by the browser.

@wmertens wmertens requested a review from a team as a code owner July 8, 2026 13:10
Copilot AI review requested due to automatic review settings July 8, 2026 13:10
@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c1ce97d

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

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/core Patch
eslint-plugin-qwik Patch
@qwik.dev/react Patch
@qwik.dev/router Patch
create-qwik 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8809

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8809

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8809

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8809

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8809

@qwik.dev/devtools

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/devtools@8809

commit: c1ce97d

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts Qwik SSR’s HTML tag nesting enforcement to be lenient for authoring-invalid markup that browsers keep unchanged during parsing, warning in dev instead of throwing when it is safe to continue.

Changes:

  • Adds a “parser-retained invalid nesting” classification (isRetainedWhenInvalid, closesPTag) to distinguish harmless invalid markup from cases that would be rewritten by the HTML parser.
  • Updates SSR container nesting validation to warn (once per parent>child combo per render) and proceed for parser-retained invalid nesting.
  • Extends unit/spec coverage for textarea text-only content and the new leniency behavior, and adds a changeset for @qwik.dev/core.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/qwik/src/server/tag-nesting.unit.ts Adds tests for textarea text-only content and leniency classification helpers.
packages/qwik/src/server/tag-nesting.ts Adds parser-leniency helpers and adjusts textarea nesting state.
packages/qwik/src/server/ssr-container.ts Warns (dev) and continues SSR for parser-retained invalid nesting; adds scope checks to keep throwing when DOM would be rewritten.
packages/qwik/src/server/ssr-container.spec.ts Adds SSR regression tests to confirm warn-once behavior and continued throwing for DOM-rewriting cases.
.changeset/lenient-tag-nesting.md Publishes the behavior change as a patch changeset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +384 to +386
case 'div':
case 'dl':
case 'fieldset':
Comment on lines +402 to +405
case 'menu':
case 'nav':
case 'ol':
case 'p':
Comment on lines 208 to 213
case 'button':
return TagNesting.BUTTON;
case 'input':
case 'textarea':
return TagNesting.PHRASING_INSIDE_INPUT;
case 'picture':
return TagNesting.PICTURE;
case 'style':
case 'noscript':
case 'noframes':
case 'textarea': // rawtext element; element children would be parsed as text
'@qwik.dev/core': patch
---

fix: ssr does not throw for invalid html nesting that browsers keep as-is, but only warns
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview c1ce97d

@Varixo Varixo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even if all the browser around behave here the same the implementation is wrong imo. You just need to remove these tags from config

@wmertens

Copy link
Copy Markdown
Member Author

@Varixo you mean, don't even warn for invalid-spec but valid-parsing HTML?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting For Review

Development

Successfully merging this pull request may close these issues.

4 participants