Skip to content
Myr

fix(jsx): use self closing tag only if element has no children (#2384)

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

* fix(jsx): use self closing tag only if element has no children * chore: denoify

authored by Taku Amano · committed by GitHub · parent b0eb512 · Browse files · 3 files+7 added−2 removed
This commit

State

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

Diff stats

3 files+7 added−2 removed

  • tests:+5 added−0 removed
  • other:+2 added−2 removed

3 files+7 added−2 removed

modified:deno_dist/jsx/base.ts+1 added-1 removed
173 unmodified lines
174 buffer[0] += '"'175 }176 }177178 if (emptyTags.includes(tag as string)) {178 if (emptyTags.includes(tag as string) && children.length === 0) {179 buffer[0] += '/>'180 return181 }182
154 unmodified lines
modified:src/jsx/base.ts+1 added-1 removed
173 unmodified lines
174 buffer[0] += '"'175 }176 }177178 if (emptyTags.includes(tag as string)) {178 if (emptyTags.includes(tag as string) && children.length === 0) {179 buffer[0] += '/>'180 return181 }182
154 unmodified lines
modified:src/jsx/index.test.tsx+5 added
130 unmodified lines
131 const template = <input />132 expect(template.toString()).toBe('<input/>')133 })134135 it('Empty elements with children are rended with children and closing tag', () => {136 const template = <link>https://example.com</link>137 expect(template.toString()).toBe('<link>https://example.com</link>')138 })139140 it('Props value is null', () => {141 const template = <span data-hello={null}>Hello</span>142 expect(template.toString()).toBe('<span>Hello</span>')143 })
617 unmodified lines