focus-visible
focus-visible copied to clipboard
Memory leaks when applyFocusVisiblePolyfill is applied then the element is removed
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
hello, we are seeing the same issue. Is this something that will be addressed?
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?
Hi @robdodson our company still support officially safari >=15.0
.
:focus-visible
is supported only from safari >=15.4
It’s why…