Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/main/cypress/specs/Link.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ describe("General API", () => {
.should("have.attr", "rel", "noreferrer noopener");
});

it("should not add rel attribute for custom target", () => {
cy.mount(<Link href="https://www.sap.com" target="my-target"></Link>);

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(
<>
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions packages/main/test/pages/Link.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ <h2>prevent-default</h2>
<ui5-link href="https://www.google.com" target="_self" id="link-click-prevent-default">link click default prevented</ui5-link><span>native span</span>
</section>

<section class="group">
<h2>Custom target</h2>
<ui5-link href="https://www.sap.com" target="my-target" id="custom-target-link">Custom target link (click multiple times - should reuse same tab)</ui5-link>
</section>

<section class="group">
<h2>overstyle-link</h2>
<ui5-link href="https://www.google.com" target="_self" style="color: pink">link with different color</ui5-link><span>native span</span>
Expand Down
Loading