File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,9 @@ function appendNextSiblings<Node, ElementNode extends Node>(
115
115
) : Node [ ] {
116
116
// Order matters because jQuery seems to check the children before the siblings
117
117
const elems = Array . isArray ( elem ) ? elem . slice ( 0 ) : [ elem ] ;
118
+ const elemsLength = elems . length ;
118
119
119
- for ( let i = 0 ; i < elems . length ; i ++ ) {
120
+ for ( let i = 0 ; i < elemsLength ; i ++ ) {
120
121
const nextSiblings = getNextSiblings ( elems [ i ] , adapter ) ;
121
122
elems . push ( ...nextSiblings ) ;
122
123
}
Original file line number Diff line number Diff line change @@ -255,6 +255,14 @@ describe("API", () => {
255
255
) . toStrictEqual ( p ) ;
256
256
} ) ;
257
257
258
+ it ( "should not crash when siblings repeat" , ( ) => {
259
+ const dom = parseDOM ( `<div></div>` . repeat ( 51 ) ) as Element [ ] ;
260
+
261
+ expect (
262
+ CSSselect . selectAll ( "+div" , dom , { context : dom } )
263
+ ) . toHaveLength ( 50 ) ;
264
+ } ) ;
265
+
258
266
it ( "should cache results by default" , ( ) => {
259
267
const [ dom ] = parseDOM (
260
268
'<div id="foo"><p>bar</p></div>'
You can’t perform that action at this time.
0 commit comments