@@ -20,6 +20,7 @@ import kotlinx.serialization.json.put
2020import org.w3c.dom.Element
2121import org.w3c.dom.HTMLDivElement
2222import org.w3c.dom.HTMLIFrameElement
23+ import org.w3c.dom.Node
2324import org.w3c.dom.events.Event
2425import kotlin.uuid.ExperimentalUuidApi
2526import kotlin.uuid.Uuid
@@ -43,7 +44,7 @@ fun HtmlView(
4344) {
4445 val scope = rememberCoroutineScope()
4546 val element = remember { mutableStateOf<HTMLIFrameElement ?>(null ) }
46- val root = LocalLayerContainer .current
47+ val root: Node = document.body?.shadowRoot ? : document.body !!
4748 val density = LocalDensity .current.density
4849 val focusManager = LocalFocusManager .current
4950
@@ -74,7 +75,7 @@ fun HtmlView(
7475 componentReady.value = true
7576 val container = componentInfo.container as HTMLDivElement
7677
77- ( root as Element ) .appendChild(container)
78+ root.appendChild(container)
7879 container.append(componentInfo.component)
7980
8081 container.style.position = " absolute"
@@ -177,7 +178,7 @@ fun HtmlView(
177178 }
178179
179180 onDispose {
180- ( root as Element ) .removeChild(componentInfo.container)
181+ root.removeChild(componentInfo.container)
181182 componentInfo.updater.dispose()
182183 element.value?.let { onDispose(it) }
183184 state.htmlElement = null
0 commit comments