update Select

support IE9
This commit is contained in:
梁灏 2017-03-30 11:52:36 +08:00
parent 345c6863bf
commit ed91d9b0c7
3 changed files with 49 additions and 34 deletions

View file

@ -36,7 +36,7 @@
import Icon from '../icon';
import Drop from './dropdown.vue';
import clickoutside from '../../directives/clickoutside';
import { oneOf, MutationObserver, findComponentDownward } from '../../utils/assist';
import { oneOf, findComponentDownward } from '../../utils/assist';
import { t } from '../../locale';
import Emitter from '../../mixins/emitter';
@ -506,22 +506,16 @@
this.updateOptions(true);
document.addEventListener('keydown', this.handleKeydown);
// watch slot changed
// todo child mounted beforeDestroy
if (MutationObserver) {
this.observer = new MutationObserver(() => {
this.modelToQuery();
this.slotChange();
this.updateOptions(true, true);
});
this.observer.observe(this.$refs.options, {
// attributes: true,
childList: true,
characterData: true,
subtree: true
});
}
this.$on('append', () => {
this.modelToQuery();
this.slotChange();
this.updateOptions(true, true);
});
this.$on('remove', () => {
this.modelToQuery();
this.slotChange();
this.updateOptions(true, true);
});
this.$on('on-select-selected', (value) => {
if (this.model === value) {
@ -556,9 +550,6 @@
},
beforeDestroy () {
document.removeEventListener('keydown', this.handleKeydown);
if (this.observer) {
this.observer.disconnect();
}
},
watch: {
value (val) {