JSFiddle - React, Tailwind, and code Playground

HTML

<svg
   xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1"
   height="50" width="50">
   <rect id="rectRED"
	x="15" y="5" height="30" width="30"
        style="fill:#ff0000;fill-opacity:0.5;stroke:#000000;stroke-width:1.5" />
   <rect id="rectBLUE"
	x="5" y="15" height="30" width="30"
        style="fill:#0000ff;fill-opacity:0.5;stroke:#000000;stroke-width:1.5" />
</svg>

JavaScript

var elementsAt = function( x, y ){
     var elements = [], current = document.elementFromPoint( x, y );
    while( current &&  current.nearestViewportElement ){
        elements.push( current );
        current.style.display = "none";
        current = document.elementFromPoint( x, y );
    }
    elements.forEach( function( elm ){
       elm.style.display = ''; 
    });
    return elements;
}

console.log( elementsAt( 25, 25 ) );