Skip to main content

Bug Tracker

Side navigation

#11253 closed bug (duplicate)

Opened January 29, 2012 05:32AM UTC

Closed August 29, 2012 05:05PM UTC

:parent selector description is unclear/misleading

Reported by: Chealer Owned by:
Priority: low Milestone: None
Component: selector Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

The description of the :parent selector reads:

Select all elements that are the parent of another element, including text nodes.

Suppose you have:


<p id="secret">jQuery is evil!</p>


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).

Attachments (0)
Change History (2)

Changed January 30, 2012 03:41AM UTC by timmywil comment:1

component: unfiledselector
keywords: → needsdocs
priority: undecidedlow
status: newopen


Changed August 29, 2012 05:05PM UTC by timmywil comment:2

keywords: needsdocs
resolution: → duplicate
status: openclosed