Skip to content
Myr

fix(jsx): enable `Fragment` (#1412)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(jsx): enable `Fragment` * denoify

authored by Yusuke Wada · committed by GitHub · parent 405ec8c · Browse files · 4 files+28 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+28 added−4 removed

  • tests:+24 added−0 removed
  • other:+4 added−4 removed

4 files+28 added−4 removed

modified:deno_dist/jsx/index.test.tsx+12 added
1/* eslint-disable @typescript-eslint/no-explicit-any */2import { html } from '../helper/html/index.ts'3import { Hono } from '../hono.ts'4// eslint-disable-next-line @typescript-eslint/no-unused-vars5import { jsx, memo, Fragment } from './index.ts'67interface SiteData {8 title: string
356 unmodified lines
365 )366 expect(template.toString()).toBe('<p>1</p><p>2</p>')367 })368369 it('Should render children - with `Fragment`', () => {370 const template = (371 <Fragment>372 <p>1</p>373 <p>2</p>374 </Fragment>375 )376 expect(template.toString()).toBe('<p>1</p><p>2</p>')377 })378379 it('Should render nothing for empty Fragment', () => {380 const template = <></>381 expect(template.toString()).toBe('')382 })
6 unmodified lines
modified:deno_dist/jsx/index.ts+2 added-2 removed
233 unmodified lines
234 return (computed ||= component(props))235 }) as FC<T>236}237238export const Fragment = (props: { key?: string; children?: Child[] }): JSXNode => {239 return new JSXFragmentNode('', {}, props.children || [])238export const Fragment = (props: { key?: string; children?: Child[] }): HtmlEscapedString => {239 return new JSXFragmentNode('', {}, props.children || []) as never240}
modified:src/jsx/index.test.tsx+12 added
1/* eslint-disable @typescript-eslint/no-explicit-any */2import { html } from '../helper/html'3import { Hono } from '../hono'4// eslint-disable-next-line @typescript-eslint/no-unused-vars5import { jsx, memo, Fragment } from './index'67interface SiteData {8 title: string
356 unmodified lines
365 )366 expect(template.toString()).toBe('<p>1</p><p>2</p>')367 })368369 it('Should render children - with `Fragment`', () => {370 const template = (371 <Fragment>372 <p>1</p>373 <p>2</p>374 </Fragment>375 )376 expect(template.toString()).toBe('<p>1</p><p>2</p>')377 })378379 it('Should render nothing for empty Fragment', () => {380 const template = <></>381 expect(template.toString()).toBe('')382 })
6 unmodified lines
modified:src/jsx/index.ts+2 added-2 removed
233 unmodified lines
234 return (computed ||= component(props))235 }) as FC<T>236}237238export const Fragment = (props: { key?: string; children?: Child[] }): JSXNode => {239 return new JSXFragmentNode('', {}, props.children || [])238export const Fragment = (props: { key?: string; children?: Child[] }): HtmlEscapedString => {239 return new JSXFragmentNode('', {}, props.children || []) as never240}