I want to know how to pinpoint the line/position of code which is altering a specific DOM element or it's style. With Chrome DOMListner I see which elements get changed and what is the change but I cannot figure out which line of script caused that DOM change.
Example jsfiddle
HTML
<div class="red circle absolute"></div>
CSS
body {
margin: 0;
padding: 0;
font-size: 10px;
}
.red {
background-color: #F44336;
/* Material design 500 tint Red color */
}
.circle {
height: 3em;
width: 3em;
border-radius: 50%;
}
.absolute {
position: absolute;
top: 0;
left: 0;
}
JS
document.onmousemove = function (e) {
// source: http://stackoverflow.com/questions/11245119/how-to-get-mouse-pointer-position-using-javascript-for-internet-explorer
// as on: 28.09.2015
var x = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
var y = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
var el = document.getElementsByTagName('div')[0];
el.style.left = (x - 15) + 'px';
el.style.top = (y - 15) + 'px';
}
jsfiddle shows a circle which follows the mouse cursor. Circle is positioned absolutely and onmousemove event triggers the change of circle position. This example is over-simplified and one can easily see where the top and left properties of a DOM element are changed.
I would like to find a method of finding the exact line/position of code for any JS script I stumble upon. Thanks