Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(b-icon): title render handling (#6233)
  • Loading branch information
jacobmllr95 committed Dec 21, 2020
1 parent d94edfe commit b025047
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/icons/helpers/icon-base.js
Expand Up @@ -10,7 +10,7 @@ import { makeProp } from '../../utils/props'
// --- Constants ---

// Base attributes needed on all icons
const baseAttrs = {
const BASE_ATTRS = {
viewBox: '0 0 16 16',
width: '1em',
height: '1em',
Expand All @@ -20,7 +20,7 @@ const baseAttrs = {
}

// Attributes that are nulled out when stacked
const stackedAttrs = {
const STACKED_ATTRS = {
width: null,
height: null,
focusable: null,
Expand Down Expand Up @@ -95,14 +95,15 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
)
}

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

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

const $content = [$title, $inner].filter(identity)

return h(
'svg',
mergeData(
Expand All @@ -112,13 +113,13 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
[`text-${variant}`]: variant,
[`b-icon-animation-${animation}`]: animation
},
attrs: baseAttrs,
attrs: BASE_ATTRS,
style: stacked ? {} : { fontSize: fontScale === 1 ? null : `${fontScale * 100}%` }
},
// Merge in user supplied data
data,
// If icon is stacked, null out some attrs
stacked ? { attrs: stackedAttrs } : {},
// If icon is stacked, null-out some attrs
stacked ? { attrs: STACKED_ATTRS } : {},
// These cannot be overridden by users
{
attrs: {
Expand All @@ -127,7 +128,7 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
}
}
),
[$title, $inner]
$content
)
}
})

0 comments on commit b025047

Please sign in to comment.