Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update spin #2351

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions components/spin/Spin.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { inject, cloneVNode } from 'vue';
import debounce from 'lodash/debounce';
import PropTypes from '../_util/vue-types';
import BaseMixin from '../_util/BaseMixin';
import {
filterEmpty,
initDefaultProps,
isValidElement,
getComponentFromProp,
getComponent,
getListeners,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getListeners 可以删除了,3.0 默认将事件 挂载到根节点 我先合并了直接改

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

} from '../_util/props-util';
import { cloneElement } from '../_util/vnode';
import { ConfigConsumerProps } from '../config-provider';

export const SpinSize = PropTypes.oneOf(['small', 'default', 'large']);
Expand Down Expand Up @@ -47,8 +47,10 @@ export default {
spinning: true,
wrapperClassName: '',
}),
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
data() {
const { spinning, delay } = this;
Expand Down Expand Up @@ -100,7 +102,7 @@ export default {
renderIndicator(h, prefixCls) {
// const h = this.$createElement
const dotClassName = `${prefixCls}-dot`;
let indicator = getComponentFromProp(this, 'indicator');
let indicator = getComponent(this, 'indicator');
// should not be render default indicator when indicator value is null
if (indicator === null) {
return null;
Expand All @@ -110,11 +112,11 @@ export default {
indicator = indicator.length === 1 ? indicator[0] : indicator;
}
if (isValidElement(indicator)) {
return cloneElement(indicator, { class: dotClassName });
return cloneVNode(indicator, { class: dotClassName });
}

if (defaultIndicator && isValidElement(defaultIndicator(h))) {
return cloneElement(defaultIndicator(h), { class: dotClassName });
return cloneVNode(defaultIndicator(h), { class: dotClassName });
}

return (
Expand Down
6 changes: 2 additions & 4 deletions components/spin/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Spin, { setDefaultIndicator } from './Spin';
import Base from '../base';

export { SpinProps } from './Spin';

Spin.setDefaultIndicator = setDefaultIndicator;

/* istanbul ignore next */
Spin.install = function(Vue) {
Vue.use(Base);
Vue.component(Spin.name, Spin);
Spin.install = function(app) {
app.component(Spin.name, Spin);
};

export default Spin;
2 changes: 2 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Drawer from 'ant-design-vue/drawer';
import Affix from 'ant-design-vue/affix';
import Alert from 'ant-design-vue/alert';
import ConfigProvider from 'ant-design-vue/config-provider';
import Spin from 'ant-design-vue/Spin';
import 'ant-design-vue/style.js';

createApp(App)
Expand All @@ -14,4 +15,5 @@ createApp(App)
.use(Drawer)
.use(Affix)
.use(Alert)
.use(Spin)
.mount('#app');