Mark,
maybe I am just misunderstanding you, however my tip using CSS
selector groups (comma separated) is:

for the direct descendants

   descendant-or-self = "self > *, self"

for all the descendants

   descendants-or-self = "self *, self"

Both will get you a collection of descendant including the element
itself. For ancestors there isn't an equivalent CSS syntax that I am
aware of.

Hope you are missing one less now....

--
Diego


On 28 Nov, 15:34, Mark Gibson <[EMAIL PROTECTED]> wrote:
> For people who are familiar with XPath, I think it would be useful to
> list
> the similarities between XPath axes and jQuery selection/traversal
> methods,
> and also add any useful discrepancies into jQuery, or describe how to
> emulate
> them.
>
> This is my interpretation, additions would be most welcome, ideally
> I'd like
> to cover all the appropriate axes (not marked n/a).
>
> XPath Axis          jQuery
>
> ancestor            context.parents(...)
> ancestor-or-self    ?
> attribute           n/a
> child               context.children(...) or "context > ..." or $
> ("> ...", context)
> descendant          context.find(...) or "context ..." or $(...,
> context)
> descendant-or-self  ?
> following           ?
> following-sibling   context.nextAll(...) or "context ~ ..."?
> namespace           n/a
> parent              context.parent(...)
> preceding           ?
> preceding-sibling   context.prevAll(...) or "... + context"?
> self                context.filter(...) ???
>
> I've found a few situations where I've needed 'ancestor-or-self',
> 'following', and
> 'preceding' style selection, but not found any easy way to do it.
>
> For example, keyboard navigation of a tree (key up & down) would
> benefit
> greatly from the following and preceding axes.
>
> Finding descendants and including all the elements specified in an
> aria-owns
> attribute in the search would benefit from the descendant-or-self
> axis.
> (ie. find in the context element, and find-inc-self for all elements
> specified
> by the attribute)
>
> I know there is a .andSelf(), but I don't think it really cover these
> situations.
> Previously I've suggested a .selfOrParents() method, but I think a
> general
> 'include self' switch before a traversal method would be better:
>
> context.incSelf().find(...)
> context.incSelf().parents(...)
>
> Can the jQuery team see this as being generally useful, and accepted
> into the core?
> Or any alternative suggestions?
>
> Also, any suggestions on how to do following or preceding style
> selection?
>
> Cheers
> -Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to