removeResizeListener should ignore the function which is non-existen in the element.__resizeListeners_

If the function does not exist in the element.__resizeListeners__, This operation element.__resizeListeners__.indexOf(fn) yields a negative one. And then,
element.__resizeListeners__.splice(-1, 1) cause the existing functions to be deleted;
pull/21053/head
LiangZhiLin 2021-06-08 19:02:04 +08:00 committed by GitHub
parent 3807b54ab2
commit 02f08af627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -28,6 +28,7 @@ export const addResizeListener = function(element, fn) {
/* istanbul ignore next */
export const removeResizeListener = function(element, fn) {
if (!element || !element.__resizeListeners__) return;
if (element.__resizeListeners__.indexOf(fn) === -1) return;
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
element.__ro__.disconnect();