NOTE: AI-assisted issue!

Problem

When `custom_elements.settings.default_render_variant` is configured to a preview variant (e.g. `preview:nuxt`), rendering an element as the **markup** variant produces broken output if it contains nested `CustomElement` slots: `custom_elements_prepare_slots_as_vue_3()` and `custom_elements_prepare_slots_as_web_component()` call `$element->toRenderArray()` on nested slot elements **without an argument**, which re-resolves the configured default render variant. The nested elements then render as preview containers inside the parent's markup — a broken hybrid. For the `vue-3` markup style the preview containers land inside the parent's `` tags, whose content is inert (never displayed, not reachable by the preview JS), so the nested content disappears completely.

Steps to reproduce

1. Set `default_render_variant` to a preview variant (e.g. `preview:markup`) in the custom elements settings.
2. Build a `CustomElement` with another `CustomElement` in a slot and render it as markup: `$parent->toRenderArray('markup')` (or anything hard-wiring `#theme => custom_element`), on a regular (non-API) request.
3. The nested element renders as a preview container instead of markup; with `markup_style: vue-3` it is swallowed entirely by the inert `` wrapper.

Proposed resolution

pass through the 'markup' slot style.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fago created an issue. See original summary.

fago’s picture

Issue summary: View changes

fago’s picture

Status: Active » Needs review

  • fago committed 3f79428f on 3.x
    fix: #3598522 fix markup rendering of nested slot elements when preview...
fago’s picture

Status: Needs review » Fixed

tested successfully + fix comes with test coverage. merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.