optimize Select event broadcast

optimize Select event broadcast
This commit is contained in:
梁灏 2017-03-13 19:33:52 +08:00
parent 04e5e3cd29
commit a9131058ab
3 changed files with 48 additions and 6 deletions

View file

@ -36,7 +36,7 @@
import Icon from '../icon';
import Drop from './dropdown.vue';
import clickoutside from '../../directives/clickoutside';
import { oneOf, MutationObserver } from '../../utils/assist';
import { oneOf, MutationObserver, findComponentDownward } from '../../utils/assist';
import { t } from '../../locale';
import Emitter from '../../mixins/emitter';
@ -507,6 +507,7 @@
document.addEventListener('keydown', this.handleKeydown);
// watch slot changed
// todo child mounted beforeDestroy
if (MutationObserver) {
this.observer = new MutationObserver(() => {
this.modelToQuery();
@ -590,9 +591,12 @@
}
},
query (val) {
// todo
this.broadcast('OptionGroup', 'on-query-change', val);
this.broadcast('iOption', 'on-query-change', val);
if (findComponentDownward(this, 'OptionGroup')) {
this.broadcast('OptionGroup', 'on-query-change', val);
this.broadcast('iOption', 'on-query-change', val);
} else {
this.broadcast('iOption', 'on-query-change', val);
}
let is_hidden = true;
this.$nextTick(() => {