angular-cn/packages/zone.js/lib/browser/webapis-rtc-peer-connection.ts
Andrew Kushnir d58747de8a Revert "fix(zone.js): should continue to executue listeners when throw error (#41562)" (#41707)
This reverts commit 5c48cd30b5e0d871adb8e72d4defa643495aa4ca.

Reason: that change introduces race conditions on CI.

PR Close #41707
2021-04-19 13:33:10 -07:00

27 lines
1020 B
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Zone.__load_patch('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
const RTCPeerConnection = global['RTCPeerConnection'];
if (!RTCPeerConnection) {
return;
}
const addSymbol = api.symbol('addEventListener');
const removeSymbol = api.symbol('removeEventListener');
RTCPeerConnection.prototype.addEventListener = RTCPeerConnection.prototype[addSymbol];
RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol];
// RTCPeerConnection extends EventTarget, so we must clear the symbol
// to allow patch RTCPeerConnection.prototype.addEventListener again
RTCPeerConnection.prototype[addSymbol] = null;
RTCPeerConnection.prototype[removeSymbol] = null;
api.patchEventTarget(global, [RTCPeerConnection.prototype], {useG: false});
});