Related to #622 (comment).
Unlike the PageRenderer and FrameRenderer implementations, the StreamActions do not preserve permanent elements
You can experiment with the code on JSFiddle:
<html>
<head>
<script type="importmap">
{
"imports": {
"@hotwired/turbo": "https://cdn.skypack.dev/@hotwired/turbo"
}
}
</script>
<script type="module">
import "@hotwired/turbo"
addEventListener("click", ({ target }) => {
if (target.matches("button")) {
const { content } = target.querySelector("template")
target.append(content.cloneNode(true))
}
})
</script>
<script type="module" src="https://unpkg.com/es-module-shims@0.10.1/dist/es-module-shims.js"></script>
</head>
<body>
<p id="permanent" data-turbo-permanent>This should not change when you click the button</p>
<button type="button">
Click me, and hopefully nothing changes
<template>
<turbo-stream action="replace" target="permanent">
<template><p id="permanent" data-turbo-permanent>Uh oh, this changed when you clicked the button!</p></template>
</turbo-stream>
</template>
</button>
</body>
</html>
Is this intended behavior? Permanent elements are a Turbolinks concept, and pre-date Frames and Streams.
Personally, I'm not sure what I'd expect to be "correct" behavior.
On one side of the argument, "permanence" is meaningful during navigation, but might not fit the idea of a Stream operation. On the opposing side, "permanence" could implies that it should be sturdy enough to be immutable in the face of page updates.
Related to #622 (comment).
Unlike the PageRenderer and FrameRenderer implementations, the StreamActions do not preserve permanent elements
You can experiment with the code on JSFiddle:
Is this intended behavior? Permanent elements are a Turbolinks concept, and pre-date Frames and Streams.
Personally, I'm not sure what I'd expect to be "correct" behavior.
On one side of the argument, "permanence" is meaningful during navigation, but might not fit the idea of a Stream operation. On the opposing side, "permanence" could implies that it should be sturdy enough to be immutable in the face of page updates.