Skip to content

Commit ef0d9e7

Browse files
committed
refactor(CButton): improve syntax
1 parent 62fd9ba commit ef0d9e7

File tree

1 file changed

+5
-5
lines changed
  • packages/coreui-vue/src/components/button

1 file changed

+5
-5
lines changed

packages/coreui-vue/src/components/button/CButton.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const CButton = defineComponent({
7979
'click',
8080
],
8181
setup(props, { emit, slots }) {
82+
const component = props.href ? 'a' : props.component
8283
const handleClick = (event: Event) => {
8384
if (props.disabled) {
8485
return
@@ -88,7 +89,7 @@ export const CButton = defineComponent({
8889
}
8990
return () =>
9091
h(
91-
props.component,
92+
component,
9293
{
9394
class: [
9495
'btn',
@@ -100,10 +101,9 @@ export const CButton = defineComponent({
100101
},
101102
props.shape,
102103
],
103-
disabled: props.disabled && props.component !== 'a',
104-
...(props.component === 'a' && props.disabled && { 'aria-disabled': true, tabIndex: -1 }),
105-
...(props.component === 'a' && props.href && { href: props.href }),
106-
...(props.component === 'button' && { type: props.type }),
104+
...(component === 'a' && props.disabled && { 'aria-disabled': true, tabIndex: -1 }),
105+
...(component === 'a' && props.href && { href: props.href }),
106+
...(component === 'button' && { type: props.type, disabled: props.disabled }),
107107
onClick: handleClick,
108108
},
109109
slots.default && slots.default(),

0 commit comments

Comments
 (0)