Skip to content

citry check: the advice for a bound boolean attribute outside Vue's list does not turn it off #876

Backlog

Description

@JuroOravec

(Sonnet 5.5)

Suggested for 1.4.0.

When a boolean attribute is bound to a string, such as :disabled="'false'", citry check tells the author to "Bind a JavaScript boolean instead, such as :disabled="false"". That advice works for most names. For seven names it does not turn the attribute off.

Example

<input type="checkbox" :switch="'false'">

citry.template.invalid-attribute-value reports that switch is on whenever it is present and suggests :switch="false". An author who follows the advice gets switch="false" in the page, and the browser reads that as on.

Affected names

BOOLEAN_ATTRIBUTES in packages/py/citry/citry/_html_attribute_values.py holds 31 names, generated from the HTML Standard. Vue's own boolean list holds 26 names, and 24 of the 31 are in it. The other seven are the ones where the advice is wrong:

  • switch on input. The HTML tables refresh for 1.3.0 adds it, which is how this showed up in review.
  • alpha on input.
  • headingreset on any element.
  • shadowrootclonable, shadowrootcustomelementregistry, shadowrootdelegatesfocus and shadowrootserializable on template.

How Vue's client renderer treats false on these names

I read @vue/runtime-dom 3.5.44 (patchProp, shouldSetAsProp, patchAttr) and ran it. For a bound false:

  1. If the element has a DOM property with the attribute's name (name in el), Vue sets that property to false. A property that reflects a boolean attribute removes the attribute.
  2. Otherwise patchAttr runs, and only seven names get boolean treatment there (itemscope, allowfullscreen, formnovalidate, ismap, nomodule, novalidate, readonly). Every other name goes through setAttribute(name, false), which writes the text false. Only null and undefined remove the attribute.

I mounted <tag :name="value"> with Vue 3.5.44's global build in Playwright 1.65.0 browsers. Results for false, and for the two values that behave the same everywhere:

Name (element) Chromium 158 Firefox 159 WebKit 27.2
switch (input) switch="false" switch="false" removed (input.switch exists)
alpha (input) alpha="false" alpha="false" removed (input.alpha exists)
headingreset (div) headingreset="false" headingreset="false" headingreset="false"
the four shadowroot* (template) ="false" ="false" ="false"
disabled, hidden, novalidate (control) removed removed removed

In all three browsers, null and undefined remove all seven attributes, and '' writes the bare attribute (on). A bound string 'false' on a control such as disabled writes the bare attribute, which is what the existing advice is about.

What the server writes

I read this in the source and did not render it, because the citry-core build I had has no Vue module.

  • server_attribute in crates/citry_vue_compiler/src/server_render.rs leaves an attribute out for false only for the 26 names in BOOLEAN_ATTRIBUTES there. Every other name goes to attribute_text, which writes false as text. So the server writes switch="false", headingreset="false" and the four shadowroot* the same way, which matches Chromium and Firefox.
  • crates/citry_vue_compiler/src/dom_members.rs marks alpha on input as Unknown, so the server reports it cannot predict the attribute, instead of writing text.
  • dom_members.rs has no entry for switch. WebKit 27.2 already has input.switch, so there the client render would remove the attribute where the server wrote switch="false". The next refresh of that table may pick it up.

Proposed fix

Give these seven names different advice in the boolean-binding variant of the message: bind null or undefined to leave the attribute off and '' to turn it on, such as :switch="on ? '' : null", or use v-if to render the element with and without it. Keep the current advice for the 24 names in Vue's list. The plain boolean variant ("leave it out to turn it off") is correct for every name.

Pieces to change:

  • The lint needs to know which names are in Vue's boolean list. A set kept in scripts/generate_html_attribute_values.py and written into the generated module fits how the other hand-kept lists work, and a test should compare it with BOOLEAN_ATTRIBUTES in server_render.rs so the two cannot drift.
  • The rule is in packages/py/citry/citry/analysis.py (the boolean-binding branch of the attribute-value check). The message text is in packages/protocol/diagnostics/v1/catalog.json, and _diagnostic_catalog.py follows it.
  • A test per variant, with :switch="'false'" for the new advice and :disabled="'false'" for the current one.

This changes a message only, so it is not a 1.x break.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions