src/select.js
function getCommonSelectors (elements) {

  const { classes, attributes, tag } = getCommonProperties(elements)

  const selectorPath = []

  if (tag) {
    selectorPath.push(tag)
  }

  if (classes) {
    const classSelector = classes.map((name) => `.${name}`).join('')
    selectorPath.push(classSelector)
  }

  if (attributes) {
    const attributeSelector = Object.keys(attributes).reduce((parts, name) => {
      parts.push(`[${name}="${attributes[name]}"]`)
      return parts
    }, []).join('')
    selectorPath.push(attributeSelector)
  }

  if (selectorPath.length) {
    // TODO: check for parent-child relation
  }

  return [
    selectorPath.join('')
  ]
}
function getCommonSelectors (elements) {

  const { classes, attributes, tag } = getCommonProperties(elements)

  const selectorPath = []

  if (tag) {
    selectorPath.push(tag)
  }

  if (classes) {
    const classSelector = classes.map((name) => `.${name}`).join('')
    selectorPath.push(classSelector)
  }

  if (attributes) {
    const attributeSelector = Object.keys(attributes).reduce((parts, name) => {
      parts.push(`[${name}="${attributes[name]}"]`)
      return parts
    }, []).join('')
    selectorPath.push(attributeSelector)
  }

  if (selectorPath.length) {
    // TODO: check for parent-child relation
  }

  return [
    selectorPath.join('')
  ]
}
function getCommonSelectors ( elements ) { const { classes , attributes , tag } = getCommonProperties ( elements ) const selectorPath = [ ] if ( tag ) { selectorPath . push ( tag ) } if ( classes ) { const classSelector = classes . map ( ( name ) => ` ${ name } ` ) . join ( '' ) selectorPath . push ( classSelector ) } if ( attributes ) { const attributeSelector = Object . keys ( attributes ) . reduce ( ( parts , name ) => { parts . push ( ` ${ name } ${ attributes [ name ] } ` ) return parts } , [ ] ) . join ( '' ) selectorPath . push ( attributeSelector ) } if ( selectorPath . length ) { // TODO: check for parent-child relation } return [ selectorPath . join ( '' ) ] }
Get selectors to describe a set of elements

@param  {Array.<HTMLElements>} elements - [description]
@return {string}                        - [description]
Get selectors to describe a set of elements