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

fix(copy): support copying MediaStream object #16061

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,9 @@ function copy(source, destination, maxDepth) {

case '[object Blob]':
return new source.constructor([source], {type: source.type});

case '[object MediaStream]':
return source.clone();
}

if (isFunction(source.cloneNode)) {
Expand Down
12 changes: 12 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,18 @@ describe('angular', function() {
/* eslint-enable */
});

it('should copy media stream objects', function() {
var source = new MediaStream();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all browsers support MediaStream (which seems to cause Travis to fail).

var destination = copy(source);

expect(destination.id).toMatch(/^((\w+)-){4}(\w+)$/);
expect(typeof destination.active).toBe('boolean');
expect(source.id).not.toBe(destination.id);
expect(source.active).toBe(destination.active);


});

it('should copy source until reaching a given max depth', function() {
var source = {a1: 1, b1: {b2: {b3: 1}}, c1: [1, {c2: 1}], d1: {d2: 1}};
var dest;
Expand Down