Skip to content

Conversation

tzdesign
Copy link
Contributor

@tzdesign tzdesign commented Aug 8, 2025

Description

This PR introduces dedicated tag nesting rules for <picture> and <button> elements to improve HTML validation in the Qwik server-side renderer.

Changes

  • Added new TagNesting.PICTURE and TagNesting.BUTTON constants.
  • Updated allowedContent() to describe valid children for <picture> (<source>, <img>) and <button> (phrasing content except interactive elements).
  • Implemented isInPicture() to restrict <picture> children to valid HTML elements.
  • Implemented isInButton() to disallow nested interactive elements inside <button>.
  • Adjusted isInPhrasing() to route <picture> and <button> appropriately.
  • Updated bitmask values for existing table-related constants to accommodate new entries.

Why

Previously, <picture> and <button> elements were validated only under generic phrasing content rules. This allowed invalid nesting (e.g., interactive elements inside <button> or unrelated tags inside <picture>). By adding explicit states and validation logic, HTML output from Qwik will better comply with the HTML specification and prevent common markup mistakes.

Benefits

  • Stricter HTML validation for server-rendered output.
  • Prevention of invalid interactive nesting inside <button>.
  • Proper enforcement of <picture> allowed children.

Checklist

@tzdesign tzdesign requested a review from a team as a code owner August 8, 2025 11:25
Copy link

changeset-bot bot commented Aug 8, 2025

🦋 Changeset detected

Latest commit: 321b52d

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

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

Copy link
Contributor

github-actions bot commented Aug 8, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

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

Copy link

pkg-pr-new bot commented Aug 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@7798
npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@7798
npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@7798
npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@7798

commit: 321b52d

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

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

LGTM

@wmertens wmertens enabled auto-merge (squash) August 8, 2025 13:53
'@qwik.dev/core': patch
---

Add explicit tag nesting rules for <picture> and <button> elements
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Add explicit tag nesting rules for <picture> and <button> elements
FIX: add explicit tag nesting rules for <picture> and <button> elements

Copy link
Member

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Thanks @tzdesign for your PR, I have one small feedback

@wmertens wmertens merged commit 3cb6697 into QwikDev:build/v2 Aug 8, 2025
17 checks passed
@tzdesign
Copy link
Contributor Author

tzdesign commented Aug 8, 2025

@wmertens you over ruled @gioboa ?

@gioboa maybe another pr, but I will make sure to keep the structure. We are started with changesets ourselves last week.

@wmertens
Copy link
Member

wmertens commented Aug 8, 2025

oops the merge ignored the unresolved conversation because on the v2 branch it's not needed :(

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.

3 participants