JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://raw.githack.com/eneko89/merged-hover-events/master/index.js"></script>
<div class="group1" id="elem1"></div>
<div class="group1" id="elem2"></div>

<div class="group2" id="elem3"></div>
<div class="group2" id="elem4"></div>

<div class="group3" id="elem5"></div>
<div class="group3" id="elem6"></div>

<div class="allGroups" id="commonElem"></div>

CSS

body {
  line-height: 0;
}

div {
  width: 60px;
  height: 30px;
  display: inline-block;
  margin: 10px;
  margin-bottom: 0;
  border: 1px solid white;
}

.group1 {
  background-color: black;
}

.group2 {
  background-color: red;
}

.group3 {
  background-color: green;
}

#elem2, #elem4, #elem6 {
  margin-left: -14px;
}

#commonElem {
  position: relative;
  background-color: blue;
  display: block;
  width: 418px;
  margin-top: 0;
}

JavaScript

var commonElem = document.getElementById('commonElem');

var group1 = [document.getElementById('elem1'),
							document.getElementById('elem2'),
              commonElem],
		group2 = [document.getElementById('elem3'),
							document.getElementById('elem4'),
              commonElem],
    group3 = [document.getElementById('elem5'),
							document.getElementById('elem6'),
              commonElem];

var groups = [group1, group2, group3];

function onEnter(event) {
	console.log('Entered', event.srcElement.className);
}

function onLeave(event) {
	console.log('Left', event.srcElement.className);
  console.log('');
}

/* Try switching 'exclusive' parameter.
 *
 * The enabled 'exclusive' param makes multiple element groups not
 * hoverable simultaneously. This means that in groups with elems
 * in common, it won't notify all groups when entering or leaving
 * the common element; it will only notify the one defined in the
 * first place (in this case, 'group1').
 */
for (var i = 0; i < groups.length; i++) {
  mergedHoverEvents(groups[i], onEnter, onLeave);
  //mergedHoverEvents(groups[i], onEnter, onLeave, true);
}