我注意到在禁用引导加载项后,removeEventListener
似乎没有删除侦听器,我无法找出原因。
let contextMenu = window.document.getElementById('contentAreaContextMenu');
if (contextMenu) {
contextMenu.addEventListener('popupshowing',
this.contextPopupShowing.bind(this), false);
// added this to make sure they refer to the same function
console.log(this.contextPopupShowing.toString());
}
然后禁用插件
console.log(this.contextPopupShowing.toString()); // same as above
this.contextMenu.removeEventListener('popupshowing',
this.contextPopupShowing.bind(this), false);
// just showing that 'this' is working
this.contextMenu.removeChild(this.menuitem);
最后 ...
contextPopupShowing: function() {
// logs even after removeEventListener
console.log('contextPopupShowing called');
// more code
},