Skip to content

Commit

Permalink
fix(iconbutton): make target type stricter
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 557643977
  • Loading branch information
AndrewJakubowicz authored and Copybara-Service committed Aug 16, 2023
1 parent d665864 commit c874cd5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion iconbutton/demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const collection =
new Knob('ariaLabel', {ui: textInput(), defaultValue: ''}),
new Knob(
'href', {ui: textInput(), defaultValue: 'https://www.google.com'}),
new Knob('target', {
new Knob<'_blank'|'_self', 'target'>('target', {
ui: radioSelector({
options: [
{value: '_blank', label: '_blank'}, {value: '_self', label: '_self'}
Expand Down
2 changes: 1 addition & 1 deletion iconbutton/demo/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface StoryKnobs {
icon: string;
ariaLabel: string;
href: string;
target: string;
target: '_blank'|'_parent'|'_self'|'_top'|'';
selectedIcon: string;
selectedAriaLabel: string;
selected: boolean;
Expand Down
4 changes: 2 additions & 2 deletions iconbutton/internal/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class IconButton extends LitElement implements FormSubmitter {
/**
* Sets the underlying `HTMLAnchorElement`'s `target` attribute.
*/
@property() target = '';
@property() target: LinkTarget|'' = '';

/**
* The `aria-label` of the button when the button is toggleable and selected.
Expand Down Expand Up @@ -130,7 +130,7 @@ export class IconButton extends LitElement implements FormSubmitter {
<a class="link"
id="link"
href="${this.href}"
target="${this.target as LinkTarget || nothing}"
target="${this.target || nothing}"
aria-label="${ariaLabel || nothing}"
></a>
`;
Expand Down

0 comments on commit c874cd5

Please sign in to comment.