From 9504a93643fd0587f990ce22ecd4eebf38cb985f Mon Sep 17 00:00:00 2001 From: Chuck Wilson Date: Mon, 11 Jun 2018 13:47:36 -0400 Subject: [PATCH] fix: make sure source options are passed through (#5241) The changes to source caching in #5156 introduced a regression where the source options were no longer available to plugins. This PR makes sure the cached source object retains any source options passed along. --- src/js/player.js | 2 +- test/unit/player.test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/js/player.js b/src/js/player.js index 9e13f4739..391fc042b 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -1241,7 +1241,7 @@ class Player extends Component { } // update `currentSource` cache always - this.cache_.source = {src, type}; + this.cache_.source = mergeOptions({}, srcObj, {src, type}); const matchingSources = this.cache_.sources.filter((s) => s.src && s.src === src); const sourceElSources = []; diff --git a/test/unit/player.test.js b/test/unit/player.test.js index f2cac3a75..613ccf332 100644 --- a/test/unit/player.test.js +++ b/test/unit/player.test.js @@ -1904,3 +1904,17 @@ QUnit.test('disposing a tech that dit NOT set a poster, should keep the poster', player.dispose(); }); + +QUnit.test('source options are retained', function(assert) { + const player = TestHelpers.makePlayer(); + + const source = { + src: 'https://some.url', + type: 'someType', + sourceOption: 'someOption' + }; + + player.src(source); + + assert.equal(player.currentSource().sourceOption, 'someOption', 'source option retained'); +});