0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

fix(jsx): changes behavior when download attribute is set to a boolean value (#3094)

This commit is contained in:
oon00b 2024-07-06 07:34:32 +09:00 committed by GitHub
parent 28de9b32a8
commit 72ee8084a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 2 deletions

View File

@ -56,6 +56,7 @@ const booleanAttributes = [
'default',
'defer',
'disabled',
'download',
'formnovalidate',
'hidden',
'inert',

View File

@ -297,6 +297,28 @@ describe('render to string', () => {
})
})
describe('download attribute', () => {
it('<a download={true}></a> should be rendered as <a download=""></a>', () => {
const template = <a download={true}></a>
expect(template.toString()).toBe('<a download=""></a>')
})
it('<a download={false}></a> should be rendered as <a></a>', () => {
const template = <a download={false}></a>
expect(template.toString()).toBe('<a></a>')
})
it('<a download></a> should be rendered as <a download=""></a>', () => {
const template = <a download></a>
expect(template.toString()).toBe('<a download=""></a>')
})
it('<a download="test"></a> should be rendered as <a download="test"></a>', () => {
const template = <a download='test'></a>
expect(template.toString()).toBe('<a download="test"></a>')
})
})
describe('Function', () => {
it('should be ignored used in on* props', () => {
const onClick = () => {}

View File

@ -179,7 +179,7 @@ export namespace JSX {
type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | string
interface AnchorHTMLAttributes extends HTMLAttributes {
download?: any
download?: string | boolean | undefined
href?: string | undefined
hreflang?: string | undefined
media?: string | undefined
@ -194,7 +194,7 @@ export namespace JSX {
interface AreaHTMLAttributes extends HTMLAttributes {
alt?: string | undefined
coords?: string | undefined
download?: any
download?: string | boolean | undefined
href?: string | undefined
hreflang?: string | undefined
media?: string | undefined