From b2015c6efbe2d490ed4b60c545601a61ec0b7b67 Mon Sep 17 00:00:00 2001 From: Tomas Vondracek Date: Mon, 26 Oct 2026 12:40:05 +0100 Subject: [PATCH] refactor: bind undefined instead of false for the pattern and error message 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 --- assets/js/app/editor/Components/Date.vue | 4 ++- assets/js/app/editor/Components/Email.vue | 9 +++++-- assets/js/app/editor/Components/Embed.vue | 6 +++-- assets/js/app/editor/Components/File.vue | 6 +++-- assets/js/app/editor/Components/Image.vue | 6 +++-- assets/js/app/editor/Components/Number.vue | 8 ++++-- assets/js/app/editor/Components/Password.vue | 6 +++-- assets/js/app/editor/Components/Select.vue | 4 ++- assets/js/app/editor/Components/Slug.vue | 6 +++-- assets/js/app/editor/Components/Text.vue | 8 ++++-- assets/js/app/editor/Components/Textarea.vue | 6 ++++- assets/js/app/editor/utils/attributes.ts | 11 ++++++++ tests/unit/README.md | 2 +- tests/unit/components/Date.spec.ts | 9 +++++++ tests/unit/components/Email.spec.ts | 10 +++++++ tests/unit/components/Embed.spec.ts | 7 +++++ tests/unit/components/File.spec.ts | 28 ++++++++++++++++---- tests/unit/components/Image.spec.ts | 16 +++++++++++ tests/unit/components/Number.spec.ts | 12 +++++++++ tests/unit/components/Password.spec.ts | 7 +++++ tests/unit/components/Select.spec.ts | 9 +++++++ tests/unit/components/Slug.spec.ts | 9 +++++++ tests/unit/components/Text.spec.ts | 8 ++++++ tests/unit/components/Textarea.spec.ts | 7 +++++ tests/unit/utils/attributes.spec.ts | 12 +++++++++ 25 files changed, 191 insertions(+), 25 deletions(-) create mode 100644 assets/js/app/editor/utils/attributes.ts create mode 100644 tests/unit/utils/attributes.spec.ts diff --git a/assets/js/app/editor/Components/Date.vue b/assets/js/app/editor/Components/Date.vue index 5a9e184d24..8fdf4dbf5a 100644 --- a/assets/js/app/editor/Components/Date.vue +++ b/assets/js/app/editor/Components/Date.vue @@ -9,7 +9,7 @@ :form="form" :name="name" placeholder="Select date" - :data-errormessage="errormessage" + :data-errormessage="optionalAttribute(errormessage)" >