LibWeb: Add Optional<String> version of Element::attribute
As a non-deprecated alternative to DeprecatedString Element::attribute.
This commit is contained in:
parent
0f6782fae6
commit
6fb3586baa
Notes:
sideshowbarker
2024-07-17 03:10:07 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/6fb3586baa Pull-request: https://github.com/SerenityOS/serenity/pull/20926 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 8 additions and 0 deletions
|
@ -92,6 +92,14 @@ public:
|
|||
bool has_attributes() const;
|
||||
|
||||
DeprecatedString deprecated_attribute(DeprecatedFlyString const& name) const { return get_attribute(name); }
|
||||
Optional<String> attribute(DeprecatedFlyString const& name) const
|
||||
{
|
||||
auto ret = deprecated_attribute(name);
|
||||
if (ret.is_null())
|
||||
return {};
|
||||
return String::from_deprecated_string(ret).release_value();
|
||||
}
|
||||
|
||||
DeprecatedString get_attribute(DeprecatedFlyString const& name) const;
|
||||
DeprecatedString get_attribute_value(DeprecatedFlyString const& local_name, DeprecatedFlyString const& namespace_ = {}) const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue