Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
feat: _blank target의 Link에 noopener을 제거한다
Browse files Browse the repository at this point in the history
- noreferrer의사용은 noreferrer noopener을 함께 사용하는 것과 같은 동작을 한다
- ref: jsx-eslint/eslint-plugin-react#2022
- ref: https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
  • Loading branch information
chiabi committed Jul 2, 2020
1 parent a276a2b commit a7aea4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/Link/index.tsx
Expand Up @@ -21,8 +21,12 @@ export const Link = React.memo(

const shouldOpenNewTab = external || props.to.search(httpRegExp) !== -1;

// NOTE: noreferrer의 사용은 noreferrer noopener을 함께 사용하는 것과 같은 동작을 하며
// https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
// noreferrer만 사용하는 것이 window.opener 값을 null로 바꾸는 브라우저 테스트에서 더 많이 성공합니다.
// https://github.com/yannickcr/eslint-plugin-react/issues/2022#issuecomment-526320768
const externalAttributes = {
...(shouldOpenNewTab && { target: '_blank', rel: 'noopener noreferrer' }),
...(shouldOpenNewTab && { target: '_blank', rel: 'noreferrer' }),
};

if (LinkComponent) {
Expand Down

0 comments on commit a7aea4b

Please sign in to comment.