This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
ast utility function to create selector from passing a root and a leaf node. #2
Labels
🧘 status/waiting
This may go somewhere but needs more information
💬 type/discussion
This is a request for comments
it would be nice to have a utility to create a selector from a root.
E.g.
selectorFromTree(root, node); // returns html > body > div:nth-child(1) > h1
which in turn you could then use something like https://github.com/syntax-tree/hast-util-select
later to find that same node.
the use case I'm using this for is dragging and dropping AST Nodes in a tree and looking them up by paths for mutation of the AST.
CC: @wooorm
I would personally work on this, but I don't think I know enough about AST manipulation to write a helper like this efficiently.
The text was updated successfully, but these errors were encountered: