Skip to content
","upvoteCount":0,"url":"https://github.com/csstree/csstree/discussions/276#discussioncomment-10318745"}}}

Is there an option to truncate the ast generated? #276

Discussion options

You must be logged in to vote

I have figured it out! Thanks for the concern. Here is the code snippet in case you are wondering. :)

const validPseudo = new Set( [ 'not', 'hover', 'active', 'checked', 'focus', 'focus-visible', 'visited', 'focus-within', 'selection' ] );

// Traverse through all the Selectors.

csstree.walk(ast, {
    visit: 'Selector', enter(node, item, list) {

        // Flag to check if the selector has a Pseudo class.
        // Set to false at the start of traversing the Selector.

        let foundValidPseudo = false;
        let pseudoClass = null;

        // Traverse through all the nodes inside the Selector.

        csstree.walk(node, {
            enter(innerNode, item, list) {

           …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@fabianlawrence
Comment options

@fabianlawrence
Comment options

Answer selected by fabianlawrence
@bartveneman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants