Hittest on div
by dandclark_msft
HTML
<span>
<div contenteditable="true">abc</div>
</span>
<span>
<div contenteditable="true">abc</div>
</span>
<script>
Array.from(document.querySelectorAll("div,span"))
.forEach((e) => e.addEventListener("mousedown", (e) => console.log(`mousedown on ${e.target.tagName}`)));
</script>
CSS
span:nth-child(1) {
display: inline-block;
width: 300px;
height: 300px;
background-color: red;
}
span:nth-child(2) {
display: inline-grid;
width: 300px;
height: 300px;
background-color: blue;
grid-auto-rows: min-content;
}