nl_tokens: Get an attribute object from a string selector
pl_tokens: function getAttributesFromSelector ( sel , existingAttributes ) { // For example: // '.test' to { class: 'test' } // '#test' to { id: 'test' } // '[data-test="test"]' to { 'data-test': 'test' } if ( ! is$1 . string ( sel ) || is$1 . empty ( sel ) ) { return { } ; } var attributes = { } ; var <mask> = extend ( { } , existingAttributes ) ; sel . split ( ',' ) . forEach ( function ( s ) { // Remove whitespace var selector = s . trim ( ) ; var className = selector . replace ( '.' , '' ) ; var stripped = selector . replace ( / [[\]] / g , '' ) ; // Get the parts and value var parts = stripped . split ( '=' ) ; var _parts = _slicedToArray ( parts , 1 ) , key = _parts [ 0 ] ; var value = parts . length > 1 ? parts [ 1 ] . replace ( / ["'] / g , '' ) : '' ; // Get the first character var start = selector . charAt ( 0 ) ; switch ( start ) { case '.' : // Add to existing classname if ( is$1 . string ( existing . class ) ) { attributes . class = "" . concat ( existing . class , " " ) . concat ( className ) ; } else { attributes . class = className ; } break ; case '#' : // ID selector attributes . id = selector . replace ( '#' , '' ) ; break ; case '[' : // Attribute selector attributes [ key ] = value ; break ; default : break ; } } ) ; return extend ( existing , attributes ) ; }