Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent #23

Closed
ioRekz opened this issue Mar 19, 2015 · 7 comments
Closed

Parent #23

ioRekz opened this issue Mar 19, 2015 · 7 comments

Comments

@ioRekz
Copy link

ioRekz commented Mar 19, 2015

Is there a way to do like a jquery .parent() ?

@davidsantiago
Copy link
Collaborator

I don't know jquery. What does that do?

@ioRekz
Copy link
Author

ioRekz commented Mar 19, 2015

Of course. When selecting a node in the tree. You can call parent on it and get its parent.
I have a use case is the page I try to get data from where one deep node got a class I can lookup but not the "parent" I want to. So I need to go down to this element and get the ascendant

@davidsantiago
Copy link
Collaborator

Oh, OK, I see. You can absolutely do this.

Normally the select function returns a list of nodes, but you can also get a list of zipper-locs instead. You can do that by calling select-locs instead of select. Then each item in the vector that is returned by select-locs will be a zipper, usable with all of the tree navigation functions of clojure.zip. So you'd call select-locs, instead of select, and then use clojure.zip/up on each of those to get their parents. As with any zipper, you'd want to call clojure.zip/node to get the node that you can examine before looking at it.

@vspinu
Copy link

vspinu commented Jul 1, 2016

Any news on this? You can do all other directions, child, follow and precede, but not parent. So you can currently get both A and C in (A B C) but only C in (A (B (C))).

@davidsantiago
Copy link
Collaborator

Are you asking about a selector function? Doesn't the has-child selector do what you want?

@vspinu
Copy link

vspinu commented Jul 1, 2016

Right. That's exactly what I was looking for. Don't understand how I missed it in the docs. Thanks!!!

@port19x
Copy link
Contributor

port19x commented Apr 11, 2023

Closing in favor of #40

@port19x port19x closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants