src/lib/entity.js
function getUniqueId(baseId) {
  if (!document.getElementById(baseId)) {
    return baseId;
  }

  var i = 2;
  // If the baseId ends with _#, it extracts the baseId removing the suffix
  var groups = baseId.match(/(\w+)-(\d+)/);
  if (groups) {
    baseId = groups[1];
    i = groups[2];
  }

  while (document.getElementById(baseId + '-' + i)) {
    i++;
  }

  return baseId + '-' + i;
}
function getUniqueId(baseId) {
  if (!document.getElementById(baseId)) {
    return baseId;
  }

  var i = 2;
  // If the baseId ends with _#, it extracts the baseId removing the suffix
  var groups = baseId.match(/(\w+)-(\d+)/);
  if (groups) {
    baseId = groups[1];
    i = groups[2];
  }

  while (document.getElementById(baseId + '-' + i)) {
    i++;
  }

  return baseId + '-' + i;
}
function getUniqueId ( baseId ) { if ( ! document . getElementById ( baseId ) ) { return baseId ; } var i = 2 ; // If the baseId ends with _#, it extracts the baseId removing the suffix var groups = baseId . match ( / (\w+)-(\d+) / ) ; if ( groups ) { baseId = groups [ 1 ] ; i = groups [ 2 ] ; } while ( document . getElementById ( baseId + '-' + i ) ) { i ++ ; } return baseId + '-' + i ; }
Detect element's Id collision and returns a valid one
@param  {string} baseId Proposed Id
@return {string}        Valid Id based on the proposed Id
Detect element s Id collision and returns a valid one