mirror of
https://github.com/RGBCube/serenity
synced 2025-07-07 20:27:36 +00:00
LibWeb: Implement CSSStyleDeclaration.getPropertyValue(property)
This commit is contained in:
parent
a72fd78713
commit
a2f5589d3a
3 changed files with 15 additions and 0 deletions
|
@ -91,4 +91,15 @@ bool PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, Str
|
||||||
return true;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ public:
|
||||||
virtual Optional<StyleProperty> property(PropertyID) const = 0;
|
virtual Optional<StyleProperty> property(PropertyID) const = 0;
|
||||||
virtual bool set_property(PropertyID, StringView css_text) = 0;
|
virtual bool set_property(PropertyID, StringView css_text) = 0;
|
||||||
|
|
||||||
|
String get_property_value(StringView property) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CSSStyleDeclaration() { }
|
CSSStyleDeclaration() { }
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,4 +4,6 @@ interface CSSStyleDeclaration {
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
CSSOMString item(unsigned long index);
|
CSSOMString item(unsigned long index);
|
||||||
|
|
||||||
|
CSSOMString getPropertyValue(CSSOMString property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue