Skip to content

chore(icons): additional adjustment for stacked animations #4948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/icons/helpers/icon-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
)
}

if (isStacked) {
// Wrap in an additional `<g>` for proper
// animation handling if stacked
$inner = h('g', {}, [$inner])
}

return h(
'svg',
mergeData(
Expand Down
32 changes: 32 additions & 0 deletions src/icons/icons.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,38 @@ describe('icons', () => {
expect(wrapper.find('svg > g > path').exists()).toBe(true)
})

it('b-icon has expected structure when `stacked` prop is true', async () => {
const wrapper = mount(BIcon, {
localVue: localVue,
parentComponent: parentComponent,
propsData: {
icon: 'alert-circle-fill',
stacked: true
}
})

expect(wrapper.exists()).toBe(true)
expect(wrapper.is('svg')).toBe(true)
expect(wrapper.classes()).toContain('b-icon')
expect(wrapper.classes()).toContain('bi')
expect(wrapper.classes()).toContain('bi-alert-circle-fill')
expect(wrapper.classes().length).toBe(3)
expect(wrapper.attributes('role')).not.toBe('img')
expect(wrapper.attributes('alt')).not.toBe('icon')
expect(wrapper.attributes('focusable')).toBe('false')
expect(wrapper.attributes('xmlns')).not.toBe('http://www.w3.org/2000/svg')
expect(wrapper.attributes('width')).not.toBe('1em')
expect(wrapper.attributes('height')).not.toBe('1em')
expect(wrapper.attributes('viewBox')).toBe('0 0 20 20')
expect(wrapper.attributes('fill')).toBe('currentColor')
expect(wrapper.attributes('style')).not.toBeDefined()
expect(wrapper.element.style.fontSize).toEqual('')
expect(wrapper.find('svg > g').exists()).toBe(true)
expect(wrapper.find('svg > g').attributes('transform')).not.toBeDefined()
expect(wrapper.find('svg > g > path').exists()).toBe(false)
expect(wrapper.find('svg > g > g > path').exists()).toBe(true)
})

it('b-icon with empty icon name renders BIconBlank', async () => {
// This test assumes Vue doesn't puke on unknown component names
// As we don't specify a parent instance (which has all the registered
Expand Down