Repository navigation
Conversation
…essage Twig passes `false` for a field without a pattern or error message. Vue 2 drops a non-boolean attribute bound to `false`, but Vue 3 renders it as "false", so every such field would get `pattern="false"` (and could no longer be saved) and `data-errormessage="false"`. The new `optionalAttribute` helper maps `false` to `undefined`, which drops the attribute in both versions; every other value renders as before. The editor fields bind `data-errormessage` and `pattern` through it. https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html
Vondry
force-pushed
the
refactor/vue3-false-attributes
branch
from
October 26, 2026 11:44
4898793 to
b2015c6
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Next step in splitting #3751 towards Vue 3.
Why
Twig passes
falsefor a field without a pattern or error message. Vue 2 drops a non-boolean attribute bound tofalse, but Vue 3 renders it as"false". On Vue 3 every such field would get:pattern="false", so the field only accepts the literal value "false" and the record can no longer be saved;data-errormessage="false", socommon.jswould show "false" as the validation message.Why this approach
nullorundefinedto drop an attribute. Both work on Vue 2.7 too, so this can land now.falseis mapped. Vue 2 drops exactlyfalse,nullandundefined, so every other value ('',0, any string) renders as before.defaultwould not help: Twig always passes the prop, so the default never applies.<script setup>the components will import it directly.What changed
assets/js/app/editor/utils/attributes.ts:optionalAttribute()returnsundefinedforfalseand every other value as it is.data-errormessageandpatternthrough it: 19 bindings in Text, Email, Number, Password, Textarea, Slug, Embed, File, Image, Date and Select.placeholderis unchanged, because Twig sends''for it, neverfalse.false. Date, Select, File and Image use the tests from Migrate to Vue 3 Composition API and TypeScript #3751, replacing File'sit.todo.