The :scope pseudo-class[1] has surprisingly good browser support: Chrome,
Firefox & Safari have supported if for a long time; only IE & Edge lack support.
This commit leverages 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.
The
:scope
pseudo-class[1] has surprisingly good browser support: Chrome, Firefox & Safari have supported if for a long time; only IE & Edge lack support. This commit leverages 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.[1] https://developer.mozilla.org/en-US/docs/Web/CSS/:scope
Fixes jquery/jquery#4453 Ref jquery/jquery#4454 Ref jquery/jquery#4332 Ref gh-405