Skip to content

Commit c26f826

Browse files
committed
refactor: small refactors
1 parent 5fa3b4f commit c26f826

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

src/components/breadcrumb/CBreadcrumb.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<ol class="breadcrumb">
33
<li
4-
v-for="(item, index) in this.items.slice(0, -1)"
4+
v-for="(item, index) in linkItems"
55
:key="index"
66
:class="[item.addClasses, sharedClasses, addLinkClasses]"
77
role="presentation"
@@ -10,7 +10,8 @@
1010
{{item.text}}
1111
</CLink>
1212
</li>
13-
<li
13+
<li
14+
v-if="lastItem"
1415
:class="['active', lastItem.addClasses, sharedClasses, addLastItemClasses]"
1516
role="presentation"
1617
>
@@ -30,17 +31,17 @@ export default {
3031
CLink
3132
},
3233
props: {
33-
items: {
34-
type: Array,
35-
required: true
36-
},
34+
items: Array,
3735
addClasses: [String, Array, Object],
3836
addLinkClasses: [String, Array, Object],
3937
addLastItemClasses: [String, Array, Object]
4038
},
4139
computed: {
4240
lastItem () {
43-
return this.items[this.items.length -1]
41+
return this.items ? this.items[this.items.length -1] : null
42+
},
43+
linkItems () {
44+
return this.items ? this.items.slice(0, -1) : []
4445
},
4546
sharedClasses () {
4647
return [this.addClasses, 'breadcrumb-item']

src/components/card/CCardImg.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ export default {
1616
functional: true,
1717
name: 'CCardImg',
1818
props,
19-
render (h, { props, data, children }) {
19+
render (h, { props, data }) {
2020
const haveClassSuffix = props.variant !== 'full'
2121
return h(
2222
CImg,
2323
mergeData(data, {
2424
class: `card-img${haveClassSuffix ? `-${props.variant}` : ''}`,
2525
props
26-
}),
27-
children
26+
})
2827
)
2928
}
3029
}

src/components/scrollbar/CScrollbar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export default {
1313
},
1414
switcher: {
1515
type: Boolean,
16-
default: true,
16+
default: true
1717
},
1818
tag: {
1919
type: String,
20-
default: 'div',
20+
default: 'div'
2121
}
2222
},
2323

src/components/toast/CToast.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ export default {
5858
}
5959
},
6060
watch: {
61-
show: {
62-
immediate: true,
63-
handler (val) {
64-
val ? this.display() : this.close()
65-
}
61+
show (val) {
62+
val ? this.display() : this.close()
6663
}
6764
},
65+
//needed not to be called in show watcher to allow SSR
66+
mounted () {
67+
this.show ? this.display() : this.close()
68+
},
6869
computed: {
6970
toastClasses () {
7071
return [

src/components/toast/tests/__snapshots__/CToast.spec.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`CToast renders correctly 1`] = `
77
aria-live="assertive"
88
class="toast"
99
role="alert"
10+
style=""
1011
>
1112
<!---->
1213

src/components/toast/tests/__snapshots__/CToaster.spec.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ exports[`CToaster renders correctly custom wrapper 1`] = `
1818
aria-live="assertive"
1919
class="toast"
2020
role="alert"
21+
style=""
2122
>
2223
<!---->
2324

0 commit comments

Comments
 (0)