I am working with multiple SVG path elements, each contained within a parent SVG element, structured like this:
<svg class="connector" style="position:absolute;left:277.5px;top:65px" position="absolute" pointer-events:"none" version="1.1" xmlns="http://www.w3.org/1999/xhtml" height="152.5px" width="410.015625px">
<path fill="none" stroke="#ff0000" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 310.015625 149.5 410.015625 149.5" id="path1"></path>
</svg>
<svg style="position:absolute;left:277.5px;top:109px" position="absolute" pointer-events:"none" version="1.1" xmlns="http://www.w3.org/1999/xhtml" height="108.5px" width="410.015625px">
<path fill="none" stroke="#880000" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 310.015625 105.5 410.015625 105.5" id="path2"></path>
</svg>
The issue I am facing is that the SVG elements and their child paths are visually overlapping.
To incorporate a hover effect, I have set up mouseenter and mouseleave events on each of the paths.
While the hover effect works as expected when the mouse is over areas that do not overlap, it fails to trigger correctly when the mouse is positioned on areas where the bounding rectangles of the SVG elements overlap.
However, when I combine the same two path elements into a single SVG, like shown below, the hover effect functions as expected even where the bounding rectangles overlap.
<svg class="connector" style="position:absolute;left:277.5px;top:265px" position="absolute" pointer-events:"none" version="1.1" xmlns="http://www.w3.org/1999/xhtml" height="152.5px" width="410.015625px">
<path fill="none" stroke="#00ff00" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 310.015625 149.5 410.015625 149.5" id="path3"></path>
<path fill="none" stroke="#008800" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 310.015625 105.5 410.015625 105.5" id="path4"></path>
</svg>
JSFiddle
For a demonstration of these two cases, you can visit this JSFiddle. In this example, the red lines are in separate SVG elements, while the green lines are within a single SVG element. The green lines exhibit the desired behavior, unlike the red lines.
Notes
The discrepancy in appearance of the paths is simply due to the different "top" attributes assigned to the two SVG elements in the initial example.
Although some similar queries suggest setting pointer-events, I believe I have configured them correctly (none on the SVG element, and visibleStroke on the paths).
Question
Is there a way to ensure that the mouse handling in the initial scenario, where two SVG elements are used, functions the same as when a single SVG element is employed?