Problem

When an empty slot is output in explicit json, it ends up:

              "slots": {
                  "default": {
                      "element": "div"
                  }
              }

Proposed resolution

When there is nothing in the slot, it's an empty element, and the empty element is called div (default), do not output it

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

Implicit output has that:

    // Special handling for "div" and "span" elements in JSON output.
    // Those elements are used to wrap slot-content and should not be output as
    // separate elements in the JSON structure.
    // @todo Consider using renderless-container instead of div/span in
    // in slot-helper-methods of CustomElement class.
    if ($result['element'] == 'div' || $result['element'] == 'span') {
      unset($result['element']);
    }

In explicit output we are skipping special handling like this, still we don't want to have it as empty element.

fago’s picture

Status: Active » Needs review

fixed and added test

fago’s picture

Status: Needs review » Fixed

Merging with green pipeline!

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.

  • fago committed b200973c on 3.x
    fix: #3560572 Explicit output for empts slots is broken
    
    By: fago
    

Status: Fixed » Closed (fixed)

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