Skip to content

Commit a13e362

Browse files
committed
fix(copy): support copying MediaStream object
use MediaStream clone method to clone mediastream object Closes angular#16055
1 parent e58bcfa commit a13e362

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Angular.js

+3
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,9 @@ function copy(source, destination, maxDepth) {
10051005

10061006
case '[object Blob]':
10071007
return new source.constructor([source], {type: source.type});
1008+
1009+
case '[object MediaStream]':
1010+
return source.clone();
10081011
}
10091012

10101013
if (isFunction(source.cloneNode)) {

test/AngularSpec.js

+12
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,18 @@ describe('angular', function() {
603603
/* eslint-enable */
604604
});
605605

606+
it('should copy media stream objects', function() {
607+
var source = new window.MediaStream();
608+
var destination = copy(source);
609+
610+
expect(destination.id).toMatch(/^((\w+)-){4}(\w+)$/);
611+
expect(typeof destination.active).toBe('boolean');
612+
expect(source.id).not.toBe(destination.id);
613+
expect(source.active).toBe(destination.active);
614+
615+
616+
});
617+
606618
it('should copy source until reaching a given max depth', function() {
607619
var source = {a1: 1, b1: {b2: {b3: 1}}, c1: [1, {c2: 1}], d1: {d2: 1}};
608620
var dest;

0 commit comments

Comments
 (0)