-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element.matches and pseudo-elements #185
Comments
I don't really understand the setup here. @tabatkins how can CSS just return a pseudo-element? The engine needs to have the context of a node or a set of nodes, no? |
The prose algorithm can return pseudos, because the result might be used by further prose algorithms that understand pseudo-elements. Obviously there's not currently any way to surface pseudo-elements in JS. |
Don't you need to have a node and a pseudo? It seems like you're assuming the node tree and the layout tree are intertwined, which would be weird. |
@tabatkins ping. |
Augh, I didn't pay enough attention to the OP here anyway. Wrt the OP,
|
How can it return a pseudo-element though? Does that carry a pointer to the element? |
Yes, pseudo-elements (the spec concept) have a pointer to their originating element. If/when we expose pseudo-elements to JS, they'll similarly have a parentElement attribute. |
Thanks, and the pseudo-element gets returned because the selector was parsed successfully and it is the last thing in the list? No out-of-band information involved? |
Your first question confuses me a little bit - the pseudo-element gets returned because that's what the selector selects. Unclear what out-of-band information you could be talking about. |
I'm wondering if we're on the same page that the input to the algorithm is the selector and the node tree only. |
Yes, that's it. But the output isn't restricted to things from the node tree (it's nodes + pseudo-elements). |
I still don't understand why it would default to allowing all pseudo-elements. This algorithm is specifically designed for Does it have any invocations other than those two APIs? |
@tabatkins ping. |
https://dom.spec.whatwg.org/#dom-element-matches links to https://drafts.csswg.org/selectors-4/#match-a-selector-against-an-element which links to https://drafts.csswg.org/selectors-4/#evaluate-a-selector which says:
As far as I understand, "allowing all pseudo-elements" means that pseudo-elements are effectively ignored during matching. For example,
document.body.matches('body::after')
should returntrue
. This seems backwards, and indeed Firefox 44 and Chromium 49 both returnfalse
.The DOM spec should probably add “with an empty list of pseudo-elements” near “the result of match a selector against an element”.
Other Selectors-related APIs likely have similar issues.
The text was updated successfully, but these errors were encountered: