|
14 | 14 | return componentOptions && componentTypes.includes(componentOptions.tag)
|
15 | 15 | }
|
16 | 16 |
|
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 |
27 | 20 | }
|
28 | 21 |
|
29 | 22 | function shouldRenderSlot (data, componentOptions) {
|
|
49 | 42 | const componentOptions = child.componentOptions
|
50 | 43 |
|
51 | 44 | if (shouldRenderSlot(data, componentOptions)) {
|
52 |
| - child.data.slot = data.slot || componentOptions.tag |
| 45 | + const slotName = data.slot || componentOptions.tag |
| 46 | + child.data.slot = slotName |
53 | 47 |
|
54 |
| - if (componentOptions.tag === 'md-app-drawer') { |
| 48 | + if (slotName === 'md-app-drawer') { |
55 | 49 | const isRight = isRightDrawer(componentOptions.propsData)
|
56 | 50 |
|
57 | 51 | if (hasDrawer) {
|
|
63 | 57 | child.data.slot += `-${isRight ? 'right' : 'left'}`
|
64 | 58 | child.key = generateAttrKeys(data.attrs)
|
65 | 59 |
|
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 | + } |
67 | 65 | }
|
68 | 66 |
|
69 | 67 | child.data.provide = options.Ctor.options.provide
|
|
80 | 78 |
|
81 | 79 | function getDrawers (children) {
|
82 | 80 | 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' |
84 | 83 | })
|
85 |
| -
|
86 | 84 | return drawerVnodes.length ? drawerVnodes : []
|
87 | 85 | }
|
88 | 86 |
|
|
0 commit comments