src/util.js
function selectorBlockHandler(element) {
    if (element.type === 'Selector') {
        const name = []
        let discard = false
        element.children.forEach(e => {
            switch (e.type) {
                case "ClassSelector":
                    name.push("." + e.name);
                    break;
                    //not support for now
                case "Combinator":
                    name.push(e.name);
                    discard = true
                    return null
                case "TypeSelector":
                    name.push(e.name);
                    break;
                case "IdSelector":
                    //not support for now
                    name.push("#" + e.name);
                    discard = true
                    return null
                case "WhiteSpace":
                    name.push(" ");
                    break
                default: {
                    // console.warn('unknown selector type:', e)
                    discard = true
                    return null
                }
            }
        })
        if (!discard)
            return name.join("")
        else return null
    }
}
function selectorBlockHandler(element) {
    if (element.type === 'Selector') {
        const name = []
        let discard = false
        element.children.forEach(e => {
            switch (e.type) {
                case "ClassSelector":
                    name.push("." + e.name);
                    break;
                    //not support for now
                case "Combinator":
                    name.push(e.name);
                    discard = true
                    return null
                case "TypeSelector":
                    name.push(e.name);
                    break;
                case "IdSelector":
                    //not support for now
                    name.push("#" + e.name);
                    discard = true
                    return null
                case "WhiteSpace":
                    name.push(" ");
                    break
                default: {
                    // console.warn('unknown selector type:', e)
                    discard = true
                    return null
                }
            }
        })
        if (!discard)
            return name.join("")
        else return null
    }
}
function selectorBlockHandler ( element ) { if ( element . type === 'Selector' ) { const name = [ ] let discard = false element . children . forEach ( e => { switch ( e . type ) { case "ClassSelector" : name . push ( "." + e . name ) ; break ; //not support for now case "Combinator" : name . push ( e . name ) ; discard = true return null case "TypeSelector" : name . push ( e . name ) ; break ; case "IdSelector" : //not support for now name . push ( "#" + e . name ) ; discard = true return null case "WhiteSpace" : name . push ( " " ) ; break default : { // console.warn('unknown selector type:', e) discard = true return null } } } ) if ( ! discard ) return name . join ( "" ) else return null } }
handle with selector part in node's structure
@param element node to be searched
@return {*}
handle with selector part in node s structure