From 7d9eb28b20aa353ee21ec2566666a1897f0b62a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Thu, 19 Nov 2020 14:45:23 -0300 Subject: [PATCH] refactor: prefer object deep merge with $.extend --- src/base/playback/playback.js | 2 +- src/base/ui_object/ui_object.js | 2 +- src/components/container/container.js | 4 ++-- src/components/core/core.js | 4 ++-- src/components/player/player.js | 2 +- src/playbacks/html5_video/html5_video.js | 2 +- src/utils/utils.js | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/base/playback/playback.js b/src/base/playback/playback.js index 1f102efef..596f69899 100644 --- a/src/base/playback/playback.js +++ b/src/base/playback/playback.js @@ -224,7 +224,7 @@ export default class Playback extends UIObject { * @param {Object} options all the options to change in form of a javascript object */ configure(options) { - this._options = $.extend(this._options, options) + this._options = $.extend(true, this._options, options) } /** diff --git a/src/base/ui_object/ui_object.js b/src/base/ui_object/ui_object.js index 461094861..56788eb57 100644 --- a/src/base/ui_object/ui_object.js +++ b/src/base/ui_object/ui_object.js @@ -190,7 +190,7 @@ export default class UIObject extends BaseObject { */ _ensureElement() { if (!this.el) { - const attrs = $.extend({}, this.attributes) + const attrs = $.extend(true, {}, this.attributes) if (this.id) attrs.id = this.id if (this.className) attrs['class'] = this.className const $el = $(DomRecycler.create(this.tagName)).attr(attrs) diff --git a/src/components/container/container.js b/src/components/container/container.js index 2a1b82413..8b3482698 100644 --- a/src/components/container/container.js +++ b/src/components/container/container.js @@ -122,7 +122,7 @@ export default class Container extends UIObject { this.volume = 100 this.playback = options.playback this.playerError = playerError - this.settings = $.extend({}, this.playback.settings) + this.settings = $.extend(true, {}, this.playback.settings) this.isReady = false this.mediaControlDisabled = false this.plugins = [this.playback] @@ -510,7 +510,7 @@ export default class Container extends UIObject { * @param {Object} options all the options to change in form of a javascript object */ configure(options) { - this._options = $.extend(this._options, options) + this._options = $.extend(true, this._options, options) this.updateStyle() this.playback.configure(this.options) this.trigger(Events.CONTAINER_OPTIONS_CHANGE) diff --git a/src/components/core/core.js b/src/components/core/core.js index 502dccd42..1b2faad61 100644 --- a/src/components/core/core.js +++ b/src/components/core/core.js @@ -220,7 +220,7 @@ export default class Core extends UIObject { sources = sources && sources.constructor === Array ? sources : [sources] this.options.sources = sources this.containers.forEach((container) => container.destroy()) - this.containerFactory.options = $.extend(this.options, { sources }) + this.containerFactory.options = $.extend(true, this.options, { sources }) this.prepareContainers() } @@ -349,7 +349,7 @@ export default class Core extends UIObject { * @param {Object} options all the options to change in form of a javascript object */ configure(options) { - this._options = $.extend(this._options, options) + this._options = $.extend(true, this._options, options) this.configureDomRecycler() const sources = options.source || options.sources diff --git a/src/components/player/player.js b/src/components/player/player.js index 2fece12c0..ded4fd9c7 100644 --- a/src/components/player/player.js +++ b/src/components/player/player.js @@ -239,7 +239,7 @@ export default class Player extends BaseObject { includeResetStyle: true, playback: playbackDefaultOptions } - this._options = $.extend(defaultOptions, options) + this._options = $.extend(true, defaultOptions, options) this.options.sources = this._normalizeSources(options) if (!this.options.chromeless) { // "allowUserInteraction" cannot be false if not in chromeless mode. diff --git a/src/playbacks/html5_video/html5_video.js b/src/playbacks/html5_video/html5_video.js index d12153760..7ead0216c 100644 --- a/src/playbacks/html5_video/html5_video.js +++ b/src/playbacks/html5_video/html5_video.js @@ -139,7 +139,7 @@ export default class HTML5Video extends Playback { } - $.extend(this.el, { + $.extend(true, this.el, { muted: this.options.mute, defaultMuted: this.options.mute, loop: this.options.loop, diff --git a/src/utils/utils.js b/src/utils/utils.js index 6298f0a1c..0ce03542f 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -289,7 +289,7 @@ export function canAutoPlayMedia(cb, options) { // Simple element factory with video recycle feature. export class DomRecycler { static configure(options) { - this.options = $.extend(this.options, options) + this.options = $.extend(true, this.options, options) } static create(name) {