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:
parent
28de9b32a8
commit
72ee8084a1
@ -56,6 +56,7 @@ const booleanAttributes = [
|
||||
'default',
|
||||
'defer',
|
||||
'disabled',
|
||||
'download',
|
||||
'formnovalidate',
|
||||
'hidden',
|
||||
'inert',
|
||||
|
@ -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 = () => {}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user