- Fixed invalid elements after testing
This commit is contained in:
1 parent
a0bf505377
commit
4bf08def27
5 files changed
+73
-68
No files matched your search
+16
-16
@@ -23,7 +23,7 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
*
|
||||
* key value uses
|
||||
* --------------------------------------------------------------------------------------------
|
||||
* single-tag Only render a single tag. Cannot contains any childrens
|
||||
* tag-type single Only render a single tag. Cannot contains any childrens
|
||||
* force-tag-open tag Control the way the opening tag is rendered
|
||||
* force-tag-close tag-close " " " " closing " " "
|
||||
* no-attr Attributes will not be rendered
|
||||
@@ -35,7 +35,7 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
|
||||
public $selected = null;
|
||||
|
||||
public string $content;
|
||||
public string $content = "";
|
||||
|
||||
protected ?UiQuery $kwery = null;
|
||||
|
||||
@@ -150,8 +150,7 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
public function render() {
|
||||
$attributesList = [];
|
||||
|
||||
foreach ( $this->attr as $key => $value ) {
|
||||
|
||||
foreach ( $this->attributes as $key => $value ) {
|
||||
if ( is_array($value) ) {
|
||||
if (empty($value)) continue;
|
||||
|
||||
@@ -163,12 +162,12 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
}
|
||||
|
||||
$attributesList[] = "$key=\"".implode(';', $style).'"';
|
||||
|
||||
}
|
||||
else {
|
||||
$attributesList[] = implode(' ', $value);
|
||||
}
|
||||
}else if ( !is_numeric($key) ) {
|
||||
}
|
||||
else if ( !is_numeric($key) ) {
|
||||
# will output something like <tag $key=$value></tag>
|
||||
$attributesList[] = "$key=\"$value\"";
|
||||
}
|
||||
@@ -190,30 +189,30 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->options->exist('no-tag') ) {
|
||||
if ( in_array('no-tag', $this->options) ) {
|
||||
return $this->content . $content;
|
||||
}
|
||||
else {
|
||||
$attributesstr = (count($attributesList) && !$this->options->exist('no-attr') ? " " . implode($attributesList, " ") : "");
|
||||
$attributesstr = (count($attributesList) && ! in_array('no-attr', $this->options) ? " " . implode(" ", $attributesList) : "");
|
||||
|
||||
# Force the node to contain a certain opening tag (php is a good example)
|
||||
if ( $this->options->exist('force-tag-open') ) {
|
||||
if ( in_array('force-tag-open', $this->options) ) {
|
||||
$opentag = $this->options['force-tag-open'] . $attributesstr;
|
||||
}
|
||||
else {
|
||||
$opentag = $this->tag ? "<{$this->tag}" . $attributesstr . ">" : "";
|
||||
}
|
||||
|
||||
if ( $this->options->exist('tag-type') ) {
|
||||
if ( $this->options['tag-type'] ?? false ) {
|
||||
if ( $this->options['tag-type'] === "single" ) {
|
||||
return $opentag;
|
||||
}
|
||||
}
|
||||
else if ( $this->options->exist('force-tag-close') ) {
|
||||
else if ( in_array('force-tag-close', $this->options) ) {
|
||||
$closetag = $this->options['force-tag-close'];
|
||||
}
|
||||
else {
|
||||
$closetag = $this->tag ? "<" . ($this->options->exist('escape-tag-end') ? "\/" : "/" ) . "{$this->tag}>" : "";
|
||||
$closetag = $this->tag ? "<" . (in_array('escape-tag-end', $this->options) ? "\/" : "/" ) . "{$this->tag}>" : "";
|
||||
}
|
||||
|
||||
return $opentag . $this->content . $content . $closetag;
|
||||
@@ -290,8 +289,8 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
public function attributes(array $attributes) : self
|
||||
{
|
||||
foreach($attributes as $key => $value) {
|
||||
switch($key) {
|
||||
case 'class' :
|
||||
switch ((string) $key) {
|
||||
case 'class':
|
||||
$this->addClass($value);
|
||||
break;
|
||||
|
||||
@@ -308,8 +307,9 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable {
|
||||
elseif ( is_array($this->attributes[$key] ?? false) ) {
|
||||
$this->attributes[$key] = array_replace($value, $this->attributes[$key]);
|
||||
}
|
||||
|
||||
$this->attributes[$key] = $value;
|
||||
else {
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user