|
5 | 5 | </template> |
6 | 6 |
|
7 | 7 | <script setup> |
8 | | -import { capitalize, computed, h, nextTick, onMounted, onUpdated, ref, render, useSlots } from 'vue'; |
| 8 | +import { capitalize, computed, getCurrentInstance, h, nextTick, onMounted, onUpdated, ref, render, useSlots } from 'vue'; |
9 | 9 | import { DtNotice } from '@dialpad/dialtone-vue'; |
10 | 10 |
|
11 | 11 | const ERROR_MESSAGE = 'Invalid combination'; |
@@ -50,6 +50,11 @@ const emit = defineEmits([ |
50 | 50 |
|
51 | 51 | const slots = useSlots(); |
52 | 52 |
|
| 53 | +// Standalone render() creates an app-less context; attaching appContext here |
| 54 | +// lets the target component and all its children (including DtcNode slots) |
| 55 | +// resolve globally registered components, directives, and provides. |
| 56 | +const { appContext } = getCurrentInstance(); |
| 57 | +
|
53 | 58 | /** |
54 | 59 | * Map object containing events and their respective handlers. |
55 | 60 | * |
@@ -114,11 +119,13 @@ function renderTarget () { |
114 | 119 | const slotKey = Object.keys(slots).sort().join(','); |
115 | 120 |
|
116 | 121 | try { |
117 | | - render(h(props.component, { |
| 122 | + const vnode = h(props.component, { |
118 | 123 | ...filteredBindings, |
119 | 124 | ...events.value, |
120 | 125 | key: slotKey, |
121 | | - }, slots), currentContainer); |
| 126 | + }, slots); |
| 127 | + vnode.appContext = appContext; |
| 128 | + render(vnode, currentContainer); |
122 | 129 | } catch (e) { |
123 | 130 | console.warn('Rendering warning: \n', e); |
124 | 131 | currentContainer = freshContainer(); |
|
0 commit comments