Skip to content

Commit 53db52c

Browse files
committed
Performance optimizations.
1 parent 4190c66 commit 53db52c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/HTMLServerComponent.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public function removeAttribute(string $name)
7676
*/
7777
public function __get($name)
7878
{
79-
return $this->getAttribute($name);
79+
$name = strtolower($name);
80+
return isset($this->attributes[$name]) ? (string) $this->attributes[$name] : null;
8081
}
8182

8283
/**
@@ -88,7 +89,7 @@ public function __get($name)
8889
*/
8990
public function __set(string $name, $value)
9091
{
91-
$this->setAttribute($name, $value);
92+
$this->attributes[strtolower($name)] = $value;
9293
}
9394

9495
/**
@@ -110,7 +111,10 @@ public function __isset(string $name): bool
110111
*/
111112
public function __unset(string $name)
112113
{
113-
$this->removeAttribute($name);
114+
$name = strtolower($name);
115+
if (isset($this->attributes[$name])) {
116+
unset($this->attributes[$name]);
117+
}
114118
}
115119

116120
/**
@@ -122,10 +126,7 @@ public function __toString(): string
122126
foreach ($this->attributes as $name => $value) {
123127
$html .= ' ' . $name . '="' . htmlspecialchars($value) . '"';
124128
}
125-
$html .= '>';
126-
$html .= $this->innerHTML;
127-
$html .= '</component>';
128-
return $html;
129+
return $html . '>' . $this->innerHTML . '</component>';
129130
}
130131

131132
}

0 commit comments

Comments
 (0)