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

Commit

Permalink
fix(event): fix #883, fix RTCPeerConnection Safari event not triggere…
Browse files Browse the repository at this point in the history
…d issue (#905)
  • Loading branch information
JiaLiPassion authored and mhevery committed Sep 17, 2017
1 parent 8718e07 commit 6f74efb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ gulp.task('build/webapis-notification.min.js', ['compile-esm'], function(cb) {
return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb);
});

gulp.task('build/webapis-rtc-peer-connection.js', ['compile-esm'], function(cb) {
return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb);
});

gulp.task('build/webapis-rtc-peer-connection.min.js', ['compile-esm'], function(cb) {
return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true, cb);
});

gulp.task('build/webapis-shadydom.js', ['compile-esm'], function(cb) {
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb);
});
Expand Down Expand Up @@ -245,6 +253,8 @@ gulp.task('build', [
'build/webapis-media-query.min.js',
'build/webapis-notification.js',
'build/webapis-notification.min.js',
'build/webapis-rtc-peer-connection.js',
'build/webapis-rtc-peer-connection.min.js',
'build/webapis-shadydom.js',
'build/webapis-shadydom.min.js',
'build/zone-patch-cordova.js',
Expand Down
26 changes: 26 additions & 0 deletions lib/browser/webapis-rtc-peer-connection.ts
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});
});

0 comments on commit 6f74efb

Please sign in to comment.