From 66a7c7ff586040fa453d2b979744948d20c268ea Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 11 Jul 2022 21:04:23 +0300 Subject: [PATCH 1/2] Components: Refactor ExternalLink away from Lodash --- packages/components/src/external-link/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/components/src/external-link/index.tsx b/packages/components/src/external-link/index.tsx index 44d006a676e26..56e9a8494a184 100644 --- a/packages/components/src/external-link/index.tsx +++ b/packages/components/src/external-link/index.tsx @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import { compact, uniq } from 'lodash'; import type { ForwardedRef } from 'react'; /** @@ -28,9 +27,16 @@ function UnforwardedExternalLink( ref: ForwardedRef< HTMLAnchorElement > ) { const { href, children, className, rel = '', ...additionalProps } = props; - const optimizedRel = uniq( - compact( [ ...rel.split( ' ' ), 'external', 'noreferrer', 'noopener' ] ) - ).join( ' ' ); + const optimizedRel = [ + ...new Set( + [ + ...rel.split( ' ' ), + 'external', + 'noreferrer', + 'noopener', + ].filter( Boolean ) + ), + ].join( ' ' ); const classes = classnames( 'components-external-link', className ); return ( /* eslint-disable react/jsx-no-target-blank */ From e19ab8348adafda1a8ecc566c7ccba18c57f2152 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 11 Jul 2022 21:08:35 +0300 Subject: [PATCH 2/2] Add changelog --- packages/components/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 517f5e3dd3340..9bf6b3b4de816 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -31,6 +31,7 @@ - `MenuItem`: Refactor away from `_.isString()` ([#42268](https://github.com/WordPress/gutenberg/pull/42268/)). - `Shortcut`: Refactor away from `_.isString()` ([#42268](https://github.com/WordPress/gutenberg/pull/42268/)). - `RangeControl`: Convert to TypeScript ([#40535](https://github.com/WordPress/gutenberg/pull/40535)). +- `ExternalLink`: Refactor away from Lodash ([#42341](https://github.com/WordPress/gutenberg/pull/42341/)). ## 19.14.0 (2022-06-29)