Javascript 修改HtmleElement.prototype.addEventListener时,Angular 2应用程序中断
我正在尝试使用一些JS monkey补丁为应用程序添加工具。我正在测试我的猴子补丁使用。但是,当我尝试使用Javascript 修改HtmleElement.prototype.addEventListener时,Angular 2应用程序中断,javascript,angular,Javascript,Angular,我正在尝试使用一些JS monkey补丁为应用程序添加工具。我正在测试我的猴子补丁使用。但是,当我尝试使用HTMLElement.addEventListener函数做最简单的事情时,它会破坏应用程序。例如,执行以下操作: (function() { var originalAEL = HTMLElement.prototype.addEventListener; HTMLElement.prototype.addEventListener = originalA
HTMLElement.addEventListener
函数做最简单的事情时,它会破坏应用程序。例如,执行以下操作:
(function() {
var originalAEL = HTMLElement.prototype.addEventListener;
HTMLElement.prototype.addEventListener = originalAEL;
})();
断开应用程序-组件的模板无法找到组件类中绑定的任何值。这里可能会发生什么?用
EventTarget
替换HTMLElement
有效-我不知道为什么。原始标签的价值是什么?HTMLElement.prototype.hasOwnProperty(“addEventListener”)
在分配前后产生了什么?HTMLElement.prototype.hasOwnProperty(“addEventListener”)
返回false
originalAEL
打印为function addEventListener(){[native code]}
将HTMLElement
替换为EventTarget
有效!