diff --git a/src/tests/fixtures/permanent_children.html b/src/tests/fixtures/permanent_children.html
new file mode 100644
index 000000000..b7c473106
--- /dev/null
+++ b/src/tests/fixtures/permanent_children.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ Turbo
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tests/functional/page_refresh_tests.js b/src/tests/functional/page_refresh_tests.js
index 0b6945063..0cb22d4b2 100644
--- a/src/tests/functional/page_refresh_tests.js
+++ b/src/tests/functional/page_refresh_tests.js
@@ -328,6 +328,28 @@ test("it preserves data-turbo-permanent elements that don't match when their ids
await expect(page.locator("#preserve-me")).toHaveText("Preserve me, I have a family!")
})
+test("it preserves data-turbo-permanent children", async ({ page }) => {
+ await page.goto("/src/tests/fixtures/permanent_children.html")
+
+ await page.evaluate(() => {
+ // simulate result of client-side drag-and-drop reordering
+ document.getElementById("first-li").before(document.getElementById("second-li"))
+
+ // set state of data-turbo-permanent checkbox
+ document.getElementById("second-checkbox").checked = true
+ })
+
+ // morph page back to original li ordering
+ await page.click("#form-submit")
+ await nextEventNamed(page, "turbo:render", { renderMethod: "morph" })
+
+ // data-turbo-permanent checkbox should still be checked
+ assert.ok(
+ await hasSelector(page, "#second-checkbox:checked"),
+ "retains state of data-turbo-permanent child"
+ )
+})
+
test("renders unprocessable entity responses with morphing", async ({ page }) => {
await page.goto("/src/tests/fixtures/page_refresh.html")