webfansplz / vite-plugin-vue-inspector

jump to editor source code while click the element of browser automatically.
MIT License
698 stars 74 forks source link

toggleEventListener runtime error #68

Closed XinChou16 closed 1 year ago

XinChou16 commented 1 year ago

Our project use element-ui, and it hack eventlistener, while overlay.vue js code bind event listener whithou check this

element-ui

var hackEventListener = () => {
  Element.prototype._addEventListener = Element.prototype.addEventListener;
  Element.prototype._removeEventListener = Element.prototype.removeEventListener;
  Element.prototype.addEventListener = function(type, listener, useCapture = false) {
    this._addEventListener(type, listener, useCapture);
    if (!this.__eventListenerList__) {
      this.__eventListenerList__ = {};
    }
    if (!this.__eventListenerList__[type]) {
      this.__eventListenerList__[type] = [];
    }
    this.__eventListenerList__[type].push({ type, listener, useCapture });
  };
  Element.prototype.removeEventListener = function(type, listener, useCapture = false) {
    this._removeEventListener(type, listener, useCapture);
    //...
  }

overlay.vue

toggleEventListener() {
      const listener = this.enabled ? document.body.addEventListener : document.body.removeEventListener
      listener?.('mousemove', this.updateLinkParams)
      listener?.('click', this.handleClick, true)
    },