Skip to content

Commit 342ba88

Browse files
committed
refactor(CNavItem): pass anchor attributes to the internal element if the href attribute is set
1 parent 741c27b commit 342ba88

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/coreui-vue/src/components/nav/CNavItem.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import type { ComponentProps } from '../../utils/ComponentProps'
55

66
interface CNavItemProps extends ComponentProps<typeof CNavLink> {
77
as: string
8+
class: string
89
}
910

1011
const CNavItem = defineComponent({
1112
name: 'CNavItem',
13+
inheritAttrs: false,
1214
props: {
1315
/**
1416
* Toggle the active state for the component.
@@ -21,6 +23,10 @@ const CNavItem = defineComponent({
2123
type: String,
2224
default: 'li',
2325
},
26+
/**
27+
* A string of all className you want applied to the component.
28+
*/
29+
class: String,
2430
/**
2531
* Toggle the disabled state for the component.
2632
*/
@@ -30,17 +36,18 @@ const CNavItem = defineComponent({
3036
*/
3137
href: String,
3238
},
33-
setup(props: CNavItemProps, { slots }) {
39+
setup(props: CNavItemProps, { attrs, slots }) {
3440
return () =>
3541
h(
3642
props.as,
3743
{
38-
class: 'nav-item',
44+
class: ['nav-item', props.class],
3945
},
4046
props.href
4147
? h(
4248
CNavLink,
4349
{
50+
...attrs,
4451
active: props.active,
4552
disabled: props.disabled,
4653
href: props.href,

0 commit comments

Comments
 (0)