Skip to content

Commit 9b1edc9

Browse files
serialinexanf
andauthored
fix(b-skeleton): accepts custom attributes (bootstrap-vue#6858)
* fix(b-skeleton): root element accept custom attributes * fix(b-skeleton-img): pass attributes only image element Co-authored-by: Illya Klymov <xanf@xanf.me>
1 parent 14e413c commit 9b1edc9

File tree

6 files changed

+65
-19
lines changed

6 files changed

+65
-19
lines changed

src/components/skeleton/skeleton-icon.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Vue } from '../../vue'
1+
import { Vue, mergeData } from '../../vue'
22
import { NAME_SKELETON_ICON } from '../../constants/components'
33
import { PROP_TYPE_OBJECT, PROP_TYPE_STRING } from '../../constants/props'
44
import { makeProp, makePropsConfigurable } from '../../utils/props'
@@ -22,7 +22,7 @@ export const BSkeletonIcon = /*#__PURE__*/ Vue.extend({
2222
name: NAME_SKELETON_ICON,
2323
functional: true,
2424
props,
25-
render(h, { props }) {
25+
render(h, { data, props }) {
2626
const { icon, animation } = props
2727

2828
const $icon = h(BIcon, {
@@ -35,10 +35,10 @@ export const BSkeletonIcon = /*#__PURE__*/ Vue.extend({
3535

3636
return h(
3737
'div',
38-
{
38+
mergeData(data, {
3939
staticClass: 'b-skeleton-icon-wrapper position-relative d-inline-block overflow-hidden',
4040
class: { [`b-skeleton-animate-${animation}`]: animation }
41-
},
41+
}),
4242
[$icon]
4343
)
4444
}

src/components/skeleton/skeleton-icon.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,17 @@ describe('skeleton-icon', () => {
7272

7373
wrapper.destroy()
7474
})
75+
76+
it('accepts custom classes', async () => {
77+
const wrapper = mount(BSkeletonIcon, {
78+
context: {
79+
class: ['foobar']
80+
}
81+
})
82+
83+
expect(wrapper.classes()).toContain('b-skeleton-icon-wrapper')
84+
expect(wrapper.classes()).toContain('foobar')
85+
86+
wrapper.destroy()
87+
})
7588
})

src/components/skeleton/skeleton-img.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Vue } from '../../vue'
1+
import { Vue, mergeData } from '../../vue'
22
import { NAME_SKELETON_IMG } from '../../constants/components'
33
import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../../constants/props'
44
import { makeProp, makePropsConfigurable } from '../../utils/props'
@@ -27,19 +27,22 @@ export const BSkeletonImg = /*#__PURE__*/ Vue.extend({
2727
name: NAME_SKELETON_IMG,
2828
functional: true,
2929
props,
30-
render(h, { props }) {
30+
render(h, { data, props }) {
3131
const { aspect, width, height, animation, variant, cardImg } = props
3232

33-
const $img = h(BSkeleton, {
34-
props: {
35-
type: 'img',
36-
width,
37-
height,
38-
animation,
39-
variant
40-
},
41-
class: { [`card-img-${cardImg}`]: cardImg }
42-
})
33+
const $img = h(
34+
BSkeleton,
35+
mergeData(data, {
36+
props: {
37+
type: 'img',
38+
width,
39+
height,
40+
animation,
41+
variant
42+
},
43+
class: { [`card-img-${cardImg}`]: cardImg }
44+
})
45+
)
4346

4447
return props.noAspect ? $img : h(BAspect, { props: { aspect } }, [$img])
4548
}

src/components/skeleton/skeleton-img.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,17 @@ describe('skeleton-img', () => {
123123

124124
wrapper.destroy()
125125
})
126+
127+
it('accepts custom classes', async () => {
128+
const wrapper = mount(BSkeletonImg, {
129+
context: {
130+
class: ['foobar']
131+
}
132+
})
133+
134+
expect(wrapper.find('.b-aspect-content > .b-skeleton-img').exists()).toBe(true)
135+
expect(wrapper.find('.b-aspect-content > .b-skeleton-img').classes()).toContain('foobar')
136+
137+
wrapper.destroy()
138+
})
126139
})

src/components/skeleton/skeleton-table.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Vue } from '../../vue'
1+
import { Vue, mergeData } from '../../vue'
22
import { NAME_SKELETON_TABLE } from '../../constants/components'
33
import {
44
PROP_TYPE_BOOLEAN,
@@ -36,7 +36,7 @@ export const BSkeletonTable = /*#__PURE__*/ Vue.extend({
3636
name: NAME_SKELETON_TABLE,
3737
functional: true,
3838
props,
39-
render(h, { props }) {
39+
render(h, { data, props }) {
4040
const { animation, columns } = props
4141

4242
const $th = h('th', [h(BSkeleton, { props: { animation } })])
@@ -49,6 +49,10 @@ export const BSkeletonTable = /*#__PURE__*/ Vue.extend({
4949
const $thead = !props.hideHeader ? h('thead', [$thTr]) : h()
5050
const $tfoot = props.showFooter ? h('tfoot', [$thTr]) : h()
5151

52-
return h(BTableSimple, { props: { ...props.tableProps } }, [$thead, $tbody, $tfoot])
52+
return h(BTableSimple, mergeData(data, { props: { ...props.tableProps } }), [
53+
$thead,
54+
$tbody,
55+
$tfoot
56+
])
5357
}
5458
})

src/components/skeleton/skeleton-table.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,17 @@ describe('skeleton-table', () => {
103103

104104
wrapper.destroy()
105105
})
106+
107+
it('accepts custom classes', async () => {
108+
const wrapper = mount(BSkeletonTable, {
109+
context: {
110+
class: ['foobar']
111+
}
112+
})
113+
114+
expect(wrapper.classes()).toContain('b-table')
115+
expect(wrapper.classes()).toContain('foobar')
116+
117+
wrapper.destroy()
118+
})
106119
})

0 commit comments

Comments
 (0)