Reputation: 2281
I want to see what code is modifying a DOM element on a webpage, so I set a breakpoint in Chrome by right-clicking on the element in the Elements tab of the DevTools inspector and choosing "Break on..." -> "Subtree Modifications". The script modifies the element when the page is loaded (and not after), so I want to preserve the DOM breakpoint and refresh the page.
The process for saving breakpoints in javascript code doesn't seem to apply to DOM breakpoints.
Upvotes: 26
Views: 9767
Reputation: 620
I believe this didn't have a proper explanation for the answer because I face the issue as well. the steps goes as follows.
Upvotes: 7
Reputation: 150543
In Chrome, DOM breakpoints are not preserved upon refresh, they are thrown away, and then restored after the onload event. See bug report 571519, and this comment from that report:
We are preserving DOM breakpoints upon reload, but the breakpoints are only restored upon onload event. So if you expect breakpoint to trigger before that or it is set on a node that is added lazily, breakpoint is not restored. We should fix that though.
This is the workaround:
debugger;
line of JavascriptUpvotes: 11
Reputation: 2281
For now I added a debugger;
line before any other code runs, added a DOM breakpoint, and continued.
Upvotes: 15