Bug Tracker

Opened 14 years ago

Closed 14 years ago

#3657 closed feature (invalid)

New feature: selfOrParents traversal function

Reported by: jollytoad Owned by:
Priority: minor Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: jollytoad
Blocked by: Blocking:

Description

I find it handy to be able to traverse using parents, but include the current context in the search, like the XPath ancestors-or-self axis.

It's very handy for this kind of thing:

if (!$(...).selfOrParents(':hidden').length) {

do something because we are visible

}

rather than having to do:

var tmp = $(...);

if (!(tmp.is(':hidden')
tmp.parents(':hidden').length)) { ... }

I've attached a patch, it's very small :)

Attachments (1)

selfOrParents.patch (1.0 KB) - added by jollytoad 14 years ago.

Download all attachments as: .zip

Change History (2)

Changed 14 years ago by jollytoad

Attachment: selfOrParents.patch added

comment:1 Changed 14 years ago by flesler

Cc: jollytoad added
Resolution: invalid
Status: newclosed

If I'm not wrong, that can be achieved with:

$(...).parents().andSelf().is(':hidden')

That seems to me like pretty much the same amount of code. So.. I think this is not really useful, generally speaking.

Note: See TracTickets for help on using tickets.