Ticket #11253 (closed bug: duplicate)
:parent selector description is unclear/misleading
|Reported by:||Chealer||Owned by:|
The description of the :parent selector reads: Select all elements that are the parent of another element, including text nodes.
Suppose you have: <div> <p id="secret">jQuery is evil!</p> </div>
It is not clear what jQuery("p:parent") matches. Does it match the div, i.e. the paragraph's parent? Or does it match the paragraph?
The answer is that :parent matches the paragraph. This can be deducted from observation of other selector constructs and the realization that a selector doing the former would be :parent(p), but this is far from obvious. It is not clear that :parent means "is a parent", but not "the parent of". Some have even suggested to rename the selector in the documentation comments. I don't know if this is desirable, but kk and Jakub Konecki suggested ":hasChild" and ":isParent". I did find it very surprising to read that ":parent"'s opposite was ":empty".
Furthermore, the current description implies that text nodes are elements, which is misleading.
A description which would fix both issues would be: Select all elements that have a child node (either an element or text).
- Keywords needsdocs added
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to selector