focus-visible icon indicating copy to clipboard operation
focus-visible copied to clipboard

Memory leaks when applyFocusVisiblePolyfill is applied then the element is removed

Open ryuran opened this issue 2 years ago • 3 comments

Hello.

Some web components with shadowDOM use focus-visible polyfill. We apply applyFocusVisiblePolyfill when the component is attached to the DOM connectedCallback(). When the component is removed, applyFocusVisiblePolyfill keep a reference of it preventing it to be garbage collected.

So each web-component added then removed are kept in memory and it can make a huge memory leak.

Potential solution: provide a function to unapply to remove all event listener set by applyFocusVisiblePolyfill at disconnectedCallback.

More info on memory Leaks https://www.youtube.com/watch?v=YDU_3WdfkxA

ryuran avatar Nov 15 '22 09:11 ryuran

hello, we are seeing the same issue. Is this something that will be addressed?

rafael-leal-mccormack avatar Dec 21 '22 15:12 rafael-leal-mccormack

Hi @rafael-leal-mccormack and @ryuran, unfortunately we don't have the bandwidth to work on this right now, but would gladly accept and review a PR if someone wanted to take the time to make one.

We are not planning any updates to this polyfill because focus-visible is now supported in all browsers, and those browsers have all moved to an evergreen model. I would be curious to know if you and @ryuran feel like you can move off of the polyfill, and if not, why?

robdodson avatar Dec 21 '22 18:12 robdodson

Hi @robdodson our company still support officially safari >=15.0. :focus-visible is supported only from safari >=15.4 It’s why…

ryuran avatar Jan 16 '23 14:01 ryuran