sveltejs / sveltejs/kit

Inconsistent boolean element property processing

Open
#14,366 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting submitter
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

I noticed that Svelte changes my html slightly during rendering when boolean HTML attributes are in use.

Here's a two lines of HTML from a svelte file:

<form action="#" novalidate></form>
<custom-element popover></custom-element>

Here's how it's rendered:

<form action="#" novalidate></form> 
<custom-element popover=""></custom-element>

Note how the popover attribute was unexpectedly altered into a string while novalidate was not.

Reproduction

Drop these lines into any *.svelte file and observe the rendered source.

<form action="#" novalidate></form>
<custom-element popover></custom-element>
Logs

System Info
System:
    OS: Linux 6.8 Linux Mint 22 (Wilma)
    CPU: (16) x64 AMD Ryzen 7 5700G with Radeon Graphics
    Memory: 16.49 GB / 30.72 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.19.4 - ~/.bin/node/bin/node
    npm: 10.8.2 - ~/.bin/node/bin/npm
  Browsers:
    Chrome: 139.0.7258.154
  npmPackages:
    @sveltejs/adapter-auto: ^6.0.0 => 6.1.0 
    @sveltejs/kit: ^2.22.0 => 2.37.0 
    @sveltejs/vite-plugin-svelte: ^6.0.0 => 6.1.3 
    svelte: ^5.0.0 => 5.38.6 
    vite: ^7.0.4 => 7.1.4
Severity

annoyance

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported reproduction in any *.svelte file and compare the rendered source for the novalidate and popover attributes. Trace how these boolean HTML attributes are processed, then verify that both attributes are rendered consistently without changing their intended form.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.