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

ast convertors #21

Open
idoros opened this issue Jul 13, 2021 · 0 comments
Open

ast convertors #21

idoros opened this issue Jul 13, 2021 · 0 comments
Labels

Comments

@idoros
Copy link
Collaborator

idoros commented Jul 13, 2021

When transforming ast it is sometimes easier to perform mutable changes converting one type of node into another. It would be helpful to provide convert functions like:

function convertToClass(node: SelectorNode, options: {preserveNodes?: boolean}) {
    const castNode = node as Class;
    castNode.type = `class`;
    if(options.preserveNodes) {
        delete castNode.nodes;
    }
    castNode.dotComments = [];
    return castNode;
}
@idoros idoros added enhancement New feature or request css-selector-parser labels Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant