简体   繁体   English

Chrome Dev Tool跟踪DOM在交互时的变化

[英]Chrome Dev Tool track DOM changes on interaction

In Chrome Developer Tool Element's tab, if by clicking on a button an attribute changes ( class="menu-item" -> class="menu-item active" ), you can see a purple flash on the element indicating the change. 在Chrome开发者工具元素的标签中,如果通过单击按钮属性更改( class="menu-item" - > class="menu-item active" ),您可以在元素上看到指示更改的紫色闪光。 This is very helpful but in a large document you have to expand all the elements down deep to see what's happening. 这非常有用,但在大型文档中,您必须深入扩展所有元素才能看到发生了什么。

Is there any way you can record/list all the DOM changes when an interaction occurs? 有没有什么方法可以在发生交互时记录/列出所有DOM更改? Not specifically in Chrome but any other tool would be great. 不是专门用于Chrome,但任何其他工具都会很棒。 Think of it as a diff between before and after interaction but specific to CSS. 将其视为交互前后的diff ,但特定于CSS。

There is a chrome extension: DOMListener Where you can start recording DOM changes when you are expecting a change, when the change happens too fast for you to notice without help of a tool. 有一个chrome扩展名:DOMListener您可以在期望更改时开始记录DOM更改,当更改发生得太快而您无需借助工具时就能注意到。 You can filter the changes you want to track by 4 categories: 您可以按4个类别过滤要跟踪的更改:

  • text changed 文字改变了
  • attribute changed 属性已更改
  • node added 节点已添加
  • node removed 节点已删除

And you will get the changes with target and details 您将获得目标和详细信息的更改

https://chrome.google.com/webstore/detail/domlistener/jlfdgnlpibogjanomigieemaembjeolj https://chrome.google.com/webstore/detail/domlistener/jlfdgnlpibogjanomigieemaembjeolj

Right click the element in Inspector and choose Breakpoint and choose the type of change you want to monitor. 右键单击“检查器”中的元素,然后选择“断点”并选择要监视的更改类型。

Then next time the element is affected, the page will stop. 然后,下次元素受到影响时,页面将停止。 with a "Paused execution" message. 带有“暂停执行”消息。 You can examine the frozen state of the element at that point. 您可以在该点检查元素的冻结状态。 Then click the blue triangle button on the Paused Execution message and it will resume until the next time that element changes, at which point you can examine it again. 然后单击Paused Execution消息上的蓝色三角形按钮,它将一直恢复,直到下一次该元素发生变化,此时您可以再次检查它。

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

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