简体   繁体   English

是否可以检测何时设置了内联样式属性?

[英]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. 我有一个错误,某个div的style.height属性被Javascript设置为0px,但我不知道是什么代码正在做这个不需要的设置。

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". 在Chrome Dev Tools的Elements选项卡中,我相信您可以右键单击该元素,并且应该有一个“Breaking attribute modification”选项。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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