This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(event): fix #883, fix RTCPeerConnection Safari event not triggere…
…d issue (#905)
- Loading branch information
1 parent
8718e07
commit 6f74efb
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. 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 pathc RTCPeerConnection.prototype.addEventListener again | ||
RTCPeerConnection.prototype[addSymbol] = null; | ||
RTCPeerConnection.prototype[removeSymbol] = null; | ||
|
||
api.patchEventTarget(global, [RTCPeerConnection.prototype], {useGlobalCallback: false}); | ||
}); |