Skip to content

Commit 76232e6

Browse files
committed
Revert beforeunload event handler & update test comment
1 parent 03a0cd1 commit 76232e6

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ internal class ComposeWindow(
366366
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
367367
}
368368

369-
state.globalEvents.addDisposableEvent("beforeunload") {
370-
dispose()
371-
}
372-
373369
detachListener.observe(document.body!!, MutationObserverInit(childList = true, subtree = true))
374370
}
375371

compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/window/ComposeWindowLifecycleTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class ComposeWindowLifecycleTest : OnCanvasTests {
6262
window.dispatchEvent(Event("focus"))
6363
assertEquals(Lifecycle.State.RESUMED, eventsChannel.receive().targetState)
6464

65-
// An artificial "beforeunload" event crashes the entire test task, so leverage a mutation
66-
// for disposing of the ComposeWindow instead.
65+
// Implicitly destroy the ComposeWindow by removing its canvas from the DOM.
6766
canvas.parentNode!!.removeChild(canvas)
6867
assertEquals(Lifecycle.State.STARTED, eventsChannel.receive().targetState)
6968
assertEquals(Lifecycle.State.CREATED, eventsChannel.receive().targetState)

0 commit comments

Comments
 (0)