Skip to content

Commit 927c234

Browse files
authored
chore(icons): additional adjustment for stacked animations (#4948)
1 parent 2c60769 commit 927c234

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/icons/helpers/icon-base.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
116116
)
117117
}
118118

119+
if (isStacked) {
120+
// Wrap in an additional `<g>` for proper
121+
// animation handling if stacked
122+
$inner = h('g', {}, [$inner])
123+
}
124+
119125
return h(
120126
'svg',
121127
mergeData(

src/icons/icons.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,38 @@ describe('icons', () => {
5252
expect(wrapper.find('svg > g > path').exists()).toBe(true)
5353
})
5454

55+
it('b-icon has expected structure when `stacked` prop is true', async () => {
56+
const wrapper = mount(BIcon, {
57+
localVue: localVue,
58+
parentComponent: parentComponent,
59+
propsData: {
60+
icon: 'alert-circle-fill',
61+
stacked: true
62+
}
63+
})
64+
65+
expect(wrapper.exists()).toBe(true)
66+
expect(wrapper.is('svg')).toBe(true)
67+
expect(wrapper.classes()).toContain('b-icon')
68+
expect(wrapper.classes()).toContain('bi')
69+
expect(wrapper.classes()).toContain('bi-alert-circle-fill')
70+
expect(wrapper.classes().length).toBe(3)
71+
expect(wrapper.attributes('role')).not.toBe('img')
72+
expect(wrapper.attributes('alt')).not.toBe('icon')
73+
expect(wrapper.attributes('focusable')).toBe('false')
74+
expect(wrapper.attributes('xmlns')).not.toBe('http://www.w3.org/2000/svg')
75+
expect(wrapper.attributes('width')).not.toBe('1em')
76+
expect(wrapper.attributes('height')).not.toBe('1em')
77+
expect(wrapper.attributes('viewBox')).toBe('0 0 20 20')
78+
expect(wrapper.attributes('fill')).toBe('currentColor')
79+
expect(wrapper.attributes('style')).not.toBeDefined()
80+
expect(wrapper.element.style.fontSize).toEqual('')
81+
expect(wrapper.find('svg > g').exists()).toBe(true)
82+
expect(wrapper.find('svg > g').attributes('transform')).not.toBeDefined()
83+
expect(wrapper.find('svg > g > path').exists()).toBe(false)
84+
expect(wrapper.find('svg > g > g > path').exists()).toBe(true)
85+
})
86+
5587
it('b-icon with empty icon name renders BIconBlank', async () => {
5688
// This test assumes Vue doesn't puke on unknown component names
5789
// As we don't specify a parent instance (which has all the registered

0 commit comments

Comments
 (0)