diff options
author | ac-mmi <79802170+ac-mmi@users.noreply.github.com> | 2024-09-11 03:48:53 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 00:18:53 +0200 |
commit | 3cad5c435aa2333c39baa55a8bceb2b6bf1e2721 (patch) | |
tree | d0574da799ad03019ff21a135c870ab16545dc82 /src/manipulation | |
parent | 6d78c0768d9aa6ba213678724c89af69a1958df6 (diff) | |
download | jquery-3cad5c435aa2333c39baa55a8bceb2b6bf1e2721.tar.gz jquery-3cad5c435aa2333c39baa55a8bceb2b6bf1e2721.zip |
Manipulation: Make jQuery.cleanData not skip elements during cleanup
When passing a result of `getElementByTagsName` to `jQuery.cleanData`, convert
it to an array first. Otherwise, a live NodeList is passed and if any of the
event cleanups remove the element itself, a collection is modified during the
iteration, making `jQuery.cleanData` skip cleanup for some elements.
Fixes gh-5214
Closes gh-5523
Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Diffstat (limited to 'src/manipulation')
-rw-r--r-- | src/manipulation/getAll.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/manipulation/getAll.js b/src/manipulation/getAll.js index db876202d..86526a256 100644 --- a/src/manipulation/getAll.js +++ b/src/manipulation/getAll.js @@ -1,5 +1,6 @@ import { jQuery } from "../core.js"; import { nodeName } from "../core/nodeName.js"; +import { arr } from "../var/arr.js"; export function getAll( context, tag ) { @@ -8,7 +9,9 @@ export function getAll( context, tag ) { var ret; if ( typeof context.getElementsByTagName !== "undefined" ) { - ret = context.getElementsByTagName( tag || "*" ); + + // Use slice to snapshot the live collection from gEBTN + ret = arr.slice.call( context.getElementsByTagName( tag || "*" ) ); } else if ( typeof context.querySelectorAll !== "undefined" ) { ret = context.querySelectorAll( tag || "*" ); |