|
16 | 16 | <script>
|
17 | 17 | /* eslint-disable no-console */
|
18 | 18 |
|
19 |
| - const spinnerMapping = { |
20 |
| - bubbles: 'loading-bubbles', |
21 |
| - circles: 'loading-circles', |
22 |
| - default: 'loading-default', |
23 |
| - spiral: 'loading-spiral', |
24 |
| - waveDots: 'loading-wave-dots', |
| 19 | + const SPINNERS = { |
| 20 | + BUBBLES: 'loading-bubbles', |
| 21 | + CIRCLES: 'loading-circles', |
| 22 | + DEFAULT: 'loading-default', |
| 23 | + SPIRAL: 'loading-spiral', |
| 24 | + WAVEDOTS: 'loading-wave-dots', |
25 | 25 | };
|
26 |
| - const warnings = { |
27 |
| - stateChanger: [ |
| 26 | + const WARNINGS = { |
| 27 | + STATE_CHANGER: [ |
28 | 28 | '[Vue-infinite-loading warn]: emit `loaded` and `complete` event through component instance of `$refs` may cause error, so it will be deprecated soon, please use the `$state` argument instead (`$state` just the special `$event` variable):',
|
29 | 29 | '\ntemplate:',
|
30 | 30 | '<infinite-loading @infinite="infiniteHandler"></infinite-loading>',
|
|
45 | 45 | '',
|
46 | 46 | 'more details: https://github.com/PeachScript/vue-infinite-loading/issues/57#issuecomment-324370549',
|
47 | 47 | ].join('\n'),
|
48 |
| - infiniteEvent: '[Vue-infinite-loading warn]: `:on-infinite` property will be deprecated soon, please use `@infinite` event instead.', |
| 48 | + INFINITE_EVENT: '[Vue-infinite-loading warn]: `:on-infinite` property will be deprecated soon, please use `@infinite` event instead.', |
49 | 49 | };
|
50 | 50 |
|
51 | 51 | export default {
|
|
62 | 62 | },
|
63 | 63 | computed: {
|
64 | 64 | spinnerType() {
|
65 |
| - return spinnerMapping[this.spinner] || spinnerMapping.default; |
| 65 | + return SPINNERS[(this.spinner || '').toUpperCase()] || SPINNERS.DEFAULT; |
66 | 66 | },
|
67 | 67 | isNoResults: {
|
68 | 68 | cache: false, // disable cache to fix the problem of get slot text delay
|
|
121 | 121 | }
|
122 | 122 |
|
123 | 123 | if (!ev || ev.target !== this) {
|
124 |
| - console.warn(warnings.stateChanger); |
| 124 | + console.warn(WARNINGS.STATE_CHANGER); |
125 | 125 | }
|
126 | 126 | });
|
127 | 127 |
|
|
137 | 137 | this.scrollParent.removeEventListener('scroll', this.scrollHandler);
|
138 | 138 |
|
139 | 139 | if (!ev || ev.target !== this) {
|
140 |
| - console.warn(warnings.stateChanger); |
| 140 | + console.warn(WARNINGS.STATE_CHANGER); |
141 | 141 | }
|
142 | 142 | });
|
143 | 143 |
|
|
150 | 150 | });
|
151 | 151 |
|
152 | 152 | if (this.onInfinite) {
|
153 |
| - console.warn(warnings.infiniteEvent); |
| 153 | + console.warn(WARNINGS.INFINITE_EVENT); |
154 | 154 | }
|
155 | 155 |
|
156 | 156 | /**
|
|
0 commit comments