mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
ipl\BaseElement: implement generic void element...
...support fixes #999
This commit is contained in:
parent
15e87a15bb
commit
4ced1137cd
29
library/vendor/ipl/Html/BaseElement.php
vendored
29
library/vendor/ipl/Html/BaseElement.php
vendored
@ -13,6 +13,23 @@ abstract class BaseElement extends Html
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $tag;
|
protected $tag;
|
||||||
|
|
||||||
|
protected static $voidElements = [
|
||||||
|
'area',
|
||||||
|
'base',
|
||||||
|
'br',
|
||||||
|
'col',
|
||||||
|
'embed',
|
||||||
|
'hr',
|
||||||
|
'img',
|
||||||
|
'input',
|
||||||
|
'link',
|
||||||
|
'meta',
|
||||||
|
'param',
|
||||||
|
'source',
|
||||||
|
'track',
|
||||||
|
'wbr'
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Attributes
|
* @return Attributes
|
||||||
*/
|
*/
|
||||||
@ -98,7 +115,7 @@ abstract class BaseElement extends Html
|
|||||||
$tag = $this->getTag();
|
$tag = $this->getTag();
|
||||||
$this->assemble();
|
$this->assemble();
|
||||||
$content = $this->renderContent();
|
$content = $this->renderContent();
|
||||||
if (strlen($content) || $this->forcesClosingTag()) {
|
if (strlen($content) || $this->wantsClosingTag()) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<%s%s>%s</%s>',
|
'<%s%s>%s</%s>',
|
||||||
$tag,
|
$tag,
|
||||||
@ -115,9 +132,15 @@ abstract class BaseElement extends Html
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function forcesClosingTag()
|
public function wantsClosingTag()
|
||||||
{
|
{
|
||||||
return false;
|
// TODO: There is more. SVG and MathML namespaces
|
||||||
|
return ! $this->isVoidElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isVoidElement()
|
||||||
|
{
|
||||||
|
return in_array($this->tag, self::$voidElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
5
library/vendor/ipl/Html/Icon.php
vendored
5
library/vendor/ipl/Html/Icon.php
vendored
@ -22,9 +22,4 @@ class Icon extends BaseElement
|
|||||||
{
|
{
|
||||||
return new static($name, $attributes);
|
return new static($name, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function forcesClosingTag()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user