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
Add path.getPrevSibling
, path.getNextSibling
, etc.
#5223
Comments
Hey @kangax! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
I like it! Names seem fine to me but maybe someone else has a better idea. We should just have something like jQuery haha https://api.jquery.com/category/traversing/tree-traversal/. |
Seems like a nice beginner-friendly task so I'm marking it as such. |
Yep! I'l update the issue for that stuff. If someone wants to chime in on a good name though.. |
@chitchu chaining would work automatically since the method will be defined on a path and will return another path (or |
@kangax I misunderstood what |
We have quite a few cases of
path.parentPath.getSibling(path.parentPath.key + 1)
in Babili's DCE.It would be nice if Babel provided basic traversal methods like
getPrevSibling()
,getNextSibling()
,forEachPrevSibling()
,forEachNextSibling()
, etc.Naming subject to change, of course.
EDIT by @hzoo
master
make build
after a source code change or better just runmake watch
in another terminal window to auto run babel while you are developing$("a").siblings
) but instead its an AST node sibling.babel-traverse/src/path/family.js
and add the methods shown above ^ https://github.com/babel/babel/blob/master/packages/babel-traverse/src/path/family.js#L60-L67The text was updated successfully, but these errors were encountered: