Skip to content

Commit

Permalink
fix(MdApp): fix drawer slot (#1845)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuell1 authored Jul 11, 2018
1 parent b09777b commit e6a967b
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/components/MdApp/MdApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@
return componentOptions && componentTypes.includes(componentOptions.tag)
}
function isRightDrawer ({ mdRight }) {
return mdRight === '' || !!mdRight
}
function createRightDrawer (isMdRight) {
if (isMdRight) {
const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}})
drawerRightPrevious.data.slot = 'md-app-drawer-right-previous'
slots.push(drawerRightPrevious)
}
function isRightDrawer (propsData) {
if (!propsData) return false
return propsData.mdRight === '' || !!propsData.mdRight
}
function shouldRenderSlot (data, componentOptions) {
Expand All @@ -49,9 +42,10 @@
const componentOptions = child.componentOptions
if (shouldRenderSlot(data, componentOptions)) {
child.data.slot = data.slot || componentOptions.tag
const slotName = data.slot || componentOptions.tag
child.data.slot = slotName
if (componentOptions.tag === 'md-app-drawer') {
if (slotName === 'md-app-drawer') {
const isRight = isRightDrawer(componentOptions.propsData)
if (hasDrawer) {
Expand All @@ -63,7 +57,11 @@
child.data.slot += `-${isRight ? 'right' : 'left'}`
child.key = generateAttrKeys(data.attrs)
createRightDrawer(isRight)
if (isRight) {
const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}})
drawerRightPrevious.data.slot = 'md-app-drawer-right-previous'
slots.push(drawerRightPrevious)
}
}
child.data.provide = options.Ctor.options.provide
Expand All @@ -80,9 +78,9 @@
function getDrawers (children) {
const drawerVnodes = children.filter(child => {
return child.componentOptions.tag === 'md-app-drawer'
const tag = child.data.slot || child.componentOptions.tag
return tag === 'md-app-drawer'
})
return drawerVnodes.length ? drawerVnodes : []
}
Expand Down

0 comments on commit e6a967b

Please sign in to comment.