Is it possible to detect when an inline style property was set?

喜欢而已 提交于 2019-12-12 01:34:15

问题


I have a bug where a certain div is having its style.height property being set to 0px by Javascript but I have no idea what code is doing this unwanted setting.

Is there to tell the debugger to halt execution when the inline height property is set or for me to at least have an event fire when this occurs?

The problem is occurring in a thorny inner loop and I don't want to have to do a manual "binary search" unless I really have to. (Specially since there is a chance that the culprit code could be coming from an event or timeout and that would be harder to pinpoint by hand)

Edit: I also need to be able to do this before the element in question is inserted into the main document. By the time I can do to the elements tab to inspect it the bug has already been triggerred.


回答1:


In the Elements tab of Chrome Dev Tools, I believe you can right click on the element and there should be an option to "Break on attribute modification".

https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints#dom



来源:https://stackoverflow.com/questions/11507472/is-it-possible-to-detect-when-an-inline-style-property-was-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!