Skip to content

Commit 7e24ca1

Browse files
committed
fix: update type definitions for xml and html functions
1 parent cb42564 commit 7e24ca1

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function markup(
153153

154154
export function html(
155155
tag: string | ((props: any) => VDocumentFragment | VElement),
156-
attrs?: Record<string, unknown> | null,
156+
attrs?: Record<string, unknown> | unknown[] | null,
157157
...children: unknown[]
158158
): string {
159159
const parsed = hArgumentParser(tag, attrs, ...children)

src/vdom.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ describe('vdom', () => {
725725
// div.replaceWith('x')
726726
// })
727727

728-
729728
it('should include only elements in children', () => {
730729
const el: VElement = parseHTML('<div> <p>Hello</p> </div>').firstChild
731730
expect(el.childNodes).toHaveLength(3)

src/xml.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import type { VDocumentFragment, VElement } from './vdom'
12
import { hArgumentParser } from './h'
23
import { markup } from './html'
34
import './jsx-runtime'
45

5-
export function xml(itag: string, iattrs?: object, ...ichildren: any[]) {
6-
const { tag, attrs, children } = hArgumentParser(itag, iattrs, ichildren)
7-
return markup(true, tag, attrs, children)
6+
export function xml(
7+
itag: string | ((props: any) => VElement | VDocumentFragment),
8+
iattrs?: Record<string, unknown> | unknown[] | null,
9+
...ichildren: any[]
10+
) {
11+
const { tag, attrs, children } = hArgumentParser(itag, iattrs, ...ichildren)
12+
return markup(true, tag as string, attrs, children)
813
}
914

1015
// export const xmlVDOM = markup.bind(null, true)

0 commit comments

Comments
 (0)