Skip to content

Commit c79df41

Browse files
authored
fix(core): propagate connection meta and owner document to popup (#402)
1 parent 00556e1 commit c79df41

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

packages/core/src/client/webcomponents/state/__tests__/popup.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ function createMockContext(
5252
docks: {
5353
switchEntry: vi.fn(),
5454
},
55+
rpc: {
56+
connectionMeta: { backend: 'ws' },
57+
},
5558
} as unknown as DocksContext
5659
}
5760

@@ -175,6 +178,8 @@ describe('dock popup state', () => {
175178
expect(appRoot).toBeTruthy()
176179
expect(appRoot.id).toBe('vite-devtools-popup-root')
177180
expect(appRoot.appended).toHaveLength(1)
181+
expect((popup as unknown as { __DEVFRAME_CONNECTION_META__?: unknown }).__DEVFRAME_CONNECTION_META__)
182+
.toBe(context.rpc.connectionMeta)
178183
})
179184

180185
it('hides dock overflow panel when opening popup', async () => {

packages/core/src/client/webcomponents/state/popup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const PANEL_MAX_SIZE = 100
1818
const POPUP_MIN_WIDTH = 320
1919
const POPUP_MIN_HEIGHT = 240
2020
const MAIN_FRAME_ACTION_HANDLER_KEY = '__VITE_DEVTOOLS_TRIGGER_DOCK_ACTION__'
21+
const DEVFRAME_CONNECTION_META_KEY = '__DEVFRAME_CONNECTION_META__'
2122

2223
const popupWindow = shallowRef<Window | null>(null)
2324
const isPopupOpen = shallowRef(false)
@@ -179,6 +180,8 @@ async function mountStandaloneApp(context: DocksContext, popup: Window) {
179180
popup.document.head?.appendChild(baseStyle)
180181
popup.document.body.textContent = ''
181182

183+
;(popup as Window & { [DEVFRAME_CONNECTION_META_KEY]?: unknown })[DEVFRAME_CONNECTION_META_KEY] = context.rpc.connectionMeta
184+
182185
const appRoot = popup.document.createElement('div')
183186
appRoot.id = 'vite-devtools-popup-root'
184187
popup.document.body.appendChild(appRoot)

packages/core/src/client/webcomponents/utils/useIframePanes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function useIframePanes(
2525
container,
2626
(el) => {
2727
if (el && !panes.value) {
28-
panes.value = markRaw(createIframePanes({ container: el }))
28+
panes.value = markRaw(createIframePanes({ container: el, document: el.ownerDocument }))
2929
stop()
3030
}
3131
},

0 commit comments

Comments
 (0)