Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(theme): respect custom tag prop in VPButton component #4185

Merged
merged 1 commit into from
Sep 7, 2024

Conversation

rileychh
Copy link
Contributor

@rileychh rileychh commented Sep 7, 2024

Description

This PR fixes a bug in the VPButton component of the default VitePress theme. Previously, the tag prop was not being properly respected when determining the component to render. This change ensures that the tag prop takes precedence, falling back to a or button based on the presence of the href prop only if no custom tag is specified.

Here's a simple script that demonstrates the effect of this change:

const props = {
  tag: 'div',
  href: undefined,
}

// Before: Incorrectly evaluates to 'a'
const component = props.tag || props.href ? 'a' : 'button'

// After: Correctly evaluates to 'div'
const fixed = props.tag || (props.href ? 'a' : 'button')

In this example, even though we specify a custom tag 'div' and there's no href, the original code would incorrectly choose 'a'. The fixed version correctly respects the custom tag 'div'.

Linked Issues

None.

Additional Context

None.


Tip

The author of this PR can publish a preview release by commenting /publish below.

@brc-dd brc-dd merged commit 9c5d348 into vuejs:main Sep 7, 2024
8 checks passed
rileychh added a commit to COSCUP/coscup.org that referenced this pull request Sep 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants