1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 05:32:13 +00:00

LibWeb: Implement CSSStyleDeclaration.getPropertyValue(property)

This commit is contained in:
Andreas Kling 2021-09-12 20:44:17 +02:00
parent a72fd78713
commit a2f5589d3a
3 changed files with 15 additions and 0 deletions

View file

@ -91,4 +91,15 @@ bool PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, Str
return true;
}
String CSSStyleDeclaration::get_property_value(StringView property_name) const
{
auto property_id = property_id_from_string(property_name);
if (property_id == CSS::PropertyID::Invalid)
return {};
auto maybe_property = property(property_id);
if (!maybe_property.has_value())
return {};
return maybe_property->value->to_string();
}
}

View file

@ -34,6 +34,8 @@ public:
virtual Optional<StyleProperty> property(PropertyID) const = 0;
virtual bool set_property(PropertyID, StringView css_text) = 0;
String get_property_value(StringView property) const;
protected:
CSSStyleDeclaration() { }
};

View file

@ -4,4 +4,6 @@ interface CSSStyleDeclaration {
readonly attribute unsigned long length;
CSSOMString item(unsigned long index);
CSSOMString getPropertyValue(CSSOMString property);
};