Skip to content

Commit

Permalink
feat(link): support rel attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
simshanith authored and Westbrook committed Jul 27, 2020
1 parent fc7d587 commit df4b5a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/link/test/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,20 @@ describe('Link', () => {

await expect(el).to.be.accessible();
});

it('loads[rel]', async () => {
const el = await fixture<Link>(
html`
<sp-link href="test_url" rel="external">
Default Link
</sp-link>
`
);

await elementUpdated(el);
expect(el).to.not.be.undefined;
expect(el.getAttribute('rel')).to.eq('external'));

await expect(el).to.be.accessible();
});
});
5 changes: 5 additions & 0 deletions packages/shared/src/like-anchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface LikeAnchorInterface {
download?: string;
label?: string;
href?: string;
rel?: string;
target?: '_blank' | '_parent' | '_self' | '_top';
renderAnchor(options: {
id: string;
Expand All @@ -45,6 +46,9 @@ export function LikeAnchor<T extends Constructor<UpdatingElement>>(
@property({ reflect: true })
public target?: '_blank' | '_parent' | '_self' | '_top';

@property({ reflect: true })
public rel?: string;

public renderAnchor({
id,
// prettier-ignore
Expand All @@ -61,6 +65,7 @@ export function LikeAnchor<T extends Constructor<UpdatingElement>>(
download=${ifDefined(this.download)}
target=${ifDefined(this.target)}
aria-label=${ifDefined(this.label)}
rel=${ifDefined(this.rel)}
>${anchorContent}</a>`;
}
}
Expand Down

0 comments on commit df4b5a8

Please sign in to comment.