Skip to content

Commit

Permalink
Fix hydration mismatch due to different order of attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Apr 9, 2022
1 parent b05e75b commit 6d68771
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ export function handleCommentClick(event: ReactMouseEvent<HTMLElement, MouseEven

export function processCommentBody(bodyHTML: string) {
if (typeof document === 'undefined') {
return bodyHTML.replace(/<a href/g, '<a target="_top" rel="noopener noreferrer nofollow" href');
return bodyHTML.replace(
/<a (href=\"[^"]*\")/g,
'<a $1 rel="noopener noreferrer nofollow" target="_top"',
);
}

const template = document.createElement('template');
Expand All @@ -164,8 +167,8 @@ export function processCommentBody(bodyHTML: string) {
return;
}

a.target = '_top';
a.rel = 'noopener noreferrer nofollow';
a.target = '_top';
});

content
Expand Down

0 comments on commit 6d68771

Please sign in to comment.