diff --git a/source/links/privacy-link.ts b/source/links/privacy-link.ts index 3ec09aa..61dfb74 100644 --- a/source/links/privacy-link.ts +++ b/source/links/privacy-link.ts @@ -5,9 +5,8 @@ import {Component, ComponentChildren, VNode} from 'preact'; * Component properties for {@linkcode PrivacyLink}. */ export type PrivacyLinkProps = { + attributes: Record; children: ComponentChildren; - class: string; - href: string; }; /** @@ -18,8 +17,7 @@ export type PrivacyLinkProps = { export class PrivacyLink extends Component { render(): VNode { const props: Record = { - class: this.props.class, - href: this.props.href, + ...this.props.attributes, rel: 'noopener noreferrer', target: '_blank', }; diff --git a/tests/links/privacy-link.test.ts b/tests/links/privacy-link.test.ts index 1a06f7c..bc44977 100644 --- a/tests/links/privacy-link.test.ts +++ b/tests/links/privacy-link.test.ts @@ -7,15 +7,18 @@ import {PrivacyLink} from '../../source/gram.js'; test('PrivacyLink', (t) => { t.snapshot(render(html`<${PrivacyLink} />`), 'Empty'); + const attributes: Record = { + href: 'https://example.org', + }; t.snapshot( - render(html`<${PrivacyLink} href="https://example.org">Example`), + render(html`<${PrivacyLink} attributes=${attributes}>Example`), 'Text children', ); t.snapshot( render( html` - <${PrivacyLink} href="https://example.org"> + <${PrivacyLink} attributes=${attributes}> Example with children `, @@ -23,14 +26,9 @@ test('PrivacyLink', (t) => { 'HTML children', ); + attributes.class = 'bold italic'; t.snapshot( - render( - html` - <${PrivacyLink} class="bold italic" href="https://example.org"> - Example - - `, - ), + render(html`<${PrivacyLink} attributes=${attributes}>Example`), 'CSS class', ); }); diff --git a/tests/links/snapshots/privacy-link.test.ts.md b/tests/links/snapshots/privacy-link.test.ts.md index 6c88c42..0a4ff9c 100644 --- a/tests/links/snapshots/privacy-link.test.ts.md +++ b/tests/links/snapshots/privacy-link.test.ts.md @@ -20,4 +20,4 @@ Generated by [AVA](https://avajs.dev). > CSS class - 'Example' + 'Example' diff --git a/tests/links/snapshots/privacy-link.test.ts.snap b/tests/links/snapshots/privacy-link.test.ts.snap index 5858066..8751ae0 100644 Binary files a/tests/links/snapshots/privacy-link.test.ts.snap and b/tests/links/snapshots/privacy-link.test.ts.snap differ