1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 11:55:12 +00:00

LibWeb: Implement CSSStyleDeclaration.{set,remove}Property close to spec

We already had setProperty() but it was full of ad-hoc idiosyncracies.
This patch aligns setProperty() with the CSSOM spec and also implements
removeProperty() since that's actually needed by setProperty() now.

Some things fixed by this:
- We now support the "priority" parameter to setProperty()
- Element "style" attributes now update to reflect CSSOM mutations
This commit is contained in:
Andreas Kling 2022-04-11 16:10:55 +02:00
parent 9ad9c72827
commit 66618a666b
5 changed files with 134 additions and 26 deletions

View file

@ -800,9 +800,18 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
};
}
bool ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView)
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
DOM::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView)
{
return false;
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return DOM::NoModificationAllowedError::create("Cannot modify properties in result of getComputedStyle()");
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
DOM::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return DOM::NoModificationAllowedError::create("Cannot remove properties from result of getComputedStyle()");
}
String ResolvedCSSStyleDeclaration::serialized() const