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 [email protected]
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