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

fix(event): fix #883, fix RTCPeerConnection Safari event not triggered issue. #905

Merged
merged 1 commit into from
Sep 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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});
});