@@ -5,15 +5,6 @@ import { pascalCase, trim } from '../utils/string'
5
5
import { BIconBlank } from './icons'
6
6
import { commonIconProps } from './helpers/icon-base'
7
7
8
- const findIconComponent = ( parent , iconName ) => {
9
- if ( ! parent ) {
10
- return null
11
- }
12
- const components = ( parent . $options || { } ) . components
13
- const iconComponent = components [ iconName ]
14
- return iconComponent || findIconComponent ( parent . $parent , iconName )
15
- }
16
-
17
8
// Helper BIcon component
18
9
// Requires the requested icon component to be installed
19
10
export const BIcon = /*#__PURE__*/ Vue . extend ( {
@@ -32,13 +23,13 @@ export const BIcon = /*#__PURE__*/ Vue.extend({
32
23
} ,
33
24
render ( h , { data, props, parent } ) {
34
25
const icon = pascalCase ( trim ( props . icon || '' ) ) . replace ( RX_ICON_PREFIX , '' )
35
-
26
+ const iconName = `BIcon ${ icon } `
36
27
// If parent context exists, we check to see if the icon has been registered
37
- // either locally in the parent component, or globally at the `$root` level
28
+ // Either locally in the parent component, or globally at the `$root` level
38
29
// If not registered, we render a blank icon
39
- return h (
40
- icon ? findIconComponent ( parent , `BIcon ${ icon } ` ) || BIconBlank : BIconBlank ,
41
- mergeData ( data , { props : { ... props , icon : null } } )
42
- )
30
+ const components = ( ( parent || { } ) . $options || { } ) . components
31
+ const componentRefOrName =
32
+ icon && components ? components [ iconName ] || BIconBlank : icon ? iconName : BIconBlank
33
+ return h ( componentRefOrName , mergeData ( data , { props : { ... props , icon : null } } ) )
43
34
}
44
35
} )
0 commit comments