Skip to content

Commit 87d8bd3

Browse files
committed
fix: map class -> className
Fixes #606
1 parent ada1fad commit 87d8bd3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.changeset/chatty-waves-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'markdown-to-jsx': patch
3+
---
4+
5+
Handle `class` attribute from arbitrary HTML properly to avoid React warnings.

index.compiler.spec.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,10 +2460,18 @@ describe('GFM tables', () => {
24602460

24612461
describe('arbitrary HTML', () => {
24622462
it('preserves the HTML given', () => {
2463-
render(compiler('<dd>Hello</dd>'))
2463+
const ast = compiler('<dd class="foo">Hello</dd>')
2464+
expect(ast).toMatchInlineSnapshot(`
2465+
<dd
2466+
className="foo"
2467+
>
2468+
Hello
2469+
</dd>
2470+
`)
24642471

2472+
render(ast)
24652473
expect(root.innerHTML).toMatchInlineSnapshot(`
2466-
<dd>
2474+
<dd class="foo">
24672475
Hello
24682476
</dd>
24692477
`)

index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ const ATTRIBUTE_TO_JSX_PROP_MAP = [
8989
'cellPadding',
9090
'cellSpacing',
9191
'charSet',
92-
'className',
9392
'classId',
9493
'colSpan',
9594
'contentEditable',
@@ -126,7 +125,7 @@ const ATTRIBUTE_TO_JSX_PROP_MAP = [
126125
obj[x.toLowerCase()] = x
127126
return obj
128127
},
129-
{ for: 'htmlFor' }
128+
{ class: 'className', for: 'htmlFor' }
130129
)
131130

132131
const namedCodesToUnicode = {

0 commit comments

Comments
 (0)