How to see changes to HTML & CSS caused by scripts or navigation events
I often work with UI templates that I adapt to the framework I am coding with. Often there are UI features that are triggered off of mouse overs, etc… that rely on the position of the pointer. Once the pointer is removed the HTML/CSS reverts back to the original state.
A simple example is a Drop Down Menu triggered by a hover event.
<div>
<button class="dropdown">Dropdown</button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
<style>
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
z-index: 1;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
</style>
One can easily find this by using Inspect in developer tools and watching for the change in the CSS of <div class="dropdown-content">
tag when you hover over the <button class="dropdown">Dropdown</button>
tag (the css for the hover is selected and appears in the top of the Developer Tools Styles Window).
Unfortunately, many UI features are not this easy to uncover. Hover events can trigger complex unfamiliar JavaScript liberties, etc. with changes that are not easily noticed in the Developer Tools. This can lead to time spend tracing through compressed JavaScript code or frustration with changes disappearing when you move your mouse pointer off of the spot to use the dev tools, etc.
To avoid debugging 3rd party JavaScript (that I am often trying to replace), the rough solution I have found to this has been to dump a copy of the HTML/CSS to a file. Cause the UI change to take place and dump a second file, then Diff the files to see the changes to the HTML and Style that causes the changes.
Is there a tool that will display the diff for me without having to dump files to disk?
As I mentioned, it’s not always easy to spot the changes in the Developer Tools HTML & CSS windows without moving your mouse (losing the changes).