setSlot() + addSlot() + output inconsistency

Created on 22 January 2025, 2 months ago

Problem/Motivation

Two things:

  1. $ce = CustomElement::create('MYTAG')
      ->setSlot('content', 'FIRST')
      ->addSlot('content', 'SECOND');
    

    sets slotNormalizationStyle NORMALIZE_AS_SINGLE_VALUE. (Specifically: a setSlot() call without $index parameter does this.)

  2. Rendering $ce as HTML produces
    <mytag><div slot="content">FIRST</div><div slot="content">SECOND</div></mytag>
    

    But normalizing JSON produces

    [ 'element' => 'mytag', 'content' => 'FIRST']
    

    In other words, the CustomElement::$slotNormalizationStyles property is only used for JSON output, not HTML.

Remaining tasks

Work out what we want to do with this.

  • Do we not care about the difference between outputs? Then document the fact that setSlotNormalizationStyle() does nothing for HTML. Otherwise fix?
  • Is it a known fact that a setSlot*() call without $index parameter 'breaks' subsequent addSlot*() calls for the same slot name but only for JSON, not HTML? Then document this.
  • ...

(CustomElement and set/addSlot() calls' documentation could use an overhaul/extension, apart from this. I'll later decide whether to do this in this same issue, or maybe file a followup, or maybe I will have already done that before this issue is addressed...)

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024