Compute which JS selector will take priority

Viewed 52

Is it possible in JavaScript to check which element selector would take precedence in JavaScript, given a list of selectors?

For example, if I have the following two selectors:

selA: body.app > #container

selB: #container

Is it possible to check in JS which selector “applies more” to a given element? So far I have been doing the following to check if an element matches a selector:

el.matches(selA)

But I need to know which of the two selectors has a higher precedence/priority on this specific element (el). Is this possible to compute in JS?

1 Answers
Related