Description
Hi, Thanks for a great tool!
I discovered one problem with it that I think should be treated as a bug. Or, probably the docs need a clarification.
The announcement blog post (https://blogs.windows.com/msedgedev/2021/12/09/debug-memory-leaks-detached-elements-tool-devtools/) gives 2 valid reasons why elements can be unattached (numbering mine):
Usually, we create DOM nodes in JavaScript to insert them somewhere in the page to display them. But it is possible to create nodes and
(1) never attach them or
(2) remove nodes from the page and keep references to them in JavaScript.
The announcement blog post explains it as if the "Detached Elements" tab was able to detect cases (1) and (2), but, in fact, it only detects case (2).
I think both cases are valid. It would be useful for this tool to support both. Ideally with some button to filter the kind you're interested in.
Reproduction
Run the following code as index.html
:
<script type="module">
const cache = [];
const detachedSection = document.createElement("section");
cache.push(detachedSection);
const detachedArticle = document.createElement("article");
document.body.appendChild(detachedArticle);
detachedArticle.remove();
cache.push(detachedArticle);
console.log("Disconnected elements", cache);
</script>
This script creates two nodes, but only one (article
) is reported by the tool, as seen on the screenshot below:
Edge version: 120.0.2158.0 (Official build) Canary (arm64)