diff --git a/package/package-lock.json b/package/package-lock.json index 25a8bd4..88990c4 100644 --- a/package/package-lock.json +++ b/package/package-lock.json @@ -1,12 +1,12 @@ { "name": "texsaur", - "version": "0.7.1", + "version": "0.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "texsaur", - "version": "0.7.1", + "version": "0.8.0", "license": "MIT", "dependencies": { "typescript": "^4.9.5" diff --git a/package/package.json b/package/package.json index cd6882d..c886fd5 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "texsaur", - "version": "0.7.1", + "version": "0.8.0", "description": "", "types": "./dist/index.d.ts", "main": "./dist/index.js", diff --git a/package/src/index.test.tsx b/package/src/index.test.tsx index f099734..cf38275 100644 --- a/package/src/index.test.tsx +++ b/package/src/index.test.tsx @@ -64,6 +64,17 @@ describe('jsx: intrinsic elements', () => { expect(div.classList[0]).to.equal('foo'); expect(div.className).to.equal('foo'); }) + + it('can accept HTMLCollections as children', () => { + const parent =
+
+
+
+
+ const container =
{parent.children}
+ expect(container.children).to.have.a.lengthOf(3); + expect(container.children[2].className).to.equal("child"); + }) }); describe('jsx: fragments', () => { diff --git a/package/src/index.ts b/package/src/index.ts index e0a835e..f559ac3 100644 --- a/package/src/index.ts +++ b/package/src/index.ts @@ -5,7 +5,7 @@ import * as svg from './svg'; function __jsx(tag: T, properties: RecursivePartial | null, ...children: Node[]): HTMLElement function __jsx(tag: T, properties: RecursivePartial | null, ...children: Node[]): SVGElement function __jsx(tag: JSX.Component, properties: Parameters | null, ...children: Node[]): Node -function __jsx(tag: JSX.Tag | JSX.Component, properties: { [key: string]: any } | null, ...children: Node[]) { +function __jsx(tag: JSX.Tag | JSX.Component, properties: { [key: string]: any } | null, ...children: any[]) { const { document, Node } = JsxDom; if (typeof tag === 'function') { @@ -84,7 +84,7 @@ function __jsx(tag: JSX.Tag | JSX.Component, properties: { [key: string]: any } element.appendChild(child); continue; } - if (Array.isArray(child)) { + if (typeof child !== 'string' && child?.[Symbol.iterator]) { element.append(...child); continue; }