Skip to content
Snippets Groups Projects
Commit 3496b2a6 authored by Shibin Das's avatar Shibin Das
Browse files

Issue #3467523: Render <source/> and <img/> as a void element without content

parent 8c96f580
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,20 @@ class ImgElement extends ElementBase {
*/
protected ?string $title = NULL;
/**
* Generates Drupal Render array for printing the Html Element.
*/
public function render(): array {
return [
'#type' => 'inline_template',
'#template' => '<{{ tag_name }} {{ attributes }} />',
'#context' => [
'tag_name' => $this->getTagName(),
'attributes' => $this->getAttribute(),
],
];
}
/**
* {@inheritDoc}
*/
......
......@@ -44,6 +44,20 @@ class SourceElement extends ElementBase {
*/
protected array $srcset = [];
/**
* Generates Drupal Render array for printing the Html Element.
*/
public function render(): array {
return [
'#type' => 'inline_template',
'#template' => '<{{ tag_name }} {{ attributes }} />',
'#context' => [
'tag_name' => $this->getTagName(),
'attributes' => $this->getAttribute(),
],
];
}
/**
* {@inheritDoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment