Skip to content

[FIX] owl-compiler: give each keyed site a unique render key - #2083

Merged
ged-odoo merged 1 commit into
odoo:masterfrom
alexkuhn:master-fix-owl-component-in-a-t-call-body-collides-with-t-aku
Dec 2, 2026
Merged

ged-odoo merged 1 commit into
odoo:masterfrom
alexkuhn:master-fix-owl-component-in-a-t-call-body-collides-with-t-aku

Conversation

@alexkuhn

@alexkuhn alexkuhn commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Before this commit, mounting a component crashes when one of its templates calls a sub-template with a body, and both the body and the sub-template render a component.

Steps to reproduce:

  • Mount a component with the template <div><t t-call="sub"><Child v="'B'"/></t></div>, where the template sub is <b><Child v="'A'"/><t t-out="0"/></b>. The mount throws "Cannot read properties of null (reading 'bdom')", where <div><b><i>A</i><i>B</i></b></div> is expected.

This happens because the t-out="0" of the sub-template renders the body with the key of that site, under the same node, while the ids in the keys of components and t-calls restart for each compiled template. The body is compiled in the caller's template, so its first component and the first one of the sub-template get the same key, and the second site reuses the component of the first one, which is mounted twice. The same happens with a dynamic t-call, and with a t-call-slot of the same name in the body and in the sub-template.

The same keys also repeat in loops: the t-out="0", t-call-slot and t-set body sites take as key only the t-key of their innermost loop, without the key of the template or of the outer loops. Their components then get the same key in each iteration of an outer loop, or of a loop that calls their template, such as a slot called in a loop of a sub-template that is itself called in a loop.

After this commit, these sites get a unique id followed by the keys of all loops through generateComponentKey(), as components and t-calls already do. This also keeps apart the cache keys of .signal= sites once they start with the render key, as #2066 does.

@alexkuhn
alexkuhn marked this pull request as ready for review November 30, 2026 17:23
Before this commit, mounting a component crashes when one of its
templates calls a sub-template with a body, and both the body and the
sub-template render a component.

Steps to reproduce:
- Mount a component with the template
  `<div><t t-call="sub"><Child v="'B'"/></t></div>`, where the template
  `sub` is `<b><Child v="'A'"/><t t-out="0"/></b>`. The mount throws
  "Cannot read properties of null (reading 'bdom')", where
  `<div><b><i>A</i><i>B</i></b></div>` is expected.

This happens because the `t-out="0"` of the sub-template renders the
body with the key of that site, under the same node, while the ids in
the keys of components and `t-call`s restart for each compiled template.
The body is compiled in the caller's template, so its first component
and the first one of the sub-template get the same key, and the second
site reuses the component of the first one, which is mounted twice. The
same happens with a dynamic `t-call`, and with a `t-call-slot` of the
same name in the body and in the sub-template.

The same keys also repeat in loops: the `t-out="0"`, `t-call-slot` and
`t-set` body sites take as key only the `t-key` of their innermost loop,
without the key of the template or of the outer loops. Their components
then get the same key in each iteration of an outer loop, or of a loop
that calls their template, such as a slot called in a loop of a
sub-template that is itself called in a loop.

After this commit, these sites get a unique id followed by the keys of
all loops through `generateComponentKey()`, as components and `t-call`s
already do. This also keeps apart the cache keys of `.signal=` sites
once they start with the render key, as odoo#2066 does.
@alexkuhn
alexkuhn force-pushed the master-fix-owl-component-in-a-t-call-body-collides-with-t-aku branch from e6053eb to 459fe82 Compare December 1, 2026 14:46
@alexkuhn alexkuhn changed the title [FIX] owl-compiler: give a t-call body its own render key [FIX] owl-compiler: give each keyed site a unique render key Dec 1, 2026
@ged-odoo
ged-odoo merged commit 7958577 into odoo:master Dec 2, 2026
2 checks passed
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.

3 participants