Skip to content

Conversation

@connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Dec 15, 2021

Fixes #12001

Turns out that the order on the protocol for CSS.getMatchedStylesForNode is from least to most specific, so we don't need to calculate specificity ourselves. Only need to filter to the rules we care about (based on what properties they contain) and pick the last.

I don't think adding various tests in the smoke to really confirm this is too useful–we should just rely on it being a given, as DevTools depends on it. To confirm it works, I am first putting up a draft PR that keeps the current implementation and asserts when the simpler approach does not match. This should pass in all the simpler cases we already support, and only fail for the complex stuff we don't yet support. I ran it on cnn.com, theverge.com, and other big sites and got no errors. The smoke tests seo perf also still work.

@connorjclark connorjclark marked this pull request as ready for review November 18, 2022 21:45
@connorjclark connorjclark requested a review from a team as a code owner November 18, 2022 21:45
@connorjclark connorjclark requested review from brendankenny and removed request for a team November 18, 2022 21:45
@connorjclark
Copy link
Collaborator Author

I update this PR last week - should be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use universally correct CSS specificity

4 participants