Content
View differences
Updated by Alexander Coles 14 days ago
## Context
Split off from #OP-19618 (Part B), which originally bundled this with CSP nonce enforcement (now its own consolidation, OP-19618, stacked on PR #23980 / #24033). Splitting because this half has an open design question the other did not, and is independent scope.
## Three mechanisms protect custom elements from morph; make it one policy
Three places independently decide what happens to a custom element when idiomorph runs, each with a different rule:
* - `frontend/src/turbo/turbo-global-listeners.ts` — `turbo:before-morph-element` blanket `preventDefault()` on any `OPCE-*` element.
*
- `frontend/src/turbo/action-menu-morph-remount.ts` — `turbo:morph-element` clones the `<action-menu>` host to force `connectedCallback` to re-fire.
*
- `frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts` — its own `beforeNodeMorphed` that skips `OPCE-*` unless a scheduling flag flips.
The root fact ("Primer/Angular ("Primer/Angular custom elements do not survive morph cleanly") cleanly") is re-discovered and re-encoded three ways; a fourth bug will likely become a fourth special case.
* - Extract a single custom-element morph policy with a small interface (e.g. `shouldMorph(node)` / `onMorphSkipped(node)`) consumed by all three call sites.
*
- Confirm during design whether one policy covers all three cases (whole-page vs frame vs single host) or only two — they are subtly different.
## Notes
Relates to #DREAM-514 and #OP-19618 (the CSP nonce consolidation, sibling work). The `turbo_power` allowlist in `setup.ts` is being addressed upstream via https://github.com/marcoroth/turbo\_power/pull/333 https://github.com/marcoroth/turbo_power/pull/333 and is intentionally out of scope here.
### Hints for QA
Changes are DX-focused. Does not need manual QA.
Split off from #OP-19618 (Part B), which originally bundled this with CSP nonce enforcement (now its own consolidation, OP-19618, stacked on PR #23980 / #24033). Splitting because this half has an open design question the other did not, and is independent scope.
## Three mechanisms protect custom elements from morph; make it one policy
Three places independently decide what happens to a custom element when idiomorph runs, each with a different rule:
*
*
-
*
-
*
*
-
Relates to #DREAM-514 and #OP-19618 (the CSP nonce consolidation, sibling work). The `turbo_power` allowlist in `setup.ts` is being addressed upstream via https://github.com/marcoroth/turbo\_power/pull/333
### Hints for QA
Changes are DX-focused. Does not need manual QA.