Skip to content

Commit f641c0f

Browse files
committed
remove merge-options in favor of obj.merge
1 parent a5fd093 commit f641c0f

18 files changed

+86
-104
lines changed

src/js/component.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Dom from './utils/dom.js';
1010
import * as Fn from './utils/fn.js';
1111
import * as Guid from './utils/guid.js';
1212
import {toTitleCase, toLowerCase} from './utils/str.js';
13-
import mergeOptions from './utils/merge-options.js';
13+
import {merge} from './utils/obj.js';
1414
import computedStyle from './utils/computed-style';
1515
import Map from './utils/map.js';
1616
import Set from './utils/set.js';
@@ -69,10 +69,10 @@ class Component {
6969
this.parentComponent_ = null;
7070

7171
// Make a copy of prototype.options_ to protect against overriding defaults
72-
this.options_ = mergeOptions({}, this.options_);
72+
this.options_ = merge({}, this.options_);
7373

7474
// Updated options with supplied options
75-
options = this.options_ = mergeOptions(this.options_, options);
75+
options = this.options_ = merge(this.options_, options);
7676

7777
// Get ID from options or options element if one is supplied
7878
this.id_ = options.id || (options.el && options.el.id);
@@ -215,7 +215,7 @@ class Component {
215215
/**
216216
* Deep merge of options objects with new options.
217217
* > Note: When both `obj` and `options` contain properties whose values are objects.
218-
* The two properties get merged using {@link module:mergeOptions}
218+
* The two properties get merged using {@link module:obj.merge}
219219
*
220220
* @param {Object} obj
221221
* The object that contains new options.
@@ -228,7 +228,7 @@ class Component {
228228
return this.options_;
229229
}
230230

231-
this.options_ = mergeOptions(this.options_, obj);
231+
this.options_ = merge(this.options_, obj);
232232
return this.options_;
233233
}
234234

src/js/live-tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Component from './component.js';
2-
import mergeOptions from './utils/merge-options.js';
2+
import {merge} from './utils/obj.js';
33
import document from 'global/document';
44
import * as browser from './utils/browser.js';
55
import window from 'global/window';
@@ -40,7 +40,7 @@ class LiveTracker extends Component {
4040
*/
4141
constructor(player, options) {
4242
// LiveTracker does not need an element
43-
const options_ = mergeOptions(defaults, options, {createEl: false});
43+
const options_ = merge(defaults, options, {createEl: false});
4444

4545
super(player, options_);
4646

src/js/player.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import * as stylesheet from './utils/stylesheet.js';
2323
import FullscreenApi from './fullscreen-api.js';
2424
import MediaError from './media-error.js';
2525
import safeParseTuple from 'safe-json-parse/tuple';
26-
import {assign} from './utils/obj';
27-
import mergeOptions from './utils/merge-options.js';
2826
import {silencePromise, isPromise} from './utils/promise';
2927
import textTrackConverter from './tracks/text-track-list-converter.js';
3028
import ModalDialog from './modal-dialog';
@@ -34,7 +32,7 @@ import {ALL as TRACK_TYPES} from './tracks/track-types';
3432
import filterSource from './utils/filter-source';
3533
import {getMimetype, findMimetype} from './utils/mimetypes';
3634
import {hooks} from './utils/hooks';
37-
import {isObject} from './utils/obj';
35+
import {assign, merge, isObject} from './utils/obj';
3836
import keycode from 'keycode';
3937

4038
// The following imports are used only to ensure that the corresponding modules
@@ -504,7 +502,7 @@ class Player extends Component {
504502
// as well so they don't need to reach back into the player for options later.
505503
// We also need to do another copy of this.options_ so we don't end up with
506504
// an infinite loop.
507-
const playerOptionsCopy = mergeOptions(this.options_);
505+
const playerOptionsCopy = merge(this.options_);
508506

509507
// Load plugins
510508
if (options.plugins) {
@@ -1535,7 +1533,7 @@ class Player extends Component {
15351533
}
15361534

15371535
// update `currentSource` cache always
1538-
this.cache_.source = mergeOptions({}, srcObj, {src, type});
1536+
this.cache_.source = merge({}, srcObj, {src, type});
15391537

15401538
const matchingSources = this.cache_.sources.filter((s) => s.src && s.src === src);
15411539
const sourceElSources = [];
@@ -4648,7 +4646,7 @@ class Player extends Component {
46484646
* An array of of supported languages
46494647
*/
46504648
languages() {
4651-
return mergeOptions(Player.prototype.options_.languages, this.languages_);
4649+
return merge(Player.prototype.options_.languages, this.languages_);
46524650
}
46534651

46544652
/**
@@ -4659,7 +4657,7 @@ class Player extends Component {
46594657
* Object representing the current of track info
46604658
*/
46614659
toJSON() {
4662-
const options = mergeOptions(this.options_);
4660+
const options = merge(this.options_);
46634661
const tracks = options.tracks;
46644662

46654663
options.tracks = [];
@@ -4668,7 +4666,7 @@ class Player extends Component {
46684666
let track = tracks[i];
46694667

46704668
// deep merge tracks and null out player so no circular references
4671-
track = mergeOptions(track);
4669+
track = merge(track);
46724670
track.player = undefined;
46734671
options.tracks[i] = track;
46744672
}
@@ -4942,7 +4940,7 @@ class Player extends Component {
49424940
this.reset();
49434941

49444942
// Clone the media object so it cannot be mutated from outside.
4945-
this.cache_.media = mergeOptions(media);
4943+
this.cache_.media = merge(media);
49464944

49474945
const {artwork, poster, src, textTracks} = this.cache_.media;
49484946

@@ -5001,7 +4999,7 @@ class Player extends Component {
50014999
return media;
50025000
}
50035001

5004-
return mergeOptions(this.cache_.media);
5002+
return merge(this.cache_.media);
50055003
}
50065004

50075005
/**

src/js/resize-manager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import window from 'global/window';
55
import { debounce } from './utils/fn.js';
66
import * as Events from './utils/events.js';
7-
import mergeOptions from './utils/merge-options.js';
7+
import {merge} from './utils/obj.js';
88
import Component from './component.js';
99

1010
/**
@@ -47,7 +47,7 @@ class ResizeManager extends Component {
4747
}
4848

4949
// Only create an element when ResizeObserver isn't available
50-
const options_ = mergeOptions({
50+
const options_ = merge({
5151
createEl: !RESIZE_OBSERVER_AVAILABLE,
5252
reportTouchActivity: false
5353
}, options);

src/js/tech/html5.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import log from '../utils/log.js';
88
import * as browser from '../utils/browser.js';
99
import document from 'global/document';
1010
import window from 'global/window';
11-
import {assign} from '../utils/obj';
12-
import mergeOptions from '../utils/merge-options.js';
11+
import {assign, merge} from '../utils/obj';
1312
import {toTitleCase} from '../utils/str.js';
1413
import {NORMAL as TRACK_TYPES, REMOTE} from '../tracks/track-types';
1514
import setupSourceset from './setup-sourceset';
@@ -385,7 +384,7 @@ class Html5 extends Tech {
385384

386385
// determine if native controls should be used
387386
const tagAttributes = this.options_.tag && Dom.getAttributes(this.options_.tag);
388-
const attributes = mergeOptions({}, tagAttributes);
387+
const attributes = merge({}, tagAttributes);
389388

390389
if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
391390
delete attributes.controls;

src/js/tech/loader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import Component from '../component.js';
55
import Tech from './tech.js';
66
import {toTitleCase} from '../utils/str.js';
7-
import mergeOptions from '../utils/merge-options.js';
7+
import {merge} from '../utils/obj.js';
88

99
/**
1010
* The `MediaLoader` is the `Component` that decides which playback technology to load
@@ -28,7 +28,7 @@ class MediaLoader extends Component {
2828
*/
2929
constructor(player, options, ready) {
3030
// MediaLoader has no element
31-
const options_ = mergeOptions({createEl: false}, options);
31+
const options_ = merge({createEl: false}, options);
3232

3333
super(player, options_, ready);
3434

src/js/tech/setup-sourceset.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import window from 'global/window';
22
import document from 'global/document';
3-
import mergeOptions from '../utils/merge-options';
3+
import {merge} from '../utils/obj';
44
import {getAbsoluteURL} from '../utils/url';
55

66
/**
@@ -183,7 +183,7 @@ const firstSourceWatch = function(tech) {
183183
el[k] = appendWrapper(old[k]);
184184
});
185185

186-
Object.defineProperty(el, 'innerHTML', mergeOptions(innerDescriptor, {
186+
Object.defineProperty(el, 'innerHTML', merge(innerDescriptor, {
187187
set: appendWrapper(innerDescriptor.set)
188188
}));
189189

@@ -252,7 +252,7 @@ const setupSourceset = function(tech) {
252252
const oldSetAttribute = el.setAttribute;
253253
const oldLoad = el.load;
254254

255-
Object.defineProperty(el, 'src', mergeOptions(srcDescriptor, {
255+
Object.defineProperty(el, 'src', merge(srcDescriptor, {
256256
set: (v) => {
257257
const retval = srcDescriptor.set.call(el, v);
258258

src/js/tech/tech.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
*/
44

55
import Component from '../component';
6-
import mergeOptions from '../utils/merge-options.js';
76
import * as Fn from '../utils/fn.js';
87
import log from '../utils/log.js';
98
import { createTimeRange } from '../utils/time-ranges.js';
109
import { bufferedPercent } from '../utils/buffer.js';
1110
import MediaError from '../media-error.js';
1211
import window from 'global/window';
1312
import document from 'global/document';
14-
import {isPlain} from '../utils/obj';
13+
import {isPlain, merge} from '../utils/obj';
1514
import * as TRACK_TYPES from '../tracks/track-types';
1615
import {toTitleCase, toLowerCase} from '../utils/str.js';
1716
import vtt from 'videojs-vtt.js';
@@ -743,7 +742,7 @@ class Tech extends Component {
743742
* The track element that gets created.
744743
*/
745744
createRemoteTextTrack(options) {
746-
const track = mergeOptions(options, {
745+
const track = merge(options, {
747746
tech: this
748747
});
749748

src/js/tracks/audio-track.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {AudioTrackKind} from './track-enums';
22
import Track from './track';
3-
import merge from '../utils/merge-options';
3+
import {merge} from '../utils/obj';
44

55
/**
66
* A representation of a single `AudioTrack`. If it is part of an {@link AudioTrackList}

src/js/tracks/text-track.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import window from 'global/window';
99
import Track from './track.js';
1010
import { isCrossOrigin } from '../utils/url.js';
1111
import XHR from '@videojs/xhr';
12-
import merge from '../utils/merge-options';
12+
import {merge} from '../utils/obj';
1313

1414
/**
1515
* Takes a webvtt file contents and parses it into cues

src/js/tracks/video-track.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {VideoTrackKind} from './track-enums';
22
import Track from './track';
3-
import merge from '../utils/merge-options';
3+
import {merge} from '../utils/obj';
44

55
/**
66
* A representation of a single `VideoTrack`.

src/js/utils/merge-options.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/js/video.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const normalizeId = (id) => id.indexOf('#') === 0 ? id.slice(1) : id;
109109
* @borrows module:format-time.formatTime as formatTime
110110
* @borrows module:format-time.resetFormatTime as resetFormatTime
111111
* @borrows module:format-time.setFormatTime as setFormatTime
112-
* @borrows module:merge-options.mergeOptions as mergeOptions
113112
* @borrows module:middleware.use as use
114113
* @borrows Player.players as players
115114
* @borrows Plugin.registerPlugin as registerPlugin

test/api/api.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ QUnit.test('should export useful components to the public', function(assert) {
208208
assert.ok(videojs.getComponent('ChaptersButton'), 'ChaptersButton should be public');
209209
assert.ok(videojs.getComponent('ChaptersTrackMenuItem'),
210210
'ChaptersTrackMenuItem should be public');
211-
212-
assert.ok(videojs.mergeOptions, 'mergeOptions should be public');
213211
});
214212

215213
QUnit.test('should be able to initialize player twice on the same tag using string reference', function(assert) {

test/unit/autoplay.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ QUnit.module('autoplay', {
6363
videoTag.setAttribute(a, attributes[a]);
6464
});
6565

66-
this.player = videojs(videoTag.id, videojs.mergeOptions({techOrder: ['techFaker']}, options));
66+
this.player = videojs(videoTag.id, videojs.obj.merge({techOrder: ['techFaker']}, options));
6767
const oldMuted = this.player.muted;
6868

6969
this.player.play = () => {

test/unit/play.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const mainModule = function(playReturnValue, middlewareTermination, subhooks) {
5151
};
5252

5353
this.checkState = (assertName, options = {}) => {
54-
const expectedState = videojs.mergeOptions({
54+
const expectedState = videojs.obj.merge({
5555
playCalls: 0,
5656
techLoaded: false,
5757
techReady: false,

test/unit/utils/merge-options.test.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)