Skip to content

Commit 4e65ae0

Browse files
committed
perf: update listeners
1 parent 20ff341 commit 4e65ae0

File tree

89 files changed

+257
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+257
-215
lines changed

build/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
devComponent: 'table',
2+
devComponent: 'menu',
33
};

components/date-picker/RangePicker.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
mergeProps,
1616
getComponentFromProp,
1717
isValidElement,
18+
getListeners,
1819
} from '../_util/props-util';
1920
import BaseMixin from '../_util/BaseMixin';
2021
import { cloneElement } from '../_util/vnode';
@@ -262,16 +263,16 @@ export default {
262263
sShowDate: showDate,
263264
sHoverValue: hoverValue,
264265
sOpen: open,
265-
$listeners,
266266
$scopedSlots,
267267
} = this;
268+
const listeners = getListeners(this);
268269
const {
269270
calendarChange = noop,
270271
ok = noop,
271272
focus = noop,
272273
blur = noop,
273274
panelChange = noop,
274-
} = $listeners;
275+
} = listeners;
275276
const {
276277
prefixCls: customizePrefixCls,
277278
tagPrefixCls: customizeTagPrefixCls,
@@ -407,7 +408,7 @@ export default {
407408
const vcDatePickerProps = mergeProps(
408409
{
409410
props,
410-
on: $listeners,
411+
on: listeners,
411412
},
412413
pickerChangeHandler,
413414
{

components/date-picker/WeekPicker.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
initDefaultProps,
1010
getComponentFromProp,
1111
isValidElement,
12+
getListeners,
1213
} from '../_util/props-util';
1314
import BaseMixin from '../_util/BaseMixin';
1415
import { WeekPickerProps } from './interface';
@@ -149,16 +150,15 @@ export default {
149150
localeCode,
150151
disabledDate,
151152
$data,
152-
$listeners,
153153
$scopedSlots,
154154
} = this;
155-
155+
const listeners = getListeners(this);
156156
const getPrefixCls = this.configProvider.getPrefixCls;
157157
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
158158
this._prefixCls = prefixCls;
159159

160160
const { _value: pickerValue, _open: open } = $data;
161-
const { focus = noop, blur = noop } = $listeners;
161+
const { focus = noop, blur = noop } = listeners;
162162

163163
if (pickerValue && localeCode) {
164164
pickerValue.locale(localeCode);
@@ -225,7 +225,7 @@ export default {
225225
open,
226226
},
227227
on: {
228-
...$listeners,
228+
...listeners,
229229
change: this.handleChange,
230230
openChange: this.handleOpenChange,
231231
},

components/date-picker/wrapPicker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from 'classnames';
33
import LocaleReceiver from '../locale-provider/LocaleReceiver';
44
import { generateShowHourMinuteSecond } from '../time-picker';
55
import enUS from './locale/en_US';
6-
import { getOptionProps, initDefaultProps } from '../_util/props-util';
6+
import { getOptionProps, initDefaultProps, getListeners } from '../_util/props-util';
77
import { ConfigConsumerProps } from '../config-provider';
88

99
const DEFAULT_FORMAT = {
@@ -168,7 +168,7 @@ export default function wrapPicker(Picker, props, pickerType) {
168168
timePicker,
169169
},
170170
on: {
171-
...this.$listeners,
171+
...getListeners(this),
172172
openChange: this.handleOpenChange,
173173
focus: this.handleFocus,
174174
blur: this.handleBlur,

components/drawer/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import VcDrawer from '../vc-drawer/src';
33
import PropTypes from '../_util/vue-types';
44
import BaseMixin from '../_util/BaseMixin';
55
import Icon from '../icon';
6-
import { getComponentFromProp, getOptionProps } from '../_util/props-util';
6+
import { getComponentFromProp, getOptionProps, getListeners } from '../_util/props-util';
77
import { ConfigConsumerProps } from '../config-provider';
88
import Base from '../base';
99

@@ -214,7 +214,7 @@ const Drawer = {
214214
},
215215
on: {
216216
maskClick: this.onMaskClick,
217-
...this.$listeners,
217+
...getListeners(this),
218218
},
219219
};
220220
return <VcDrawer {...vcDrawerProps}>{this.renderBody(prefixCls)}</VcDrawer>;

components/dropdown/dropdown.jsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import RcDropdown from '../vc-dropdown/src/index';
22
import DropdownButton from './dropdown-button';
33
import PropTypes from '../_util/vue-types';
44
import { cloneElement } from '../_util/vnode';
5-
import { getOptionProps, getPropsData, getComponentFromProp } from '../_util/props-util';
5+
import {
6+
getOptionProps,
7+
getPropsData,
8+
getComponentFromProp,
9+
getListeners,
10+
} from '../_util/props-util';
611
import getDropdownProps from './getDropdownProps';
712
import { ConfigConsumerProps } from '../config-provider';
813
import Icon from '../icon';
@@ -72,7 +77,7 @@ const Dropdown = {
7277
},
7378

7479
render() {
75-
const { $slots, $listeners } = this;
80+
const { $slots } = this;
7681
const props = getOptionProps(this);
7782
const { prefixCls: customizePrefixCls, trigger, disabled, getPopupContainer } = props;
7883
const { getPopupContainer: getContextPopupContainer } = this.configProvider;
@@ -99,7 +104,7 @@ const Dropdown = {
99104
transitionName: this.getTransitionName(),
100105
trigger: triggerActions,
101106
},
102-
on: $listeners,
107+
on: getListeners(this),
103108
};
104109
return (
105110
<RcDropdown {...dropdownProps}>

components/empty/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from '../_util/vue-types';
22
import { ConfigConsumerProps } from '../config-provider';
3-
import { getComponentFromProp } from '../_util/props-util';
3+
import { getComponentFromProp, getListeners } from '../_util/props-util';
44
import LocaleReceiver from '../locale-provider/LocaleReceiver';
55
import emptyImg from './empty.svg';
66
import Base from '../base';
@@ -43,7 +43,7 @@ const Empty = {
4343
imageNode = image;
4444
}
4545
return (
46-
<div class={prefixCls} {...{ on: this.$listeners }}>
46+
<div class={prefixCls} {...{ on: getListeners(this) }}>
4747
<div class={`${prefixCls}-image`}>{imageNode}</div>
4848
<p class={`${prefixCls}-description`}>{des}</p>
4949
{this.$slots.default && <div class={`${prefixCls}-footer`}>{this.$slots.default}</div>}

components/form/Form.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import createDOMForm from '../vc-form/src/createDOMForm';
88
import createFormField from '../vc-form/src/createFormField';
99
import FormItem from './FormItem';
1010
import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants';
11-
import { initDefaultProps } from '../_util/props-util';
11+
import { initDefaultProps, getListeners } from '../_util/props-util';
1212
import { ConfigConsumerProps } from '../config-provider';
1313
import Base from '../base';
1414

@@ -192,8 +192,7 @@ const Form = {
192192
},
193193
methods: {
194194
onSubmit(e) {
195-
const { $listeners } = this;
196-
if (!$listeners.submit) {
195+
if (!getListeners(this).submit) {
197196
e.preventDefault();
198197
} else {
199198
this.$emit('submit', e);

components/grid/Col.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import PropTypes from '../_util/vue-types';
22
import { ConfigConsumerProps } from '../config-provider';
3+
import { getListeners } from '../_util/props-util';
34

45
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
56

@@ -46,7 +47,6 @@ export default {
4647
pull,
4748
prefixCls: customizePrefixCls,
4849
$slots,
49-
$listeners,
5050
rowContext,
5151
} = this;
5252
const getPrefixCls = this.configProvider.getPrefixCls;
@@ -80,7 +80,7 @@ export default {
8080
...sizeClassObj,
8181
};
8282
const divProps = {
83-
on: $listeners,
83+
on: getListeners(this),
8484
class: classes,
8585
style: {},
8686
};

components/input-number/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from '../_util/vue-types';
2-
import { initDefaultProps, getOptionProps } from '../_util/props-util';
2+
import { initDefaultProps, getOptionProps, getListeners } from '../_util/props-util';
33
import classNames from 'classnames';
44
import Icon from '../icon';
55
import VcInputNumber from '../vc-input-number/src';
@@ -68,7 +68,7 @@ const InputNumber = {
6868
},
6969
class: inputNumberClass,
7070
ref: 'inputNumberRef',
71-
on: this.$listeners,
71+
on: getListeners(this),
7272
};
7373
return <VcInputNumber {...vcInputNumberprops} />;
7474
},

components/input/Group.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from '../_util/vue-types';
2-
import { filterEmpty } from '../_util/props-util';
2+
import { filterEmpty, getListeners } from '../_util/props-util';
33
import { ConfigConsumerProps } from '../config-provider';
44

55
export default {
@@ -32,9 +32,8 @@ export default {
3232
},
3333
methods: {},
3434
render() {
35-
const { $listeners } = this;
3635
return (
37-
<span class={this.classes} {...{ on: $listeners }}>
36+
<span class={this.classes} {...{ on: getListeners(this) }}>
3837
{filterEmpty(this.$slots.default)}
3938
</span>
4039
);

components/input/Input.jsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import classNames from 'classnames';
22
import TextArea from './TextArea';
33
import omit from 'omit.js';
44
import inputProps from './inputProps';
5-
import { hasProp, getComponentFromProp } from '../_util/props-util';
5+
import { hasProp, getComponentFromProp, getListeners } from '../_util/props-util';
66
import { ConfigConsumerProps } from '../config-provider';
77
import Icon from '../icon';
88

@@ -234,15 +234,15 @@ export default {
234234
'defaultValue',
235235
'lazy',
236236
]);
237-
const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this;
237+
const { stateValue, getInputClassName, handleKeyDown, handleChange } = this;
238238
const inputProps = {
239239
directives: [{ name: 'ant-input' }],
240240
domProps: {
241241
value: fixControlledValue(stateValue),
242242
},
243243
attrs: { ...otherProps, ...this.$attrs },
244244
on: {
245-
...$listeners,
245+
...getListeners(this),
246246
keydown: handleKeyDown,
247247
input: handleChange,
248248
change: noop,
@@ -256,12 +256,11 @@ export default {
256256
},
257257
render() {
258258
if (this.$props.type === 'textarea') {
259-
const { $listeners } = this;
260259
const textareaProps = {
261260
props: this.$props,
262261
attrs: this.$attrs,
263262
on: {
264-
...$listeners,
263+
...getListeners(this),
265264
input: this.handleChange,
266265
keydown: this.handleKeyDown,
267266
change: noop,

components/input/Password.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import { getComponentFromProp, getOptionProps } from '../_util/props-util';
2+
import { getComponentFromProp, getOptionProps, getListeners } from '../_util/props-util';
33
import Input from './Input';
44
import Icon from '../icon';
55
import inputProps from './inputProps';
@@ -93,7 +93,7 @@ export default {
9393
},
9494
class: inputClassName,
9595
ref: 'input',
96-
on: this.$listeners,
96+
on: getListeners(this),
9797
};
9898
return <Input {...inputProps} />;
9999
},

components/input/Search.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Icon from '../icon';
44
import inputProps from './inputProps';
55
import Button from '../button';
66
import { cloneElement } from '../_util/vnode';
7-
import { getOptionProps, getComponentFromProp, isValidElement } from '../_util/props-util';
7+
import { getOptionProps, getComponentFromProp, getListeners } from '../_util/props-util';
88
import PropTypes from '../_util/vue-types';
99
import { ConfigConsumerProps } from '../config-provider';
1010

@@ -119,7 +119,7 @@ export default {
119119
inputClassName = prefixCls;
120120
}
121121

122-
const on = { ...this.$listeners };
122+
const on = { ...getListeners(this) };
123123
delete on.search;
124124
const inputProps = {
125125
props: {

components/input/TextArea.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import omit from 'omit.js';
33
import ResizeObserver from 'resize-observer-polyfill';
44
import inputProps from './inputProps';
55
import calculateNodeHeight from './calculateNodeHeight';
6-
import hasProp from '../_util/props-util';
6+
import hasProp, { getListeners } from '../_util/props-util';
77
import { ConfigConsumerProps } from '../config-provider';
88

99
function onNextFrame(cb) {
@@ -146,7 +146,6 @@ export default {
146146
handleTextareaChange,
147147
textareaStyles,
148148
$attrs,
149-
$listeners,
150149
prefixCls: customizePrefixCls,
151150
disabled,
152151
} = this;
@@ -169,7 +168,7 @@ export default {
169168
directives: [{ name: 'ant-input' }],
170169
attrs: { ...otherProps, ...$attrs },
171170
on: {
172-
...$listeners,
171+
...getListeners(this),
173172
keydown: handleKeyDown,
174173
input: handleTextareaChange,
175174
change: noop,

components/layout/layout.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from '../_util/vue-types';
22
import classNames from 'classnames';
3-
import { getOptionProps } from '../_util/props-util';
3+
import { getOptionProps, getListeners } from '../_util/props-util';
44
import { ConfigConsumerProps } from '../config-provider';
55

66
export const BasicProps = {
@@ -27,7 +27,7 @@ function generator(props, name) {
2727
prefixCls,
2828
...getOptionProps(this),
2929
},
30-
on: this.$listeners,
30+
on: getListeners(this),
3131
};
3232
return <BasicComponent {...basicComponentProps}>{this.$slots.default}</BasicComponent>;
3333
},
@@ -38,10 +38,10 @@ function generator(props, name) {
3838
const Basic = {
3939
props: BasicProps,
4040
render() {
41-
const { prefixCls, $slots, $listeners } = this;
41+
const { prefixCls, $slots } = this;
4242
const divProps = {
4343
class: prefixCls,
44-
on: $listeners,
44+
on: getListeners(this),
4545
};
4646
return <div {...divProps}>{$slots.default}</div>;
4747
},
@@ -67,13 +67,13 @@ const BasicLayout = {
6767
};
6868
},
6969
render() {
70-
const { prefixCls, $slots, hasSider, $listeners } = this;
70+
const { prefixCls, $slots, hasSider } = this;
7171
const divCls = classNames(prefixCls, {
7272
[`${prefixCls}-has-sider`]: hasSider || this.siders.length > 0,
7373
});
7474
const divProps = {
7575
class: divCls,
76-
on: $listeners,
76+
on: getListeners,
7777
};
7878
return <div {...divProps}>{$slots.default}</div>;
7979
},

0 commit comments

Comments
 (0)