/
githubmirror
/
element
Обзор
Документация
Войти
/
githubmirror
/
element
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/table/src/dropdown.js
28 строк
650 B
qingwei.li
SSR feature
26 дек 2016, 05:45
26 дек 2016, 05:45
daec90a
Код
Авторство
О чём код?
import Vue from 'vue'; var dropdowns = []; !Vue.prototype.$isServer && document.addEventListener('click', function(event) { dropdowns.forEach(function(dropdown) { var target = event.target; if (!dropdown || !dropdown.$el) return; if (target === dropdown.$el || dropdown.$el.contains(target)) { return; } dropdown.handleOutsideClick && dropdown.handleOutsideClick(event); }); }); export default { open(instance) { if (instance) { dropdowns.push(instance); } }, close(instance) { var index = dropdowns.indexOf(instance); if (index !== -1) { dropdowns.splice(instance, 1); } } };