Skip to content

Commit 122e374

Browse files
committed
perf: remove syncWatch
1 parent 7719c65 commit 122e374

File tree

10 files changed

+20
-35
lines changed

10 files changed

+20
-35
lines changed

components/_util/PortalWrapper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import PropTypes from './vue-types';
22
import switchScrollingEffect from './switchScrollingEffect';
33
import setStyle from './setStyle';
44
import Portal from './Portal';
5-
import syncWatch from './syncWatch';
65

76
let openCount = 0;
87
const windowIsUndefined = !(
@@ -33,9 +32,9 @@ export default {
3332
this.setWrapperClassName();
3433
},
3534
watch: {
36-
visible: syncWatch(function(val) {
35+
visible(val) {
3736
openCount = val ? openCount + 1 : openCount - 1;
38-
}),
37+
},
3938
getContainer(getContainer, prevGetContainer) {
4039
const getContainerIsFunc =
4140
typeof getContainer === 'function' && typeof prevGetContainer === 'function';

components/_util/syncWatch.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

components/badge/ScrollNumber.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import omit from 'omit.js';
55
import { cloneElement } from '../_util/vnode';
66
import { ConfigConsumerProps } from '../config-provider';
77
import { inject } from 'vue';
8-
import syncWatch from '../_util/syncWatch';
98

109
function getNumberArray(num) {
1110
return num
@@ -47,12 +46,12 @@ export default {
4746
};
4847
},
4948
watch: {
50-
count: syncWatch(function() {
49+
count() {
5150
this.lastCount = this.sCount;
5251
this.setState({
5352
animateStarted: true,
5453
});
55-
}),
54+
},
5655
},
5756
updated() {
5857
const { animateStarted, count } = this;

components/input/Input.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import inputProps from './inputProps';
66
import { hasProp, getComponent, getOptionProps } from '../_util/props-util';
77
import { ConfigConsumerProps } from '../config-provider';
88
import ClearableLabeledInput from './ClearableLabeledInput';
9-
import syncWatch from '../_util/syncWatch';
109

1110
export function fixControlledValue(value) {
1211
if (typeof value === 'undefined' || value === null) {
@@ -68,9 +67,9 @@ export default {
6867
};
6968
},
7069
watch: {
71-
value: syncWatch(function(val) {
70+
value(val) {
7271
this.stateValue = val;
73-
}),
72+
},
7473
},
7574
mounted() {
7675
this.$nextTick(() => {

components/input/ResizableTextArea.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import BaseMixin from '../_util/BaseMixin';
88
import inputProps from './inputProps';
99
import PropTypes from '../_util/vue-types';
1010
import { getOptionProps } from '../_util/props-util';
11-
import syncWatch from '../_util/syncWatch';
1211

1312
const RESIZE_STATUS_NONE = 0;
1413
const RESIZE_STATUS_RESIZING = 1;
@@ -39,11 +38,11 @@ const ResizableTextArea = {
3938
raf.cancel(this.resizeFrameId);
4039
},
4140
watch: {
42-
value: syncWatch(function() {
41+
value() {
4342
this.$nextTick(() => {
4443
this.resizeTextarea();
4544
});
46-
}),
45+
},
4746
},
4847
methods: {
4948
saveTextArea(textArea) {

components/input/TextArea.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { hasProp, getOptionProps } from '../_util/props-util';
66
import { ConfigConsumerProps } from '../config-provider';
77
import { fixControlledValue, resolveOnChange } from './Input';
88
import PropTypes from '../_util/vue-types';
9-
import syncWatch from '../_util/syncWatch';
109

1110
const TextAreaProps = {
1211
...inputProps,
@@ -32,9 +31,9 @@ export default {
3231
};
3332
},
3433
watch: {
35-
value: syncWatch(function(val) {
34+
value(val) {
3635
this.stateValue = val;
37-
}),
36+
},
3837
},
3938
mounted() {
4039
this.$nextTick(() => {

components/modal/Modal.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const ButtonType = buttonTypes().type;
1111
import LocaleReceiver from '../locale-provider/LocaleReceiver';
1212
import { initDefaultProps, getComponent, getSlot } from '../_util/props-util';
1313
import { ConfigConsumerProps } from '../config-provider';
14-
import syncWatch from '../_util/syncWatch';
1514

1615
let mousePosition = null;
1716
// ref: https://github.com/ant-design/ant-design/issues/15795
@@ -107,9 +106,9 @@ export default {
107106
};
108107
},
109108
watch: {
110-
visible: syncWatch(function(val) {
109+
visible(val) {
111110
this.sVisible = val;
112-
}),
111+
},
113112
},
114113
setup() {
115114
return {

components/vc-cascader/Cascader.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import shallowEqualArrays from 'shallow-equal/arrays';
88
import { hasProp, getEvents } from '../_util/props-util';
99
import BaseMixin from '../_util/BaseMixin';
1010
import { cloneElement } from '../_util/vnode';
11-
import syncWatch from '../_util/syncWatch';
1211

1312
const BUILT_IN_PLACEMENTS = {
1413
bottomLeft: {
@@ -100,7 +99,7 @@ export default {
10099
};
101100
},
102101
watch: {
103-
value: syncWatch(function(val, oldValue) {
102+
value(val, oldValue) {
104103
if (!shallowEqualArrays(val, oldValue)) {
105104
const newValues = {
106105
sValue: val || [],
@@ -112,12 +111,12 @@ export default {
112111
}
113112
this.setState(newValues);
114113
}
115-
}),
116-
popupVisible: syncWatch(function(val) {
114+
},
115+
popupVisible(val) {
117116
this.setState({
118117
sPopupVisible: val,
119118
});
120-
}),
119+
},
121120
},
122121
methods: {
123122
getPopupDOMNode() {

components/vc-table/src/Table.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import BodyTable from './BodyTable';
1515
import ExpandableTable from './ExpandableTable';
1616
import { initDefaultProps, getOptionProps } from '../../_util/props-util';
1717
import BaseMixin from '../../_util/BaseMixin';
18-
import syncWatch from '../../_util/syncWatch';
1918

2019
export default {
2120
name: 'Table',
@@ -129,11 +128,11 @@ export default {
129128
this.components,
130129
);
131130
},
132-
columns: syncWatch(function(val) {
131+
columns(val) {
133132
if (val) {
134133
this.columnManager.reset(val);
135134
}
136-
}),
135+
},
137136
data(val) {
138137
if (val.length === 0 && this.hasScrollX()) {
139138
this.$nextTick(() => {

components/vc-tree/src/Tree.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import warning from 'warning';
44
import { hasProp, initDefaultProps, getOptionProps, getSlot } from '../../_util/props-util';
55
import { cloneElement } from '../../_util/vnode';
66
import BaseMixin from '../../_util/BaseMixin';
7-
import syncWatch from '../../_util/syncWatch';
87
import {
98
convertTreeToEntities,
109
convertDataToTree,
@@ -153,10 +152,10 @@ const Tree = {
153152
'checkedKeys',
154153
'loadedKeys',
155154
]),
156-
__propsSymbol__: syncWatch(function() {
155+
__propsSymbol__() {
157156
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
158157
this.needSyncKeys = {};
159-
}),
158+
},
160159
},
161160

162161
methods: {

0 commit comments

Comments
 (0)