Skip to content

Commit e6a967b

Browse files
authored
fix(MdApp): fix drawer slot (#1845)
1 parent b09777b commit e6a967b

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/components/MdApp/MdApp.vue

+13-15
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,9 @@
1414
return componentOptions && componentTypes.includes(componentOptions.tag)
1515
}
1616
17-
function isRightDrawer ({ mdRight }) {
18-
return mdRight === '' || !!mdRight
19-
}
20-
21-
function createRightDrawer (isMdRight) {
22-
if (isMdRight) {
23-
const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}})
24-
drawerRightPrevious.data.slot = 'md-app-drawer-right-previous'
25-
slots.push(drawerRightPrevious)
26-
}
17+
function isRightDrawer (propsData) {
18+
if (!propsData) return false
19+
return propsData.mdRight === '' || !!propsData.mdRight
2720
}
2821
2922
function shouldRenderSlot (data, componentOptions) {
@@ -49,9 +42,10 @@
4942
const componentOptions = child.componentOptions
5043
5144
if (shouldRenderSlot(data, componentOptions)) {
52-
child.data.slot = data.slot || componentOptions.tag
45+
const slotName = data.slot || componentOptions.tag
46+
child.data.slot = slotName
5347
54-
if (componentOptions.tag === 'md-app-drawer') {
48+
if (slotName === 'md-app-drawer') {
5549
const isRight = isRightDrawer(componentOptions.propsData)
5650
5751
if (hasDrawer) {
@@ -63,7 +57,11 @@
6357
child.data.slot += `-${isRight ? 'right' : 'left'}`
6458
child.key = generateAttrKeys(data.attrs)
6559
66-
createRightDrawer(isRight)
60+
if (isRight) {
61+
const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}})
62+
drawerRightPrevious.data.slot = 'md-app-drawer-right-previous'
63+
slots.push(drawerRightPrevious)
64+
}
6765
}
6866
6967
child.data.provide = options.Ctor.options.provide
@@ -80,9 +78,9 @@
8078
8179
function getDrawers (children) {
8280
const drawerVnodes = children.filter(child => {
83-
return child.componentOptions.tag === 'md-app-drawer'
81+
const tag = child.data.slot || child.componentOptions.tag
82+
return tag === 'md-app-drawer'
8483
})
85-
8684
return drawerVnodes.length ? drawerVnodes : []
8785
}
8886

0 commit comments

Comments
 (0)