Closed melloware closed 1 month ago
Thanks for the report but I don’t understand the issue. Can you elaborate why the current behavior is problematic?
Well its a detached unused element reported by Chrome as a leak. Why keep an anchor around you don't need? I don't understand what you are asking that you don't understand?
The goal should be to never have detached DOM elements right?
It’s a single element, it doesn’t block a lot of memory. By keeping it, we avoid having to recreate one each time we need to normalize the href parts.
I understand you can find it in Chrome memory report but does it really cause any issue for the running website? Just seeing the node in a memory report is not a sufficient reason to change the code IMO.
Thank you for your contribution, but I don't think a change is needed here. This is not a memory leak. See https://github.com/jquery/jquery/issues/5458#issuecomment-2022921263
Understood but since this value won't change ever why keep the anchor around and not just store the simple string seems like an odd design choice...
That's a fair question. I think in this case the value you're referring to can change depending on the context so it needs to continue to reference the property on the element, rather than cache a previous value.
Description
Running plain jQuery 3.7.1 and then do a Chrome Heap Snapshot. You will see the OriginAnchor is detached.
Reason
You are storing a ref to an anchor and constantly checking it.
Solution
The solution is to store off the value you need and de-reference the originAnchor.