fix(animations): replace copy of query selector node-list from "spread" to "for" (#39646)
For element queries that return sufficiently large NodeList objects, using spread syntax to populate the results array causes a RangeError due to the call stack limit being reached. This commit updates the code to use regular "for" loop instead. Fixes #38551. PR Close #39646
This commit is contained in:
parent
5684ac5e34
commit
bfa197f564
@ -183,7 +183,17 @@ if (_isNode || typeof Element !== 'undefined') {
|
|||||||
_query = (element: any, selector: string, multi: boolean): any[] => {
|
_query = (element: any, selector: string, multi: boolean): any[] => {
|
||||||
let results: any[] = [];
|
let results: any[] = [];
|
||||||
if (multi) {
|
if (multi) {
|
||||||
results.push(...element.querySelectorAll(selector));
|
// DO NOT REFACTOR TO USE SPREAD SYNTAX.
|
||||||
|
// For element queries that return sufficiently large NodeList objects,
|
||||||
|
// using spread syntax to populate the results array causes a RangeError
|
||||||
|
// due to the call stack limit being reached. `Array.from` can not be used
|
||||||
|
// as well, since NodeList is not iterable in IE 11, see
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/NodeList
|
||||||
|
// More info is available in #38551.
|
||||||
|
const elems = element.querySelectorAll(selector);
|
||||||
|
for (let i = 0; i < elems.length; i++) {
|
||||||
|
results.push(elems[i]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const elm = element.querySelector(selector);
|
const elm = element.querySelector(selector);
|
||||||
if (elm) {
|
if (elm) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user