Skip to content

Commit 4679600

Browse files
committed
hyperscript should support HTML elements as strings
1 parent 9b45338 commit 4679600

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/h.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ReactElement,
44
ReactNode,
55
ReactType,
6+
ReactHTML,
67
Attributes,
78
} from 'react';
89
import {incorporate} from './incorporate';
@@ -16,7 +17,7 @@ type PropsLike<P> = P & PropsExtensions & Attributes;
1617
type Children = string | Array<ReactNode>;
1718

1819
function createElementSpreading<P = any>(
19-
type: ReactType<P>,
20+
type: ReactType<P> | keyof ReactHTML,
2021
props: PropsLike<P> | null,
2122
children: Children,
2223
): ReactElement<P> {
@@ -28,7 +29,7 @@ function createElementSpreading<P = any>(
2829
}
2930

3031
function hyperscriptProps<P = any>(
31-
type: ReactType<P>,
32+
type: ReactType<P> | keyof ReactHTML,
3233
props: PropsLike<P>,
3334
): ReactElement<P> {
3435
if (!props.sel) {
@@ -39,14 +40,14 @@ function hyperscriptProps<P = any>(
3940
}
4041

4142
function hyperscriptChildren<P = any>(
42-
type: ReactType<P>,
43+
type: ReactType<P> | keyof ReactHTML,
4344
children: Children,
4445
): ReactElement<P> {
4546
return createElementSpreading(type, null, children);
4647
}
4748

4849
function hyperscriptPropsChildren<P = any>(
49-
type: ReactType<P>,
50+
type: ReactType<P> | keyof ReactHTML,
5051
props: PropsLike<P>,
5152
children: Children,
5253
): ReactElement<P> {
@@ -58,7 +59,7 @@ function hyperscriptPropsChildren<P = any>(
5859
}
5960

6061
export function h<P = any>(
61-
type: ReactType<P>,
62+
type: ReactType<P> | keyof ReactHTML,
6263
a?: PropsLike<P> | Children,
6364
b?: Children,
6465
): ReactElement<P> {

0 commit comments

Comments
 (0)