perf: remove syncWatch
parent
7719c65169
commit
122e374224
|
@ -2,7 +2,6 @@ import PropTypes from './vue-types';
|
||||||
import switchScrollingEffect from './switchScrollingEffect';
|
import switchScrollingEffect from './switchScrollingEffect';
|
||||||
import setStyle from './setStyle';
|
import setStyle from './setStyle';
|
||||||
import Portal from './Portal';
|
import Portal from './Portal';
|
||||||
import syncWatch from './syncWatch';
|
|
||||||
|
|
||||||
let openCount = 0;
|
let openCount = 0;
|
||||||
const windowIsUndefined = !(
|
const windowIsUndefined = !(
|
||||||
|
@ -33,9 +32,9 @@ export default {
|
||||||
this.setWrapperClassName();
|
this.setWrapperClassName();
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
visible: syncWatch(function(val) {
|
visible(val) {
|
||||||
openCount = val ? openCount + 1 : openCount - 1;
|
openCount = val ? openCount + 1 : openCount - 1;
|
||||||
}),
|
},
|
||||||
getContainer(getContainer, prevGetContainer) {
|
getContainer(getContainer, prevGetContainer) {
|
||||||
const getContainerIsFunc =
|
const getContainerIsFunc =
|
||||||
typeof getContainer === 'function' && typeof prevGetContainer === 'function';
|
typeof getContainer === 'function' && typeof prevGetContainer === 'function';
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
export default function syncWatch(fn) {
|
|
||||||
return {
|
|
||||||
handler: fn,
|
|
||||||
flush: 'sync',
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ import omit from 'omit.js';
|
||||||
import { cloneElement } from '../_util/vnode';
|
import { cloneElement } from '../_util/vnode';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
import syncWatch from '../_util/syncWatch';
|
|
||||||
|
|
||||||
function getNumberArray(num) {
|
function getNumberArray(num) {
|
||||||
return num
|
return num
|
||||||
|
@ -47,12 +46,12 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
count: syncWatch(function() {
|
count() {
|
||||||
this.lastCount = this.sCount;
|
this.lastCount = this.sCount;
|
||||||
this.setState({
|
this.setState({
|
||||||
animateStarted: true,
|
animateStarted: true,
|
||||||
});
|
});
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
const { animateStarted, count } = this;
|
const { animateStarted, count } = this;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import inputProps from './inputProps';
|
||||||
import { hasProp, getComponent, getOptionProps } from '../_util/props-util';
|
import { hasProp, getComponent, getOptionProps } from '../_util/props-util';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import ClearableLabeledInput from './ClearableLabeledInput';
|
import ClearableLabeledInput from './ClearableLabeledInput';
|
||||||
import syncWatch from '../_util/syncWatch';
|
|
||||||
|
|
||||||
export function fixControlledValue(value) {
|
export function fixControlledValue(value) {
|
||||||
if (typeof value === 'undefined' || value === null) {
|
if (typeof value === 'undefined' || value === null) {
|
||||||
|
@ -68,9 +67,9 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: syncWatch(function(val) {
|
value(val) {
|
||||||
this.stateValue = val;
|
this.stateValue = val;
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import BaseMixin from '../_util/BaseMixin';
|
||||||
import inputProps from './inputProps';
|
import inputProps from './inputProps';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import { getOptionProps } from '../_util/props-util';
|
import { getOptionProps } from '../_util/props-util';
|
||||||
import syncWatch from '../_util/syncWatch';
|
|
||||||
|
|
||||||
const RESIZE_STATUS_NONE = 0;
|
const RESIZE_STATUS_NONE = 0;
|
||||||
const RESIZE_STATUS_RESIZING = 1;
|
const RESIZE_STATUS_RESIZING = 1;
|
||||||
|
@ -39,11 +38,11 @@ const ResizableTextArea = {
|
||||||
raf.cancel(this.resizeFrameId);
|
raf.cancel(this.resizeFrameId);
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: syncWatch(function() {
|
value() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.resizeTextarea();
|
this.resizeTextarea();
|
||||||
});
|
});
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveTextArea(textArea) {
|
saveTextArea(textArea) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { hasProp, getOptionProps } from '../_util/props-util';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import { fixControlledValue, resolveOnChange } from './Input';
|
import { fixControlledValue, resolveOnChange } from './Input';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import syncWatch from '../_util/syncWatch';
|
|
||||||
|
|
||||||
const TextAreaProps = {
|
const TextAreaProps = {
|
||||||
...inputProps,
|
...inputProps,
|
||||||
|
@ -32,9 +31,9 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: syncWatch(function(val) {
|
value(val) {
|
||||||
this.stateValue = val;
|
this.stateValue = val;
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
|
@ -11,7 +11,6 @@ const ButtonType = buttonTypes().type;
|
||||||
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
||||||
import { initDefaultProps, getComponent, getSlot } from '../_util/props-util';
|
import { initDefaultProps, getComponent, getSlot } from '../_util/props-util';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import syncWatch from '../_util/syncWatch';
|
|
||||||
|
|
||||||
let mousePosition = null;
|
let mousePosition = null;
|
||||||
// ref: https://github.com/ant-design/ant-design/issues/15795
|
// ref: https://github.com/ant-design/ant-design/issues/15795
|
||||||
|
@ -107,9 +106,9 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
visible: syncWatch(function(val) {
|
visible(val) {
|
||||||
this.sVisible = val;
|
this.sVisible = val;
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import shallowEqualArrays from 'shallow-equal/arrays';
|
||||||
import { hasProp, getEvents } from '../_util/props-util';
|
import { hasProp, getEvents } from '../_util/props-util';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { cloneElement } from '../_util/vnode';
|
import { cloneElement } from '../_util/vnode';
|
||||||
import syncWatch from '../_util/syncWatch';
|
|
||||||
|
|
||||||
const BUILT_IN_PLACEMENTS = {
|
const BUILT_IN_PLACEMENTS = {
|
||||||
bottomLeft: {
|
bottomLeft: {
|
||||||
|
@ -100,7 +99,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: syncWatch(function(val, oldValue) {
|
value(val, oldValue) {
|
||||||
if (!shallowEqualArrays(val, oldValue)) {
|
if (!shallowEqualArrays(val, oldValue)) {
|
||||||
const newValues = {
|
const newValues = {
|
||||||
sValue: val || [],
|
sValue: val || [],
|
||||||
|
@ -112,12 +111,12 @@ export default {
|
||||||
}
|
}
|
||||||
this.setState(newValues);
|
this.setState(newValues);
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
popupVisible: syncWatch(function(val) {
|
popupVisible(val) {
|
||||||
this.setState({
|
this.setState({
|
||||||
sPopupVisible: val,
|
sPopupVisible: val,
|
||||||
});
|
});
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getPopupDOMNode() {
|
getPopupDOMNode() {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import BodyTable from './BodyTable';
|
||||||
import ExpandableTable from './ExpandableTable';
|
import ExpandableTable from './ExpandableTable';
|
||||||
import { initDefaultProps, getOptionProps } from '../../_util/props-util';
|
import { initDefaultProps, getOptionProps } from '../../_util/props-util';
|
||||||
import BaseMixin from '../../_util/BaseMixin';
|
import BaseMixin from '../../_util/BaseMixin';
|
||||||
import syncWatch from '../../_util/syncWatch';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
|
@ -129,11 +128,11 @@ export default {
|
||||||
this.components,
|
this.components,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
columns: syncWatch(function(val) {
|
columns(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.columnManager.reset(val);
|
this.columnManager.reset(val);
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
data(val) {
|
data(val) {
|
||||||
if (val.length === 0 && this.hasScrollX()) {
|
if (val.length === 0 && this.hasScrollX()) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import warning from 'warning';
|
||||||
import { hasProp, initDefaultProps, getOptionProps, getSlot } from '../../_util/props-util';
|
import { hasProp, initDefaultProps, getOptionProps, getSlot } from '../../_util/props-util';
|
||||||
import { cloneElement } from '../../_util/vnode';
|
import { cloneElement } from '../../_util/vnode';
|
||||||
import BaseMixin from '../../_util/BaseMixin';
|
import BaseMixin from '../../_util/BaseMixin';
|
||||||
import syncWatch from '../../_util/syncWatch';
|
|
||||||
import {
|
import {
|
||||||
convertTreeToEntities,
|
convertTreeToEntities,
|
||||||
convertDataToTree,
|
convertDataToTree,
|
||||||
|
@ -153,10 +152,10 @@ const Tree = {
|
||||||
'checkedKeys',
|
'checkedKeys',
|
||||||
'loadedKeys',
|
'loadedKeys',
|
||||||
]),
|
]),
|
||||||
__propsSymbol__: syncWatch(function() {
|
__propsSymbol__() {
|
||||||
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
|
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
|
||||||
this.needSyncKeys = {};
|
this.needSyncKeys = {};
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in New Issue