Skip to content

Commit 9cf4ff2

Browse files
Erbil Nasbuseselvi
authored andcommitted
fix(link): make anchor attrs optional
1 parent f1035cc commit 9cf4ff2

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/components/link/bl-link.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ describe("bl-link", () => {
1515
expect(el.kind).to.equal("primary");
1616
expect(el.href).to.equal("javascript:void(0)");
1717
expect(el.target).to.equal("_self");
18-
expect(el.rel).to.equal("");
19-
expect(el.hreflang).to.equal("");
20-
expect(el.type).to.equal("");
21-
expect(el.download).to.equal("");
22-
expect(el.ping).to.equal("");
18+
expect(el.rel).to.be.undefined;
19+
expect(el.hreflang).to.be.undefined;
20+
expect(el.type).to.be.undefined;
21+
expect(el.referrerPolicy).to.be.undefined;
22+
expect(el.download).to.be.undefined;
23+
expect(el.ping).to.be.undefined;
2324
expect(el.ariaLabel).to.equal("");
2425
});
2526

@@ -167,4 +168,17 @@ describe("bl-link", () => {
167168
expect(link?.getAttribute("target")).to.equal(target);
168169
}
169170
});
171+
172+
it("renders custom icon slot", async () => {
173+
const el = await fixture<BlLink>(html`
174+
<bl-link href="/">
175+
Link Text
176+
<bl-icon name="settings" slot="icon"></bl-icon>
177+
</bl-link>
178+
`);
179+
180+
const slot = el.shadowRoot!.querySelector('slot[name="icon"]');
181+
182+
expect(slot).to.exist;
183+
});
170184
});

src/components/link/bl-link.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,37 @@ export default class BlLink extends LitElement {
6767
* Example: "noopener noreferrer"
6868
*/
6969
@property({ type: String, reflect: true })
70-
rel: HTMLAnchorElement["rel"] = "";
70+
rel?: HTMLAnchorElement["rel"];
7171

7272
/**
7373
* Language of the linked document
7474
*/
7575
@property({ type: String, reflect: true })
76-
hreflang: HTMLAnchorElement["hreflang"] = "";
76+
hreflang?: HTMLAnchorElement["hreflang"];
7777

7878
/**
7979
* MIME type of the linked document
8080
*/
8181
@property({ type: String, reflect: true })
82-
type: HTMLAnchorElement["type"] = "";
82+
type?: HTMLAnchorElement["type"];
8383

8484
/**
8585
* Referrer policy for the link
8686
*/
8787
@property({ type: String, reflect: true, attribute: "referrerpolicy" })
88-
referrerPolicy: HTMLAnchorElement["referrerPolicy"] = "";
88+
referrerPolicy?: HTMLAnchorElement["referrerPolicy"];
8989

9090
/**
9191
* Whether to download the resource instead of navigating to it
9292
*/
9393
@property({ type: String, reflect: true })
94-
download: HTMLAnchorElement["download"] = "";
94+
download?: HTMLAnchorElement["download"];
9595

9696
/**
9797
* Ping URLs to be notified when following the link
9898
*/
9999
@property({ type: String, reflect: true })
100-
ping: HTMLAnchorElement["ping"] = "";
100+
ping?: HTMLAnchorElement["ping"];
101101

102102
private get isStandalone(): boolean {
103103
return this.variant === "standalone";

0 commit comments

Comments
 (0)