11import PropTypes from '../_util/vue-types' ;
22import { getComponent , getSlot } from '../_util/props-util' ;
33import { menuAllProps } from './util' ;
4- import { defineComponent } from 'vue' ;
5-
4+ import { defineComponent , inject } from 'vue' ;
5+ import classNames from '../_util/classNames' ;
6+ const injectExtraPropsKey = 'ANT_MENU_PROVIDER_PROPS_KEY' ;
67const MenuItemGroup = {
78 name : 'MenuItemGroup' ,
89 inheritAttrs : false ,
10+ setup ( ) {
11+ return {
12+ injectExtraProps : inject ( injectExtraPropsKey , ( ) => ( { } ) ) ,
13+ } ;
14+ } ,
915 props : {
1016 renderMenuItem : PropTypes . func ,
1117 index : PropTypes . number ,
@@ -18,12 +24,12 @@ const MenuItemGroup = {
1824 isMenuItemGroup : true ,
1925 methods : {
2026 renderInnerMenuItem ( item ) {
21- const { renderMenuItem, index, subMenuKey } = this . $props ;
27+ const { renderMenuItem, index, subMenuKey } = { ... this . $props , ... this . injectExtraProps } ;
2228 return renderMenuItem ( item , index , subMenuKey ) ;
2329 } ,
2430 } ,
2531 render ( ) {
26- const props = { ...this . $props , ...this . $attrs } ;
32+ const props = { ...this . $props , ...this . injectExtraProps , ... this . $attrs } ;
2733 const { class : cls = '' , rootPrefixCls, title } = props ;
2834 const titleClassName = `${ rootPrefixCls } -item-group-title` ;
2935 const listClassName = `${ rootPrefixCls } -item-group-list` ;
@@ -32,7 +38,7 @@ const MenuItemGroup = {
3238 delete props . onClick ;
3339 const children = getSlot ( this ) ;
3440 return (
35- < li { ...props } class = { ` ${ cls } ${ rootPrefixCls } -item-group`} >
41+ < li { ...props } class = { classNames ( cls , ` ${ rootPrefixCls } -item-group`) } >
3642 < div class = { titleClassName } title = { typeof title === 'string' ? title : undefined } >
3743 { getComponent ( this , 'title' ) }
3844 </ div >
0 commit comments