Skip to content

Commit

Permalink
refactor(CNavItem): pass anchor attributes to the internal element if…
Browse files Browse the repository at this point in the history
… the href attribute is set
  • Loading branch information
mrholek committed Nov 16, 2024
1 parent 741c27b commit 342ba88
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/coreui-vue/src/components/nav/CNavItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import type { ComponentProps } from '../../utils/ComponentProps'

interface CNavItemProps extends ComponentProps<typeof CNavLink> {
as: string
class: string
}

const CNavItem = defineComponent({
name: 'CNavItem',
inheritAttrs: false,
props: {
/**
* Toggle the active state for the component.
Expand All @@ -21,6 +23,10 @@ const CNavItem = defineComponent({
type: String,
default: 'li',
},
/**
* A string of all className you want applied to the component.
*/
class: String,
/**
* Toggle the disabled state for the component.
*/
Expand All @@ -30,17 +36,18 @@ const CNavItem = defineComponent({
*/
href: String,
},
setup(props: CNavItemProps, { slots }) {
setup(props: CNavItemProps, { attrs, slots }) {
return () =>
h(
props.as,
{
class: 'nav-item',
class: ['nav-item', props.class],
},
props.href
? h(
CNavLink,
{
...attrs,
active: props.active,
disabled: props.disabled,
href: props.href,
Expand Down

0 comments on commit 342ba88

Please sign in to comment.