You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 754a2a5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs-site/src/content/docs/api/defineComponent.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ To define a Regor component, call the `defineComponent` function with the follow
22
22
23
23
-`options` (optional): An array of strings that defines component properties or an object that allows you to configure various options for the component, such as whether to use interpolation, props, the component's default name, or the component context.
24
24
-`context` (optional): A function that defines the Regor context for the component. This function receives a `ComponentHead` object, which you can use to specify the component's behavior and props. It should return the Regor context.
25
-
-`head.autoProps`: Automatically assigns properties defined in the `:context` binding to the component context. Defaults to `true`.
25
+
-`head.autoProps`: Automatically merges `head.props` into the returned component context. Defaults to `true`.
26
26
-`head.entangle`: Keeps refs defined in the component context entangled with `head.props` refs. Defaults to `true`.
27
27
-`head.enableSwitch`: Enables slot context switching to the parent. Defaults to `false`.
28
28
-`head.onAutoPropsAssigned`: Callback invoked after auto props get assigned to the component context.
@@ -160,6 +160,8 @@ The `defineComponent` function returns a component object with the following pro
160
160
161
161
- The component context is configured through the `options.context` callback, which defines the behavior and data of your component.
162
162
- Runtime prop validation is opt-in and local to `context(head)` through `head.validateProps(...)`.
163
+
-`head.autoProps = true` merges `head.props` into the returned component context and also keeps omitted declared prop names local by adding `undefined` only when the component did not already define that field.
164
+
-`head.autoProps = false` disables that merge. In that mode, omitted names are not added automatically, so normal parent-context lookup can still resolve them.
163
165
164
166
- The `options` parameter allows you to configure various aspects of the component, such as enabling or disabling interpolation, specifying props, setting a default name, or providing the component context.
4. Primitive/object values targeting existing component ref fields are applied to those refs.
428
-
5. For single-prop bindings, wrapping an expression in `ref(...)` gives the child a live reactive prop source even when the expression evaluates to a non-ref.
384
+
1.`head.autoProps = true`: Regor merges `head.props` into the returned component context.
385
+
2. With `head.autoProps = true`, omitted declared prop names are added as local `undefined` only when the component did not already define that field.
386
+
3. That keeps declared prop names local to the component and prevents same-named parent values from being resolved by accident.
387
+
4.`head.autoProps = false`: component author maps from `head.props` manually, and omitted names are not isolated automatically.
7. Primitive/object values targeting existing component ref fields are applied to those refs.
391
+
8. For single-prop bindings, wrapping an expression in `ref(...)` gives the child a live reactive prop source even when the expression evaluates to a non-ref.
Copy file name to clipboardExpand all lines: docs-site/src/content/docs/guide/troubleshooting.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,7 @@ Correct routing:
99
99
attribute channel on component hosts (fallthrough), not `head.props` object assignment.
100
100
101
101
If component sets `head.autoProps = false`, you must map `head.props` manually in `context(head)`.
102
+
Also note that omitted declared prop names are not isolated automatically in that mode, so same-named parent values can still resolve through normal template lookup.
0 commit comments