javascript where does id element +source exist
In javascript I want to find the SOURCE code that created the element. I have a variable that might be created in one of several places. The web page is dynamically modified via ajax calls. During debug I want to ask the question "where did you originate"?
Is there a function like that? Can I create one easily? If not, would it be worthy of the Firefox team?
Tutte le risposte (7)
Try to ask advice at the Stack Overflow forum site.
Unfortunately, that information -- "how exactly did this element get added to the DOM" -- is not part of the DOM itself, so I can't think of any place to access it.
It would be interesting to try to create such a feature. If I were to inject a Mutation Observer into the document to take some action every time an element were added to the DOM, I don't know how my script could determine what line in what script just did that. Looking at it from the other perspective, could the debugger be persuaded to log the relevant details each time it added an element to the DOM? This probably exists in some debugger somewhere and probably could be brought to Firefox, but... not by me.
You would probably need a full stack trace to be able to see what JavaScript code got executed and what parameters were used. This would involve a very large amount of data and thus would slow down Firefox in such a way that it wouldn't be usable.
jscher2000,
How about an approach where the element(s) are identified in advance? In other words, I want to know the instance source of foobar so when the various sources are processed just id/name=foobar have supplemented code generated. At execution time the extra code reports on the origin source, perhaps in a user designated variable.
It's not uncommon to set a watch in a debugger, but the details are beyond my expertise.
The debugger would not meet my application needs since the program would be in production.
I suppose I'm just going to need to give up on this feature request for now.
I'll find a different way.
I'm not sure you should give up just yet... This support forum is not a place to get features added to Firefox; at most we can describe what's available now, what we know to be coming, the add-ons we know about, and ideas we might have. You could take your request to either or both of the following:
- Dev Tools Forum: https://discourse.mozilla-community.org/c/devtools
- Mailing List: https://lists.mozilla.org/listinfo/dev-developer-tools