Skip to content

Commit 54e67c6

Browse files
committed
refactor: move blank slot check logic into utils
1 parent a971793 commit 54e67c6

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/components/InfiniteLoading.vue

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,7 @@
1717
/* eslint-disable no-console */
1818
import Spinner from './Spinner.vue';
1919
import config, { evt3rdArg, WARNINGS } from '../config';
20-
import { throttleer, loopTracker } from '../utils';
21-
22-
/**
23-
* determine slot is or not a empty element
24-
* @param {Slot} slot target slot
25-
* @return {Boolean}
26-
*/
27-
function isBlankSlotElm(slot) {
28-
return (
29-
slot
30-
&& slot[0].elm
31-
&& slot[0].elm.textContent === ''
32-
&& slot[0].elm.childNodes.length === 0
33-
);
34-
}
20+
import { throttleer, loopTracker, isBlankSlotElm } from '../utils';
3521
3622
export default {
3723
name: 'InfiniteLoading',

src/utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,22 @@ export const loopTracker = {
4040
},
4141
};
4242

43+
/**
44+
* determine slot is or not a empty element
45+
* @param {Slot} slot target slot
46+
* @return {Boolean}
47+
*/
48+
export function isBlankSlotElm(slot) {
49+
return (
50+
slot
51+
&& slot[0].elm
52+
&& slot[0].elm.textContent === ''
53+
&& slot[0].elm.childNodes.length === 0
54+
);
55+
}
56+
4357
export default {
4458
throttleer,
4559
loopTracker,
60+
isBlankSlotElm,
4661
};

0 commit comments

Comments
 (0)