Skip to content

Commit 789647c

Browse files
committed
test: update test & ts
1 parent 9de1b59 commit 789647c

File tree

32 files changed

+116
-117
lines changed

32 files changed

+116
-117
lines changed

antdv-demo

components/_util/BaseMixin.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { nextTick } from 'vue';
12
import { getOptionProps } from './props-util';
23

34
export default {
@@ -19,7 +20,7 @@ export default {
1920
if (this._.isMounted) {
2021
this.$forceUpdate();
2122
}
22-
this.$nextTick(() => {
23+
nextTick(() => {
2324
callback && callback();
2425
});
2526
},

components/_util/BaseMixin2.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { nextTick } from 'vue';
12
import { getOptionProps } from './props-util';
23

34
export default {
@@ -19,7 +20,7 @@ export default {
1920
if (this._.isMounted) {
2021
this.$forceUpdate();
2122
}
22-
this.$nextTick(() => {
23+
nextTick(() => {
2324
callback && callback();
2425
});
2526
},

components/_util/Portal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from './vue-types';
2-
import { defineComponent, Teleport } from 'vue';
2+
import { defineComponent, nextTick, Teleport } from 'vue';
33

44
export default defineComponent({
55
name: 'Portal',
@@ -18,7 +18,7 @@ export default defineComponent({
1818
updated() {
1919
const { didUpdate } = this.$props;
2020
if (didUpdate) {
21-
this.$nextTick(() => {
21+
nextTick(() => {
2222
didUpdate(this.$props);
2323
});
2424
}

components/anchor/Anchor.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, inject, provide } from 'vue';
1+
import { defineComponent, inject, nextTick, provide } from 'vue';
22
import PropTypes from '../_util/vue-types';
33
import classNames from '../_util/classNames';
44
import addEventListener from '../vc-util/Dom/addEventListener';
@@ -117,15 +117,15 @@ export default defineComponent({
117117
};
118118
},
119119
mounted() {
120-
this.$nextTick(() => {
120+
nextTick(() => {
121121
const { getContainer } = this;
122122
this.scrollContainer = getContainer();
123123
this.scrollEvent = addEventListener(this.scrollContainer, 'scroll', this.handleScroll);
124124
this.handleScroll();
125125
});
126126
},
127127
updated() {
128-
this.$nextTick(() => {
128+
nextTick(() => {
129129
if (this.scrollEvent) {
130130
const { getContainer } = this;
131131
const currentContainer = getContainer();

components/anchor/AnchorLink.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentPublicInstance, defineComponent, inject } from 'vue';
1+
import { ComponentPublicInstance, defineComponent, inject, nextTick } from 'vue';
22
import PropTypes from '../_util/vue-types';
33
import { getComponent } from '../_util/props-util';
44
import classNames from '../_util/classNames';
@@ -32,7 +32,7 @@ export default defineComponent({
3232
},
3333
watch: {
3434
href(val, oldVal) {
35-
this.$nextTick(() => {
35+
nextTick(() => {
3636
this.antAnchor.unregisterLink(oldVal);
3737
this.antAnchor.registerLink(val);
3838
});

components/avatar/Avatar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { tuple, VueNode } from '../_util/type';
2-
import { CSSProperties, defineComponent, inject, PropType } from 'vue';
2+
import { CSSProperties, defineComponent, inject, nextTick, PropType } from 'vue';
33
import { defaultConfigProvider } from '../config-provider';
44
import { getComponent } from '../_util/props-util';
55
import PropTypes from '../_util/vue-types';
@@ -40,7 +40,7 @@ export default defineComponent({
4040
},
4141
watch: {
4242
src() {
43-
this.$nextTick(() => {
43+
nextTick(() => {
4444
this.isImgExist = true;
4545
this.scale = 1;
4646
// force uodate for position
@@ -49,13 +49,13 @@ export default defineComponent({
4949
},
5050
},
5151
mounted() {
52-
this.$nextTick(() => {
52+
nextTick(() => {
5353
this.setScale();
5454
this.isMounted = true;
5555
});
5656
},
5757
updated() {
58-
this.$nextTick(() => {
58+
nextTick(() => {
5959
this.setScale();
6060
});
6161
},

components/back-top/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App, defineComponent, inject } from 'vue';
1+
import { App, defineComponent, inject, nextTick } from 'vue';
22
import classNames from '../_util/classNames';
33
import PropTypes from '../_util/vue-types';
44
import backTopTypes from './backTopTypes';
@@ -36,7 +36,7 @@ const BackTop = defineComponent({
3636
};
3737
},
3838
mounted() {
39-
this.$nextTick(() => {
39+
nextTick(() => {
4040
const getTarget = this.target || getDefaultTarget;
4141
this.scrollEvent = addEventListener(getTarget(), 'scroll', this.handleScroll);
4242
this.handleScroll();

components/cascader/index.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,6 @@ const Cascader = defineComponent({
231231
flattenOptions: showSearch ? flattenTree(options, this.$props) : undefined,
232232
};
233233
},
234-
// mounted() {
235-
// this.$nextTick(() => {
236-
// if (this.autofocus && !this.showSearch && !this.disabled) {
237-
// this.$refs.picker.focus();
238-
// }
239-
// });
240-
// },
241234
watch: {
242235
value(val) {
243236
this.setState({ sValue: val || [] });

components/checkbox/Checkbox.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, inject } from 'vue';
1+
import { defineComponent, inject, nextTick } from 'vue';
22
import PropTypes from '../_util/vue-types';
33
import classNames from '../_util/classNames';
44
import VcCheckbox from '../vc-checkbox';
@@ -36,7 +36,7 @@ export default defineComponent({
3636

3737
watch: {
3838
value(value, prevValue) {
39-
this.$nextTick(() => {
39+
nextTick(() => {
4040
const { checkboxGroupContext: checkboxGroup = {} } = this;
4141
if (checkboxGroup.registerValue && checkboxGroup.cancelValue) {
4242
checkboxGroup.cancelValue(prevValue);

components/date-picker/RangePicker.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CSSProperties, defineComponent, inject } from 'vue';
1+
import { CSSProperties, defineComponent, inject, nextTick } from 'vue';
22
import moment from 'moment';
33
import RangeCalendar from '../vc-calendar/src/RangeCalendar';
44
import VcDatePicker from '../vc-calendar/src/Picker';
@@ -136,7 +136,7 @@ export default defineComponent({
136136
this.setState(state);
137137
},
138138
sOpen(val, oldVal) {
139-
this.$nextTick(() => {
139+
nextTick(() => {
140140
if (!hasProp(this, 'open') && oldVal && !val) {
141141
this.focus();
142142
}

components/date-picker/WeekPicker.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, inject } from 'vue';
1+
import { defineComponent, inject, nextTick } from 'vue';
22
import moment from 'moment';
33
import Calendar from '../vc-calendar';
44
import VcDatePicker from '../vc-calendar/src/Picker';
@@ -63,7 +63,7 @@ export default defineComponent({
6363
this.prevState = { ...this.$data, ...state };
6464
},
6565
_open(val, oldVal) {
66-
this.$nextTick(() => {
66+
nextTick(() => {
6767
if (!hasProp(this, 'open') && oldVal && !val) {
6868
this.focus();
6969
}
@@ -74,7 +74,7 @@ export default defineComponent({
7474
this.prevState = { ...this.$data };
7575
},
7676
updated() {
77-
this.$nextTick(() => {
77+
nextTick(() => {
7878
if (!hasProp(this, 'open') && this.prevState._open && !this._open) {
7979
this.focus();
8080
}

components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`RangePicker show month panel according to value 1`] = `
4-
<div id="app" data-v-app=""><span class="ant-calendar-picker" style="width: 350px;" tabindex="0"><!--teleport start--><!--teleport end--><span class="ant-calendar-picker-input ant-input"><input readonly="" placeholder="Start date" class="ant-calendar-range-picker-input" tabindex="-1"><span class="ant-calendar-range-picker-separator"> ~ </span><input readonly="" placeholder="End date" class="ant-calendar-range-picker-input" tabindex="-1"><span tabindex="-1" role="img" aria-label="close-circle" class="anticon anticon-close-circle ant-calendar-picker-clear"><svg class="" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path></svg></span><span class="ant-calendar-picker-icon"><!----></span>
4+
<div data-v-app=""><span class="ant-calendar-picker" style="width: 350px;" tabindex="0"><!--teleport start--><!--teleport end--><span class="ant-calendar-picker-input ant-input"><input readonly="" placeholder="Start date" class="ant-calendar-range-picker-input" tabindex="-1"><span class="ant-calendar-range-picker-separator"> ~ </span><input readonly="" placeholder="End date" class="ant-calendar-range-picker-input" tabindex="-1"><span tabindex="-1" role="img" aria-label="close-circle" class="anticon anticon-close-circle ant-calendar-picker-clear"><svg class="" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path></svg></span><span class="ant-calendar-picker-icon"><!----></span>
55
<div style="position: absolute; top: 0px; left: 0px; width: 100%;">
66
<div>
77
<!---->

components/date-picker/createPicker.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CSSProperties, DefineComponent, defineComponent, inject } from 'vue';
1+
import { CSSProperties, DefineComponent, defineComponent, inject, nextTick } from 'vue';
22
import moment from 'moment';
33
import omit from 'lodash-es/omit';
44
import MonthCalendar from '../vc-calendar/src/MonthCalendar';
@@ -73,7 +73,7 @@ export default function createPicker<P>(
7373
this.setState(state);
7474
},
7575
sOpen(val, oldVal) {
76-
this.$nextTick(() => {
76+
nextTick(() => {
7777
if (!hasProp(this, 'open') && oldVal && !val) {
7878
this.focus();
7979
}

components/date-picker/wrapPicker.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { provide, inject, defineComponent, DefineComponent } from 'vue';
1+
import { provide, inject, defineComponent, DefineComponent, nextTick } from 'vue';
22
import TimePickerPanel from '../vc-time-picker/Panel';
33
import classNames from '../_util/classNames';
44
import LocaleReceiver from '../locale-provider/LocaleReceiver';
@@ -74,7 +74,7 @@ export default function wrapPicker<P>(
7474
checkValidate('DatePicker', defaultValue, 'defaultValue', valueFormat);
7575
checkValidate('DatePicker', value, 'value', valueFormat);
7676
if (autofocus && !disabled) {
77-
this.$nextTick(() => {
77+
nextTick(() => {
7878
this.focus();
7979
});
8080
}

components/form/FormItem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { inject, provide, PropType, defineComponent, computed } from 'vue';
1+
import { inject, provide, PropType, defineComponent, computed, nextTick } from 'vue';
22
import cloneDeep from 'lodash-es/cloneDeep';
33
import PropTypes from '../_util/vue-types';
44
import classNames from '../_util/classNames';
@@ -295,7 +295,7 @@ export default defineComponent({
295295
prop.o[prop.k] = this.initialValue;
296296
}
297297
// reset validateDisabled after onFieldChange triggered
298-
this.$nextTick(() => {
298+
nextTick(() => {
299299
this.validateDisabled = false;
300300
});
301301
},

components/input/Input.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, inject, VNode, withDirectives } from 'vue';
1+
import { defineComponent, inject, nextTick, VNode, withDirectives } from 'vue';
22
import antInputDirective from '../_util/antInputDirective';
33
import classNames from '../_util/classNames';
44
import omit from 'omit.js';
@@ -76,7 +76,7 @@ export default defineComponent({
7676
},
7777
},
7878
mounted() {
79-
this.$nextTick(() => {
79+
nextTick(() => {
8080
if (process.env.NODE_ENV === 'test') {
8181
if (this.autofocus) {
8282
this.focus();
@@ -129,7 +129,7 @@ export default defineComponent({
129129
} else {
130130
this.$forceUpdate();
131131
}
132-
this.$nextTick(() => {
132+
nextTick(() => {
133133
callback && callback();
134134
});
135135
},

components/input/ResizableTextArea.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PropType, VNode } from 'vue';
1+
import { nextTick, PropType, VNode } from 'vue';
22
import ResizeObserver from '../vc-resize-observer';
33
import omit from 'omit.js';
44
import classNames from '../_util/classNames';
@@ -55,7 +55,7 @@ const ResizableTextArea = defineComponent({
5555
},
5656
watch: {
5757
value() {
58-
this.$nextTick(() => {
58+
nextTick(() => {
5959
this.resizeTextarea();
6060
});
6161
},

components/input/TextArea.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, inject } from 'vue';
1+
import { defineComponent, inject, nextTick } from 'vue';
22
import ClearableLabeledInput from './ClearableLabeledInput';
33
import ResizableTextArea from './ResizableTextArea';
44
import inputProps from './inputProps';
@@ -40,7 +40,7 @@ export default defineComponent({
4040
},
4141
},
4242
mounted() {
43-
this.$nextTick(() => {
43+
nextTick(() => {
4444
if (process.env.NODE_ENV === 'test') {
4545
if (this.autofocus) {
4646
this.focus();
@@ -55,7 +55,7 @@ export default defineComponent({
5555
} else {
5656
this.$forceUpdate();
5757
}
58-
this.$nextTick(() => {
58+
nextTick(() => {
5959
callback && callback();
6060
});
6161
},

components/layout/Sider.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from '../_util/classNames';
2-
import { inject, provide, PropType, defineComponent } from 'vue';
2+
import { inject, provide, PropType, defineComponent, nextTick } from 'vue';
33
import PropTypes from '../_util/vue-types';
44
import { tuple } from '../_util/type';
55
import { getOptionProps, hasProp, getComponent, getSlot } from '../_util/props-util';
@@ -114,7 +114,7 @@ export default defineComponent({
114114
},
115115

116116
mounted() {
117-
this.$nextTick(() => {
117+
nextTick(() => {
118118
if (this.mql) {
119119
this.mql.addListener(this.responsiveHandler);
120120
this.responsiveHandler(this.mql);

0 commit comments

Comments
 (0)