简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM