Accepted answer

You cannot use the solution proposed in the page you linked because SVG does not support element.offsetTop.

An easy alternative is using the property top of Element.getBoundingClientRect():

const svg ="svg");
const offset = svg.node().getBoundingClientRect().top;

<script src=""></script>
<img width="600" height="600"/>
<svg width="1500" height="650"/>

If you still want to use offsetTop, wrap the SVG in an HTML container, like a <div>:

const svg ="svg");
const offset = svg.node().parentNode.offsetTop;

<script src=""></script>
<img width="600" height="600" />
  <svg width="1500" height="650" />

Related Query