-
Notifications
You must be signed in to change notification settings - Fork 29
Description
I was looking at using this in a Rails app that uses Turbo on the frontend. Turbo intercepts page visits and handles them with fetch to give an SPA-like experience. Turbo maintains an internal page cache, so the injected HTML needs to be cleaned up.
This causes a problem because if you render a code-input, navigate to another page, then hit the Back button, the code-input renders with the HTML
I can get most of the way there by removing all the non-textarea elements before cache using the following but it still leaves the textarea HTML in the code like you see in the above screenshot.
document.addEventListener("turbo:before-cache", () => {
document.querySelectorAll("code-input :not(textarea)").forEach((el) => el.remove())
}) <code-input class="line-numbers code-input_autogrow_height" language="bash">
<%= form.text_area :body, class: "form-control", rows: 12, data: { code_input_fallback: true } %>
</code-input>I think this comes down to how the textarea[data-code-input-fallback] is handled since that attribute seems to be removed.
Line 741 in 877e596
| this.innerHTML = this.escapeHtml(value); |