mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibWeb: Cache the "id" attribute value on DOM::Element as FlyString
This will allow us to do O(1) checks against the element ID when matching selectors, etc.
This commit is contained in:
parent
6b580d68a3
commit
1c62ee9396
2 changed files with 10 additions and 1 deletions
|
@ -478,7 +478,12 @@ void Element::attribute_changed(FlyString const& name, Optional<DeprecatedString
|
|||
{
|
||||
auto value_or_empty = value.value_or("");
|
||||
|
||||
if (name == HTML::AttributeNames::class_) {
|
||||
if (name == HTML::AttributeNames::id) {
|
||||
if (!value.has_value())
|
||||
m_id = {};
|
||||
else
|
||||
m_id = MUST(FlyString::from_deprecated_fly_string(value_or_empty));
|
||||
} else if (name == HTML::AttributeNames::class_) {
|
||||
auto new_classes = value_or_empty.split_view(Infra::is_ascii_whitespace);
|
||||
m_classes.clear();
|
||||
m_classes.ensure_capacity(new_classes.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue