File tree Expand file tree Collapse file tree 2 files changed +43
-6
lines changed Expand file tree Collapse file tree 2 files changed +43
-6
lines changed Original file line number Diff line number Diff line change @@ -295,12 +295,18 @@ export default {
295
295
getScrollParent (elm = this .$el ) {
296
296
let result;
297
297
298
- if (elm .tagName === ' BODY' ) {
299
- result = window ;
300
- } else if (! this .forceUseInfiniteWrapper && [' scroll' , ' auto' ].indexOf (getComputedStyle (elm).overflowY ) > - 1 ) {
301
- result = elm;
302
- } else if (elm .hasAttribute (' infinite-wrapper' ) || elm .hasAttribute (' data-infinite-wrapper' )) {
303
- result = elm;
298
+ if (typeof this .forceUseInfiniteWrapper === ' string' ) {
299
+ result = elm .querySelector (this .forceUseInfiniteWrapper );
300
+ }
301
+
302
+ if (! result) {
303
+ if (elm .tagName === ' BODY' ) {
304
+ result = window ;
305
+ } else if (! this .forceUseInfiniteWrapper && [' scroll' , ' auto' ].indexOf (getComputedStyle (elm).overflowY ) > - 1 ) {
306
+ result = elm;
307
+ } else if (elm .hasAttribute (' infinite-wrapper' ) || elm .hasAttribute (' data-infinite-wrapper' )) {
308
+ result = elm;
309
+ }
304
310
}
305
311
306
312
return result || this .getScrollParent (elm .parentNode );
Original file line number Diff line number Diff line change @@ -566,4 +566,35 @@ describe('vue-infinite-loading', () => {
566
566
567
567
vm . $mount ( '#app' ) ;
568
568
} ) ;
569
+
570
+ it ( 'should find my forcible element as scroll wrapper when using `force-use-infinite-wrapper` as seletor' , ( done ) => {
571
+ vm = new Vue ( Object . assign ( { } , basicConfig , {
572
+ template : `
573
+ <div class="scroll">
574
+ <div style="overflow: auto;">
575
+ <div style="overflow: auto;">
576
+ <ul>
577
+ <li v-for="item in list" v-text="item"></li>
578
+ </ul>
579
+ <infinite-loading
580
+ :direction="direction"
581
+ @infinite="infiniteHandler"
582
+ ref="infiniteLoading"
583
+ force-use-infinite-wrapper=".scroll"
584
+ >
585
+ </infinite-loading>
586
+ </div>
587
+ </div>
588
+ </div>
589
+ ` ,
590
+ methods : {
591
+ infiniteHandler : function infiniteHandler ( ) {
592
+ expect ( this . $refs . infiniteLoading . scrollParent ) . to . equal ( this . $el ) ;
593
+ done ( ) ;
594
+ } ,
595
+ } ,
596
+ } ) ) ;
597
+
598
+ vm . $mount ( '#app' ) ;
599
+ } ) ;
569
600
} ) ;
You can’t perform that action at this time.
0 commit comments