From c2728c9dafccfd19d39cddbb1baf539c8beca7ea Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Wed, 3 Sep 2025 13:23:05 +0200 Subject: [PATCH] [DOC] `slots` prop validation Make it explicit that props validation should accept `slots` if a component uses slots (even the `default` slot). --- doc/reference/props.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/reference/props.md b/doc/reference/props.md index 508afad3..a1085eee 100644 --- a/doc/reference/props.md +++ b/doc/reference/props.md @@ -320,6 +320,28 @@ class ComponentB extends owl.Component { Note: the props validation code is done by using the [validate utility function](utils.md#validate). +### `slots` prop + +If a component that uses [slots](slots.md) also lists or validates its props, then +you will have to explicitely allow the `slots` prop (with an `Object` type), or +allow extra props using the `*` notation mentioned above. This is because slots +are provided to a component [as props](slots.md#slots-and-props). + +For example: + +```js +class MyComponent extends Component { + static props = [someProp, slots?]; +} + +class MyComponentWithValidation extends Component { + static props = { + someProp: {type: Number, optional: true}, + slots : {type: Object, optional: true}, + } +} +``` + ## Good Practices A `props` object is a collection of values that come from the parent. As such,