odoo / owl

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

Suggestion: non prop attributes #843

Closed mcm-odoo closed 2 years ago

mcm-odoo commented 3 years ago

Would be nice to have something to define where class and style attributes are bound in a component.

for the example, the root element of a dialog is a portal so writing <Dialog class="my-dialog" t-att-class="...">... will bound classes on the portal element. We need to use a props to define where it should bind.

e.g.

<Portal target="'body'">
  <div class="o_dialog" t-att-class="props.contentClass">
    ...
  </div>
</Portal>
...
<Dialog contentClass="'...'">...</Dialog>

Why not having a directive or something similar to Vue3's component attributes (https://v3.vuejs.org/guide/component-attrs.html) or a mix of the two?

<Portal target="'body'">
  <div class="o_dialog" t-attrs="class">  <!-- bind the class attribute with a directive -->
    ...
  </div>
</Portal>

We'll also need something like this for multi-rooted components in owl 2.0

ged-odoo commented 3 years ago

this one is actually even more interesting once we implement multiple roots components, because in that case, there is no canonical way to decide where the class attribute should be applied

ged-odoo commented 2 years ago

done in owl 2 (class and style are now normal props)