perf: trigger event

This commit is contained in:
tanjinzhou 2020-07-24 14:30:52 +08:00
parent a50dba12aa
commit 29366a251f
2 changed files with 6 additions and 7 deletions

View File

@ -1,5 +1,4 @@
import { getOptionProps } from './props-util';
import { isOn } from './util';
export default {
methods: {
@ -25,13 +24,10 @@ export default {
});
},
__emit() {
// 直接调用listeners底层组件不需要vueTool记录events
// 直接调用事件底层组件不需要vueTool记录events
const args = [].slice.call(arguments, 0);
let eventName = args[0];
// TODO: 后续统一改成onXxxx不在运行时转提升性能
eventName = isOn(eventName)
? eventName
: `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
const event = this.$props[eventName] || this.$attrs[eventName];
if (args.length && event) {
if (Array.isArray(event)) {

View File

@ -568,7 +568,10 @@ export default {
if (this.childOriginEvents[type]) {
this.childOriginEvents[type](e);
}
this.__emit(type, e);
const event = this.$props[type] || this.$attrs[type];
if (event) {
event(e);
}
},
close() {