mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
LibWeb/CSS: Check for matching custom properties on parent elements
Previously, we were only checking the current element and not the parents in `ResolvedCSSStyleDeclaration::custom_property()` which wasn't correct.
This commit is contained in:
parent
00f6a2b744
commit
e4dc758343
Notes:
github-actions[bot]
2024-11-21 23:33:10 +00:00
Author: https://github.com/rmg-x
Commit: e4dc758343
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2494
3 changed files with 24 additions and 1 deletions
|
@ -604,7 +604,16 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
|
||||||
Optional<StyleProperty> ResolvedCSSStyleDeclaration::custom_property(FlyString const& name) const
|
Optional<StyleProperty> ResolvedCSSStyleDeclaration::custom_property(FlyString const& name) const
|
||||||
{
|
{
|
||||||
const_cast<DOM::Document&>(m_element->document()).update_style();
|
const_cast<DOM::Document&>(m_element->document()).update_style();
|
||||||
return m_element->custom_properties(m_pseudo_element).get(name);
|
|
||||||
|
auto const* element_to_check = m_element.ptr();
|
||||||
|
while (element_to_check) {
|
||||||
|
if (auto property = element_to_check->custom_properties(m_pseudo_element).get(name); property.has_value())
|
||||||
|
return *property;
|
||||||
|
|
||||||
|
element_to_check = element_to_check->parent_element();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
static WebIDL::ExceptionOr<void> cannot_modify_computed_property_error(JS::Realm& realm)
|
static WebIDL::ExceptionOr<void> cannot_modify_computed_property_error(JS::Realm& realm)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
PASS: #19db6e
|
13
Tests/LibWeb/Text/input/custom-property-from-parent.html
Normal file
13
Tests/LibWeb/Text/input/custom-property-from-parent.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--my-background-color: #19db6e;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const style = getComputedStyle(document.body);
|
||||||
|
println(`PASS: ${style.getPropertyValue("--my-background-color")}`);
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue