diff --git a/packages/main/cypress/specs/Link.cy.tsx b/packages/main/cypress/specs/Link.cy.tsx index cc4812e79673..a3b826f94db4 100644 --- a/packages/main/cypress/specs/Link.cy.tsx +++ b/packages/main/cypress/specs/Link.cy.tsx @@ -22,6 +22,16 @@ describe("General API", () => { .should("have.attr", "rel", "noreferrer noopener"); }); + it("should not add rel attribute for custom target", () => { + cy.mount(); + + cy.get("[ui5-link]") + .shadow() + .find(".ui5-link-root") + .should("have.attr", "target", "my-target") + .and("not.have.attr", "rel"); + }); + it("should wrap the text of the link", () => { cy.mount( <> diff --git a/packages/main/src/Link.ts b/packages/main/src/Link.ts index f59d9d220fbf..7b11102b6682 100644 --- a/packages/main/src/Link.ts +++ b/packages/main/src/Link.ts @@ -291,7 +291,7 @@ class Link extends UI5Element implements ITabbable { } onBeforeRendering() { - const needsNoReferrer = this.target !== "_self" + const needsNoReferrer = this.target === "_blank" && this.href && this._isCrossOrigin(this.href); diff --git a/packages/main/test/pages/Link.html b/packages/main/test/pages/Link.html index 1bf22d3c9536..24ad35d639b6 100644 --- a/packages/main/test/pages/Link.html +++ b/packages/main/test/pages/Link.html @@ -47,6 +47,11 @@

prevent-default

link click default preventednative span +
+

Custom target

+ Custom target link (click multiple times - should reuse same tab) +
+

overstyle-link

link with different colornative span