odoo / owl

OWL: A web framework for structured, dynamic and maintainable applications
https://odoo.github.io/owl/
Other
1.14k stars 344 forks source link

<t t-set="o" t-value="o"/> with a getter for o #1480

Open Polymorphe57 opened 1 year ago

Polymorphe57 commented 1 year ago

A crash occurs in the simple situation described

in playground

sdegueldre commented 1 year ago

I'm not sure what's unexpected about this, trying to set a property that only has a getter seems like it should crash?

ged-odoo commented 1 year ago

well, we probably expect that t-set stays inside the template. It's kind of the same as this:

const a = 1;
{
  let a = 2;
  a += 5; // or whatever, do something with a;
}
ged-odoo commented 1 year ago

Note that the example given by Mathieu is actually weird. Here is a different example, where we don't reuse the variable in the value: example

sdegueldre commented 1 year ago

Oh I see the issue now. The problem is that while we encounter a boundary and try to set the property on the sub-object, because the property exists in the prototype chain, the getter/setter is invoked and we get a crash because there the property is getter-only on the prototype.