You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[cssom-1] Expected error type when trying to insert an invalid rule in a grouping rule #14537
If you try to insert @top-left or @annotation (valid only in @page or @font-feature-values) in a style sheet or a grouping rule (e.g. @media), Chrome and Firefox throw a SyntaxError. I do no think there is a related WPT test for this.
But if you try to insert @namespace or @import (valid only at the top-level) in a grouping rule, they throw a HierarchyRequestError. There is this WPT test for this.
I also note that if you try to insert any other rule than a page margin rule in @page (which is a grouping rule), Chrome throws a SyntaxError while Firefox throws a HierarchyRequestError.
At first glance, HierarchyRequestError seems well-suited when trying to insert @import, @namespace, or @layer, following some other rules. Based on the underlying algorithms for .insertRule(), a SyntaxError must be thrown when the result from parse a rule is a "syntax error". The parsing algorithms defined in CSS Syntax have become context-sensitive since the introduction of nested style rules. Therefore, they should now identify these rules as a syntax error, assuming the context is defined by any ancestor or sibling rule (or the style sheet). And HierarchyRequestError can no longer be thrown.
Activity