1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibWeb: Support CSSStyleDeclaration.getPropertyPriority()

This commit is contained in:
Andreas Kling 2022-04-11 20:48:50 +02:00
parent a8afb883c1
commit a0ba49a50a
3 changed files with 14 additions and 0 deletions

View file

@ -177,6 +177,18 @@ String CSSStyleDeclaration::get_property_value(StringView property_name) const
return maybe_property->value->to_string();
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertypriority
String CSSStyleDeclaration::get_property_priority(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->important == Important::Yes ? "important" : "";
}
DOM::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority)
{
auto property_id = property_id_from_string(property_name);

View file

@ -45,6 +45,7 @@ public:
DOM::ExceptionOr<String> remove_property(StringView property_name);
String get_property_value(StringView property) const;
String get_property_priority(StringView property) const;
String css_text() const;
void set_css_text(StringView);

View file

@ -5,6 +5,7 @@ interface CSSStyleDeclaration {
CSSOMString item(unsigned long index);
CSSOMString getPropertyValue(CSSOMString property);
CSSOMString getPropertyPriority(CSSOMString property);
[CEReactions] undefined setProperty(CSSOMString property, [LegacyNullToEmptyString] CSSOMString value, [LegacyNullToEmptyString] optional CSSOMString priority = "");
[CEReactions] CSSOMString removeProperty(CSSOMString property);