Skip to content

Commit

Permalink
feat: syncing color mode backward for iframe, close #195
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 23, 2023
1 parent ebc9a38 commit 76b3c7a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/devtools/client/components/IframeView.vue
Expand Up @@ -63,6 +63,11 @@ function syncColorMode() {
const html = iframeEl.value.contentWindow.document.querySelector('html')
html?.classList.toggle('dark', colorMode.value === 'dark')
html?.classList.toggle('light', colorMode.value === 'dark')
const ob = new MutationObserver(() => {
colorMode.value = iframeEl.value?.contentWindow?.document.querySelector('html')?.classList.contains('dark') ? 'dark' : 'light'
})
ob.observe(html!, { attributes: true, attributeFilter: ['class'] })
}
catch (e) {
}
Expand Down

0 comments on commit 76b3c7a

Please sign in to comment.