LibWeb/CSS: Parse nested declarations in insert_a_css_rule()

The spec algorithm changed at some point to support nested declarations,
but I only just noticed. The subtest regression is one we were passing
incorrectly.
This commit is contained in:
Sam Atkins 2025-04-14 15:36:42 +01:00
parent fa8bbfa6a5
commit 3d1665cc80
Notes: github-actions[bot] 2025-04-23 10:40:15 +00:00
4 changed files with 40 additions and 20 deletions

View file

@ -41,10 +41,14 @@ void CSSGroupingRule::clear_caches()
rule->clear_caches();
}
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-insertrule
WebIDL::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
{
TRY(m_rules->insert_a_css_rule(rule, index));
// NOTE: The spec doesn't say where to set the parent rule, so we'll do it here.
// The insertRule(rule, index) method must return the result of invoking insert a CSS rule rule into the child CSS
// rules at index, with the nested flag set.
TRY(m_rules->insert_a_css_rule(rule, index, CSSRuleList::Nested::Yes));
// AD-HOC: The spec doesn't say where to set the parent rule, so we'll do it here.
m_rules->item(index)->set_parent_rule(this);
return index;
}