Skip to content
Snippets Groups Projects
Commit e32dfa2c authored by Roderik Muit's avatar Roderik Muit
Browse files

Issue #3473490 by fago: Fix JSON serialization of markup only slots

parent 071b0d9e
No related branches found
No related tags found
No related merge requests found
Pipeline #281440 passed with warnings
......@@ -4,7 +4,6 @@ namespace Drupal\custom_elements;
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Template\Attribute;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
......@@ -117,16 +116,12 @@ class CustomElementNormalizer implements NormalizerInterface {
// Handle slots set via nested custom element and markup.
if (!empty($slot['content']) && $slot['content'] instanceof CustomElement) {
$slot_data[$index] = $this->normalizeCustomElement($slot['content'], $cache_metadata);
// Remove possible doubled slot attributes.
unset($slot_data[$index]['slot']);
}
elseif ($slot['content'] instanceof MarkupInterface) {
$slot_data[$index]['content'] = (string) $slot['content'];
if (!empty($slot['attributes']) && $slot['attributes'] instanceof Attribute) {
$slot_data[$index] = array_merge($slot_data[$index], $slot['attributes']->toArray());
}
$slot_data[$index] = (string) $slot['content'];
}
// Remove possible doubled slot attributes.
unset($slot_data[$index]['slot']);
}
if ($element->hasSlotNormalizationStyle($slot_key, CustomElement::NORMALIZE_AS_SINGLE_VALUE)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment