Skip to content

[css-cascade-6] Specificity of Implicitly-Added :scope in Scoped Rules #10196

Closed
@dshin-moz

Description

@dshin-moz

Current WPT test for scoped styles' specificity seems to assume that an unscoped rule has the same specificity as the identically written out scoped rule.
However, the spec's example seems to imply that :scope <descendant-combinator> is implicitly added, and that :scope's specificity is equal to that of other pseudo-classes (i.e. class-like +1).

WebKit and Blink are shipping the behaviour matching the WPT.

This leads to behaviours where functionally-identical selectors with explicitly-added :scope selector wins despite the ordering. In the example below, WebKit and Chrome both show .foo being purple:

<!doctype html>
<style>
.foo { color: green }
@scope (:root) {
  :scope .foo { color: purple }
  .foo { color: blue }
}
</style>
<div class="foo">Color?</div>

cc: @emilio, @mdubet, @andruud

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Tuesday afternoon

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions