Skip to content

Commit dd68c0d

Browse files
committed
fix: vc-select
1 parent 106b82c commit dd68c0d

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

components/_util/props-util.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const getComponent = (instance, prop = 'default', options = instance, execute =
139139
}
140140
} else if (isVNode(instance)) {
141141
const temp = instance.props && instance.props[prop];
142-
if (temp !== undefined) {
142+
if (temp !== undefined && temp !== null) {
143143
return typeof temp === 'function' && execute ? temp(options) : temp;
144144
} else if (instance.children && instance.children[prop]) {
145145
let com = instance.children[prop];
@@ -305,18 +305,29 @@ export function isFragment(c) {
305305
}
306306

307307
export function isEmptyElement(c) {
308-
return c.type === Comment || (c.type === Text && c.children.trim() === '');
308+
return (
309+
c.type === Comment ||
310+
(c.type === Fragment && c.children.length === 0) ||
311+
(c.type === Text && c.children.trim() === '')
312+
);
309313
}
310314

311315
export function isStringElement(c) {
312316
return !c.tag;
313317
}
314318

315319
export function filterEmpty(children = []) {
316-
if (isFragment(children)) {
317-
return children[0].children.filter(c => !isEmptyElement(c));
318-
}
319-
return children.filter(c => !isEmptyElement(c));
320+
const res = [];
321+
children.forEach(child => {
322+
if (Array.isArray(child)) {
323+
res.push(...child);
324+
} else if (child.type === Fragment) {
325+
res.push(...child.children);
326+
} else {
327+
res.push(child);
328+
}
329+
});
330+
return res.filter(c => !isEmptyElement(c));
320331
}
321332
const initDefaultProps = (propTypes, defaultProps) => {
322333
Object.keys(defaultProps).forEach(k => {

examples/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</div>
55
</template>
66
<script>
7-
import demo from '../antdv-demo/docs/input-number/demo/index';
7+
import demo from '../antdv-demo/docs/select/demo/tags';
88
99
export default {
1010
components: {

examples/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import '@babel/polyfill';
22
import { createApp } from 'vue';
33
import App from './App.vue';
44
import {
5+
Radio,
6+
Spin,
7+
Select,
58
Input,
69
InputNumber,
710
Rate,
@@ -32,6 +35,8 @@ app
3235
.component('api', { ...basic })
3336
.component('CN', { ...basic })
3437
.component('US', { ...basic })
38+
.use(Select)
39+
.use(Spin)
3540
.use(Upload)
3641
.use(Button)
3742
.use(Icon)
@@ -42,5 +47,6 @@ app
4247
.use(Tooltip)
4348
.use(Col)
4449
.use(Row)
50+
.use(Radio)
4551
.use(InputNumber)
4652
.mount('#app');

0 commit comments

Comments
 (0)