mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb: Update CSSRule
parent style sheet whenever parent rule changes
This commit is contained in:
parent
f336667771
commit
89a08cb7cf
Notes:
github-actions[bot]
2025-06-23 14:22:43 +00:00
Author: https://github.com/Calme1709
Commit: 89a08cb7cf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5176
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 27 additions and 1 deletions
|
@ -53,6 +53,11 @@ void CSSRule::set_css_text(StringView)
|
|||
void CSSRule::set_parent_rule(CSSRule* parent_rule)
|
||||
{
|
||||
m_parent_rule = parent_rule;
|
||||
|
||||
if (parent_rule == nullptr)
|
||||
set_parent_style_sheet(nullptr);
|
||||
else
|
||||
set_parent_style_sheet(parent_rule->parent_style_sheet());
|
||||
clear_caches();
|
||||
}
|
||||
|
||||
|
|
|
@ -171,8 +171,8 @@ WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
|
|||
m_rules.remove(index);
|
||||
|
||||
// 6. Set old rule’s parent CSS rule and parent CSS style sheet to null.
|
||||
// NOTE: We set the parent stylesheet to null within set_parent_rule.
|
||||
old_rule.set_parent_rule(nullptr);
|
||||
old_rule.set_parent_style_sheet(nullptr);
|
||||
|
||||
if (on_change)
|
||||
on_change();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Pass!
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style id="style">
|
||||
@media all {
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const mediaRule = document.styleSheets[0].cssRules[0];
|
||||
mediaRule.insertRule("foobar {}", 0);
|
||||
|
||||
if (mediaRule.cssRules[0].parentStyleSheet === document.styleSheets[0]) {
|
||||
println("Pass!");
|
||||
} else {
|
||||
println("Fail!");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue