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

make it easier to subclass components with subcomponents #1390

Open ged-odoo opened 1 year ago

ged-odoo commented 1 year ago

Now, when extending a component, we have to redefine the static components key:

class A extends Component {
  static components = { SomeComponent };
}

class B extends A {
  static components = { ...A.components, SomeOtherComponent };
}

This may lead to problem in Odoo when patching components: if some code patches the A component after the definition of B, then B will not have the correct components.

We could change Owl to make it so that a subcomponent only define the additional components it needs, while keeping the components from its parent. For example:

class A extends Component {
  static components = { SomeComponent }
}

class B extends A {
  static components = { SomeOtherComponent };
}

Owl could make the above code work, maybe by setting the prototype of its static components key to A.components.

ged-odoo commented 1 year ago

@pparidans @aab-odoo