修补元件.prototype.AddeventListener都会打破任何Angular 2应用程序



我有一个Angular 2 App https://github.com/danwahlin/angular-jumpstart。我尝试为我的某些用例来修补元素。prototype.addeventlistener。

这是补丁:

var origLis = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(type, handler, useCapture) {
    console.log("Added");
    return origLis.apply(this, arguments);
}

如果我修补 element.prototype.addeventlistener ,它会打破Angular 2应用程序。该应用程序中没有发送资源/XHR。我在许多Angular 2应用程序上尝试了此操作。但是,同样的结果。控制台中没有错误

有人知道为什么会发生这种情况,并且是否有解决方法?

ps:我不想修补 eventtarget.prototype.addeventlistener ,如下所述

htmlelement.prototype.addeventlistener被修改

时,Angular 2应用程序会破裂。

如果您尝试使用monkey-patch addeventListener,请不要在element.protype上进行操作。在Angular,Zone.js Monkey-Patch EventTarget.Prototype.AddeventListener以使更改检测工作,因此,如果您修改元素。

最新更新