Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 6f74efb

Browse files
JiaLiPassionmhevery
authored andcommittedSep 17, 2017
fix(event): fix #883, fix RTCPeerConnection Safari event not triggered issue (#905)
1 parent 8718e07 commit 6f74efb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
 

‎gulpfile.js

+10
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ gulp.task('build/webapis-notification.min.js', ['compile-esm'], function(cb) {
137137
return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb);
138138
});
139139

140+
gulp.task('build/webapis-rtc-peer-connection.js', ['compile-esm'], function(cb) {
141+
return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb);
142+
});
143+
144+
gulp.task('build/webapis-rtc-peer-connection.min.js', ['compile-esm'], function(cb) {
145+
return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true, cb);
146+
});
147+
140148
gulp.task('build/webapis-shadydom.js', ['compile-esm'], function(cb) {
141149
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb);
142150
});
@@ -245,6 +253,8 @@ gulp.task('build', [
245253
'build/webapis-media-query.min.js',
246254
'build/webapis-notification.js',
247255
'build/webapis-notification.min.js',
256+
'build/webapis-rtc-peer-connection.js',
257+
'build/webapis-rtc-peer-connection.min.js',
248258
'build/webapis-shadydom.js',
249259
'build/webapis-shadydom.min.js',
250260
'build/zone-patch-cordova.js',
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
Zone.__load_patch('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
9+
const RTCPeerConnection = global['RTCPeerConnection'];
10+
if (!RTCPeerConnection) {
11+
return;
12+
}
13+
14+
const addSymbol = api.symbol('addEventListener');
15+
const removeSymbol = api.symbol('removeEventListener');
16+
17+
RTCPeerConnection.prototype.addEventListener = RTCPeerConnection.prototype[addSymbol];
18+
RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol];
19+
20+
// RTCPeerConnection extends EventTarget, so we must clear the symbol
21+
// to allow pathc RTCPeerConnection.prototype.addEventListener again
22+
RTCPeerConnection.prototype[addSymbol] = null;
23+
RTCPeerConnection.prototype[removeSymbol] = null;
24+
25+
api.patchEventTarget(global, [RTCPeerConnection.prototype], {useGlobalCallback: false});
26+
});

0 commit comments

Comments
 (0)