From e74b4d6a9c85166feed1caedaeb7d065d10891fb Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Thu, 16 Feb 2023 15:50:22 -1000 Subject: [PATCH] fix(PrismicLink): only set `target="_blank"` when "Open in new window" is checked (#176) --- src/PrismicLink.tsx | 1 - test/PrismicLink.test.tsx | 32 +++++++------------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/PrismicLink.tsx b/src/PrismicLink.tsx index ba499c4..8ffdf0f 100644 --- a/src/PrismicLink.tsx +++ b/src/PrismicLink.tsx @@ -190,7 +190,6 @@ const _PrismicLink = < props.field && "target" in props.field && props.field.target) || - (!isInternal && "_blank") || undefined; const rel = diff --git a/test/PrismicLink.test.tsx b/test/PrismicLink.test.tsx index 164151b..90856cb 100644 --- a/test/PrismicLink.test.tsx +++ b/test/PrismicLink.test.tsx @@ -217,7 +217,7 @@ test("allow overriding default target", (t) => { t.deepEqual(actual, expected); }); -test("if manually given _blank to target, use rel'noopener norefferer", (t) => { +test('if manually given _blank to target, use rel="noopener norefferer"', (t) => { const field: prismicT.FilledLinkToWebField = { url: "/url", link_type: prismicT.LinkType.Web, @@ -231,10 +231,10 @@ test("if manually given _blank to target, use rel'noopener norefferer", (t) => { t.deepEqual(actual, expected); }); -test('if target is not explicitly provided and the URL is external, use target="_blank" and rel="noopener noreferrer"', (t) => { +test("if target is not provided and the URL is external, target is not set", (t) => { const actual = renderJSON(); const expected = renderJSON( - , + , ); t.deepEqual(actual, expected); @@ -289,7 +289,7 @@ test("if URL is internal and internalComponent is given to the provider and the test("if URL is external and no externalComponent is given, render an ", (t) => { const actual = renderJSON(); const expected = renderJSON( - , + , ); t.deepEqual(actual, expected); @@ -299,13 +299,7 @@ test("if URL is external and externalComponent is given, render externalComponen const actual = renderJSON( , ); - const expected = renderJSON( - , - ); + const expected = renderJSON(); t.deepEqual(actual, expected); }); @@ -316,13 +310,7 @@ test("if URL is external and externalComponent is given to the provider, render , ); - const expected = renderJSON( - , - ); + const expected = renderJSON(); t.deepEqual(actual, expected); }); @@ -333,13 +321,7 @@ test("if URL is external and externalComponent is given to the provider and the , ); - const expected = renderJSON( - , - ); + const expected = renderJSON(); t.deepEqual(actual, expected); });