Skip to content

Commit

Permalink
fix(link): Do not convert link href to number or boolean (#5391)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurtsiv authored Aug 11, 2024
1 parent 84febb2 commit 08b4319
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/link-href-parsing-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/extension-link": fix
---

Fixes a bug where link `href` was converted to number or boolean during HTML parsing, leading to a crash in rendering.
5 changes: 4 additions & 1 deletion packages/extension-link/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export const Link = Mark.create<LinkOptions>({
return {
href: {
default: null,
parseHTML(element) {
return element.getAttribute('href')
},
},
target: {
default: this.options.HTMLAttributes.target,
Expand All @@ -187,7 +190,7 @@ export const Link = Mark.create<LinkOptions>({
if (!href || !isAllowedUri(href)) {
return false
}
return { href }
return null
},
}]
},
Expand Down

0 comments on commit 08b4319

Please sign in to comment.