Skip to content

DRAFT: [ADD] xml-class-overridden-by-dynamic: New check - #201

Draft
moylop260 wants to merge 1 commit into
OCA:mainfrom
vauxoo-dev:main-xml-class-overridden-by-dynamic-moy
Draft

moylop260 wants to merge 1 commit into
OCA:mainfrom
vauxoo-dev:main-xml-class-overridden-by-dynamic-moy

Conversation

@moylop260

Copy link
Copy Markdown
Collaborator

A server-rendered QWeb element that carries class beside t-att-class or t-attf-class keeps only the dynamic one. QWeb compiles the static attributes and the dynamic ones into the same attrs dictionary, the static first, so the dynamic value replaces the whole class key and the static classes never reach the page.

Nothing reports it. The view combines, the page answers 200 and the element is in the DOM, only without the classes meant to style it, so it surfaces as a layout that stopped applying for no visible reason. It is also what an inheritance produces on its own: <attribute name="class" remove="..."/> silently stops removing anything the day upstream turns that static class into a t-attf-class.

The check reports only the classes the dynamic value does not spell out. One written in both places still renders, and flagging it would report code that works. Templates declared under assets or qweb are skipped: Owl compiles those in the browser and its setClass calls classList.add, so there the two attributes combine rather than one replacing the other.

Measured with this check over installed addons: 14 elements in odoo/addons 19.0 (633 modules) and 10 in enterprise (785 modules) drop a class this way, among them mt-2 on the event registration questions and btn-check on a survey scale input. Nine OCA repositories (166 modules) report none.

A server-rendered QWeb element that carries `class` beside `t-att-class` or
`t-attf-class` keeps only the dynamic one. QWeb compiles the static attributes
and the dynamic ones into the same `attrs` dictionary, the static first, so the
dynamic value replaces the whole `class` key and the static classes never reach
the page.

Nothing reports it. The view combines, the page answers 200 and the element is
in the DOM, only without the classes meant to style it, so it surfaces as a
layout that stopped applying for no visible reason. It is also what an
inheritance produces on its own: `<attribute name="class" remove="..."/>`
silently stops removing anything the day upstream turns that static `class`
into a `t-attf-class`.

The check reports only the classes the dynamic value does not spell out. One
written in both places still renders, and flagging it would report code that
works. Templates declared under `assets` or `qweb` are skipped: Owl compiles
those in the browser and its `setClass` calls `classList.add`, so there the two
attributes combine rather than one replacing the other.

Measured with this check over installed addons: 14 elements in odoo/addons
19.0 (633 modules) and 10 in enterprise (785 modules) drop a class this way,
among them `mt-2` on the event registration questions and `btn-check` on a
survey scale input. Nine OCA repositories (166 modules) report none.
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.

1 participant