diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-01 19:56:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-01 20:17:15 +0200 |
commit | c953103d2fb7ecf838e853387c4b466381037f72 (patch) | |
tree | 4fca7fa6150f3bfbcdf10b923dff4fd4856e714b /Userland | |
parent | 918b0b43948f92ef70d8d3107b21a3e087548fad (diff) | |
download | serenity-c953103d2fb7ecf838e853387c4b466381037f72.zip |
LibWeb: Make CSSStyleDeclaration support both dashed-name and camelCase
Turns out we need to support *both* of these styles since there's
content that uses one or both of these.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp index 7c63c0dc23..ccdb1ab932 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp @@ -10,19 +10,29 @@ namespace Web::Bindings { +static CSS::PropertyID property_id_from_name(StringView name) +{ + if (auto property_id = CSS::property_id_from_camel_case_string(name); property_id != CSS::PropertyID::Invalid) + return property_id; + + if (auto property_id = CSS::property_id_from_string(name); property_id != CSS::PropertyID::Invalid) + return property_id; + + return CSS::PropertyID::Invalid; +} + JS::ThrowCompletionOr<bool> CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyName const& name) const { if (!name.is_string()) return Base::internal_has_property(name); - auto property_id = CSS::property_id_from_camel_case_string(name.to_string()); - return property_id != CSS::PropertyID::Invalid; + return property_id_from_name(name.to_string()) != CSS::PropertyID::Invalid; } JS::ThrowCompletionOr<JS::Value> CSSStyleDeclarationWrapper::internal_get(JS::PropertyName const& name, JS::Value receiver) const { if (!name.is_string()) return Base::internal_get(name, receiver); - auto property_id = CSS::property_id_from_camel_case_string(name.to_string()); + auto property_id = property_id_from_name(name.to_string()); if (property_id == CSS::PropertyID::Invalid) return Base::internal_get(name, receiver); if (auto maybe_property = impl().property(property_id); maybe_property.has_value()) @@ -34,7 +44,7 @@ JS::ThrowCompletionOr<bool> CSSStyleDeclarationWrapper::internal_set(JS::Propert { if (!name.is_string()) return Base::internal_set(name, value, receiver); - auto property_id = CSS::property_id_from_camel_case_string(name.to_string()); + auto property_id = property_id_from_name(name.to_string()); if (property_id == CSS::PropertyID::Invalid) return Base::internal_set(name, value, receiver); |