|
2 | 2 | import MdInteractionEvents from 'core/utils/MdInteractionEvents'
|
3 | 3 | import MdRouterLinkProps from 'core/utils/MdRouterLinkProps'
|
4 | 4 | import MdListItemDefault from './MdListItemDefault'
|
| 5 | + import MdListItemFakeButton from './MdListItemFakeButton' |
5 | 6 | import MdListItemButton from './MdListItemButton'
|
6 | 7 | import MdListItemLink from './MdListItemLink'
|
7 | 8 | import MdListItemRouter from './MdListItemRouter'
|
|
22 | 23 | }
|
23 | 24 | }
|
24 | 25 |
|
| 26 | + function hasChildrenButtons (childrens) { |
| 27 | + return childrens.default.some(children => children.componentOptions && children.componentOptions.tag === 'md-button') |
| 28 | + } |
| 29 | +
|
25 | 30 | function shouldRenderButtonWithListener (listeners) {
|
26 | 31 | let listenerNames = Object.keys(listeners)
|
27 | 32 | let shouldRender = false
|
|
39 | 44 | return parent && parent.$router && props.to
|
40 | 45 | }
|
41 | 46 |
|
42 |
| - function createListComponent (props, parent, listeners) { |
| 47 | + function createListComponent (props, parent, listeners, children) { |
43 | 48 | if (hasExpansion(props)) {
|
44 | 49 | return MdListItemExpand
|
45 | 50 | }
|
|
62 | 67 | }
|
63 | 68 |
|
64 | 69 | if (shouldRenderButtonWithListener(listeners)) {
|
| 70 | + if (hasChildrenButtons(children)) { |
| 71 | + return MdListItemFakeButton |
| 72 | + } |
65 | 73 | return MdListItemButton
|
66 | 74 | }
|
67 | 75 |
|
|
76 | 84 | },
|
77 | 85 | render (createElement, { parent, props, listeners, data, slots }) {
|
78 | 86 | let children = slots()
|
79 |
| - let listComponent = createListComponent(props, parent, listeners) |
| 87 | + let listComponent = createListComponent(props, parent, listeners, children) |
80 | 88 | let staticClass = 'md-list-item'
|
81 | 89 |
|
82 | 90 | if (data.staticClass) {
|
|
0 commit comments