0

This is mostly a question about debugging ... i have a very big JavaScript file, that somewhere inside it , it removes (empty()) a certain element. i tried to check that element for id , class in the JavaScript but couldn't find it so maybe is using some other selector based on some logic.

The question : is there a way to see where a certain element with an id , is removed / emptied by chrome and pause at that line ?

Or is there a feature regarding this matter if somebody else had the same problem in the past ?

4
  • 1
    May this will help you domManipulation Commented Sep 4, 2017 at 12:49
  • the thing is that ... this element is emptied once after the full dom loads .. so i can check it only on refresh ,.,.. Commented Sep 4, 2017 at 12:54
  • Place a break point on document ready or any other place before the DOM is emptied and then when paused add the DOM breakpoint. I also remember DOM Breakpoint is persisted across page refresh too. But not too sure. Commented Sep 4, 2017 at 13:02
  • i tried that and is not Commented Sep 4, 2017 at 13:05

2 Answers 2

1

You can set a breakpoint on DOM which would show the stack trace which modified the element.

To set a DOM change breakpoint:

  • Click the Elements tab in chrome developer tools.
  • Go the element that you want to set the breakpoint on.
  • Right-click the element. Hover over Break on then select Subtree modifications, Attribute modifications, or Node removal.

More Information : https://developers.google.com/web/tools/chrome-devtools/javascript/breakpoints#dom

Sign up to request clarification or add additional context in comments.

Comments

1

enter image description here

Add a breakpoint on the node removal option, it might help you

3 Comments

yes but when i refresh ... i cannot see them setup . i can only test on refresh
ok ... after refresh that breakpoint is still on .. but it does not break .. and clearly the node is emptied .. i can see content for a split second inside that div .. and if i manage to stop the browser right in time i can see all content
the breakpoint will only fire if the element is removed, try adding subtree modifications, that will watch through its childs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.