From 23caecb0399b9bab7ef10898b4a855e0578cc54f Mon Sep 17 00:00:00 2001 From: Evan Jacobs Date: Wed, 20 Nov 2024 01:49:21 -0500 Subject: [PATCH] fix: ref not supported in arbitrary html Fixes #591 --- .changeset/tricky-cups-relate.md | 5 +++++ index.tsx | 4 ++++ package.json | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/tricky-cups-relate.md diff --git a/.changeset/tricky-cups-relate.md b/.changeset/tricky-cups-relate.md new file mode 100644 index 00000000..0ba1f814 --- /dev/null +++ b/.changeset/tricky-cups-relate.md @@ -0,0 +1,5 @@ +--- +'markdown-to-jsx': patch +--- + +Drop encountered `ref` attributes when processing inline HTML, React doesn't handle it well. diff --git a/index.tsx b/index.tsx index 46f4bcd3..9161e97a 100644 --- a/index.tsx +++ b/index.tsx @@ -1245,6 +1245,10 @@ export function compiler( const value = unquote(raw.slice(delimiterIdx + 1).trim()) const mappedKey = ATTRIBUTE_TO_JSX_PROP_MAP[key] || key + + // bail out, not supported + if (mappedKey === 'ref') return map + const normalizedValue = (map[mappedKey] = attributeValueToJSXPropValue( tag, key, diff --git a/package.json b/package.json index a725b19a..d793eb3e 100644 --- a/package.json +++ b/package.json @@ -99,11 +99,11 @@ "size-limit": [ { "path": "./dist/index.module.js", - "limit": "6.3 kB" + "limit": "6.5 kB" }, { "path": "./dist/index.modern.js", - "limit": "6.3 kB" + "limit": "6.5 kB" } ], "jest": {