Skip to content

Commit b025047

Browse files
authored
fix(b-icon): title render handling (#6233)
1 parent d94edfe commit b025047

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/icons/helpers/icon-base.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { makeProp } from '../../utils/props'
1010
// --- Constants ---
1111

1212
// Base attributes needed on all icons
13-
const baseAttrs = {
13+
const BASE_ATTRS = {
1414
viewBox: '0 0 16 16',
1515
width: '1em',
1616
height: '1em',
@@ -20,7 +20,7 @@ const baseAttrs = {
2020
}
2121

2222
// Attributes that are nulled out when stacked
23-
const stackedAttrs = {
23+
const STACKED_ATTRS = {
2424
width: null,
2525
height: null,
2626
focusable: null,
@@ -95,14 +95,15 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
9595
)
9696
}
9797

98+
// Wrap in an additional `<g>` for proper animation handling if stacked
9899
if (stacked) {
99-
// Wrap in an additional `<g>` for proper
100-
// animation handling if stacked
101-
$inner = h('g', {}, [$inner])
100+
$inner = h('g', [$inner])
102101
}
103102

104103
const $title = title ? h('title', title) : null
105104

105+
const $content = [$title, $inner].filter(identity)
106+
106107
return h(
107108
'svg',
108109
mergeData(
@@ -112,13 +113,13 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
112113
[`text-${variant}`]: variant,
113114
[`b-icon-animation-${animation}`]: animation
114115
},
115-
attrs: baseAttrs,
116+
attrs: BASE_ATTRS,
116117
style: stacked ? {} : { fontSize: fontScale === 1 ? null : `${fontScale * 100}%` }
117118
},
118119
// Merge in user supplied data
119120
data,
120-
// If icon is stacked, null out some attrs
121-
stacked ? { attrs: stackedAttrs } : {},
121+
// If icon is stacked, null-out some attrs
122+
stacked ? { attrs: STACKED_ATTRS } : {},
122123
// These cannot be overridden by users
123124
{
124125
attrs: {
@@ -127,7 +128,7 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
127128
}
128129
}
129130
),
130-
[$title, $inner]
131+
$content
131132
)
132133
}
133134
})

0 commit comments

Comments
 (0)