Blame view

apps/directives/tap.js 321 Bytes
陈峰 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
const bingFn = (fn) => {
  return function(evt) {
    fn(evt);
    evt.preventDefault();
    evt.stopPropagation();
  };
};

export default {
  bind(el, binding) {
    el.addEventListener('e-click', bingFn(binding.value));
  },
  unbind(el, binding) {
    el.removeEventListener('e-click', bingFn(binding.value));
  }
};