|
1 | 1 | import { $, QRL } from '../import/qrl.public'; |
2 | 2 | import type { JSXNode } from '../render/jsx/types/jsx-node'; |
3 | 3 | import { OnRenderProp } from '../util/markers'; |
4 | | -import type { ComponentBaseProps } from '../render/jsx/types/jsx-qwik-attributes'; |
| 4 | +import type { ComponentBaseProps, JSXTagName } from '../render/jsx/types/jsx-qwik-attributes'; |
5 | 5 | import type { FunctionComponent } from '../render/jsx/types/jsx-node'; |
6 | 6 | import { jsx } from '../render/jsx/jsx-runtime'; |
7 | 7 | import type { MutableWrapper } from '../object/q-object'; |
@@ -42,7 +42,7 @@ export interface ComponentOptions { |
42 | 42 | * of host element requires that the parent component needs to know the tag name of the child |
43 | 43 | * component synchronously. |
44 | 44 | */ |
45 | | - tagName?: string; |
| 45 | + tagName?: JSXTagName; |
46 | 46 | } |
47 | 47 |
|
48 | 48 | /** |
@@ -80,7 +80,7 @@ export type MutableProps<PROPS extends {}> = { |
80 | 80 | */ |
81 | 81 | export type EventHandler<T> = QRL<(value: T) => any>; |
82 | 82 |
|
83 | | -const ELEMENTS_SKIP_KEY = ['html', 'body', 'head']; |
| 83 | +const ELEMENTS_SKIP_KEY: JSXTagName[] = ['html', 'body', 'head']; |
84 | 84 |
|
85 | 85 | // <docs markdown="../readme.md#component"> |
86 | 86 | // !!DO NOT EDIT THIS COMMENT DIRECTLY!!! |
@@ -145,8 +145,9 @@ export const componentQrl = <PROPS extends {}>( |
145 | 145 |
|
146 | 146 | // Return a QComponent Factory function. |
147 | 147 | return function QSimpleComponent(props, key): JSXNode<PROPS> { |
| 148 | + const finalTag = props['host:tagName'] ?? tagName; |
148 | 149 | const finalKey = skipKey ? undefined : onRenderQrl.getHash() + ':' + (key ? key : ''); |
149 | | - return jsx(tagName, { [OnRenderProp]: onRenderQrl, ...props }, finalKey) as any; |
| 150 | + return jsx(finalTag as string, { [OnRenderProp]: onRenderQrl, ...props }, finalKey) as any; |
150 | 151 | }; |
151 | 152 | }; |
152 | 153 |
|
|
0 commit comments