🌐 AI搜索 & 代理 主页
Skip to content

Leverage the :scope pseudo-class instead of the ID hack where possible #4453

@mgol

Description

@mgol

Description

The :scope pseudo-class has surprisingly good browser support: Chrome, Firefox & Safari have supported if for a long time; only IE & Edge lack support. We could leverage this pseudo-class to get rid of the ID hack in most cases. Adding a temporary ID may cause layout thrashing which was reported a few times in the past.

We can't completely eliminate the ID hack in modern browses as sibling selectors require us to change context to the parent and then :scope stops applying to what we'd like. But it'd still improve performance in the vast majority of cases.

I've attached the 3.4.2 milestone as the patch seems simple enough that I'd like to backport it to Sizzle. It'd be a nice perf win in a patch release.

Link to test case

N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions