mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Allow custom properties in getPropertyPriority()
This commit is contained in:
parent
ac5699c8fc
commit
41c172c663
Notes:
github-actions[bot]
2024-11-21 12:17:07 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/41c172c6630 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2460 Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 8 additions and 0 deletions
|
@ -318,6 +318,12 @@ StringView CSSStyleDeclaration::get_property_priority(StringView property_name)
|
||||||
auto property_id = property_id_from_string(property_name);
|
auto property_id = property_id_from_string(property_name);
|
||||||
if (!property_id.has_value())
|
if (!property_id.has_value())
|
||||||
return {};
|
return {};
|
||||||
|
if (property_id.value() == PropertyID::Custom) {
|
||||||
|
auto maybe_custom_property = custom_property(FlyString::from_utf8_without_validation(property_name.bytes()));
|
||||||
|
if (!maybe_custom_property.has_value())
|
||||||
|
return {};
|
||||||
|
return maybe_custom_property.value().important == Important::Yes ? "important"sv : ""sv;
|
||||||
|
}
|
||||||
auto maybe_property = property(property_id.value());
|
auto maybe_property = property(property_id.value());
|
||||||
if (!maybe_property.has_value())
|
if (!maybe_property.has_value())
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
style.getPropertyValue(--redcolor)=red
|
style.getPropertyValue(--redcolor)=red
|
||||||
|
style.getPropertyPriority(--redcolor)=
|
||||||
rgb(255, 0, 0)
|
rgb(255, 0, 0)
|
||||||
rgba(0, 0, 0, 0)
|
rgba(0, 0, 0, 0)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.style.setProperty("--redcolor", "red");
|
div.style.setProperty("--redcolor", "red");
|
||||||
println(`style.getPropertyValue(--redcolor)=${div.style.getPropertyValue("--redcolor")}`);
|
println(`style.getPropertyValue(--redcolor)=${div.style.getPropertyValue("--redcolor")}`);
|
||||||
|
println(`style.getPropertyPriority(--redcolor)=${div.style.getPropertyPriority("--redcolor")}`);
|
||||||
|
|
||||||
const nested = document.createElement('div');
|
const nested = document.createElement('div');
|
||||||
nested.style["backgroundColor"] = "var(--redcolor)";
|
nested.style["backgroundColor"] = "var(--redcolor)";
|
||||||
|
|
Loading…
Reference in a new issue