From 5688e400b11c4d49d49a659b582c2723c084dfa0 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 21 Feb 2018 17:10:53 -0500 Subject: [PATCH 1/3] commit breaking tests for a regression --- test/unit/video.test.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit/video.test.js b/test/unit/video.test.js index 56edcf9176..c8e2aad93f 100644 --- a/test/unit/video.test.js +++ b/test/unit/video.test.js @@ -373,6 +373,34 @@ QUnit.test('getPlayer', function(assert) { player.dispose(); }); +QUnit.test('videojs() works with the tech id', function(assert) { + const fixture = document.getElementById('qunit-fixture'); + + fixture.innerHTML += ''; + + const tag = document.querySelector('#player'); + const player = videojs('#player'); + + assert.strictEqual(videojs('player_html5_api'), player, 'the player was returned for the tech id'); + assert.strictEqual(videojs(tag), player, 'the player was returned when using the original tag/element'); + + player.dispose(); +}); + +QUnit.test('getPlayer works with the tech id', function(assert) { + const fixture = document.getElementById('qunit-fixture'); + + fixture.innerHTML += ''; + + const tag = document.querySelector('#player'); + const player = videojs('#player'); + + assert.strictEqual(videojs.getPlayer('player_html5_api'), player, 'the player was returned for the tech id'); + assert.strictEqual(videojs.getPlayer(tag), player, 'the player was returned when using the original tag/element'); + + player.dispose(); +}); + QUnit.test('getAllPlayers', function(assert) { const fixture = document.getElementById('qunit-fixture'); From bf1995f77a1f318b6945a228e2c79865e286ec1c Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 21 Feb 2018 18:19:41 -0500 Subject: [PATCH 2/3] check the Dom element associated with id in getPlayer --- src/js/video.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/js/video.js b/src/js/video.js index 3af49e28ca..9f8aabba3c 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -269,13 +269,23 @@ videojs.getPlayers = () => Player.players; */ videojs.getPlayer = (id) => { const players = Player.players; + let tag; if (typeof id === 'string') { - return players[normalizeId(id)]; + const nId = normalizeId(id); + const player = players[nId]; + + if (player) { + return player; + } + + tag = Dom.$('#' + nId); + } else { + tag = id; } - if (Dom.isEl(id)) { - const {player, playerId} = id; + if (Dom.isEl(tag)) { + const {player, playerId} = tag; // Element may have a `player` property referring to an already created // player instance. If so, return that. From a826db93f75f81f3dc6fc82db27a5140ac68ff10 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Thu, 22 Feb 2018 13:48:41 -0500 Subject: [PATCH 3/3] force html5 tech for test --- test/unit/video.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/video.test.js b/test/unit/video.test.js index c8e2aad93f..e5cca0a91f 100644 --- a/test/unit/video.test.js +++ b/test/unit/video.test.js @@ -379,7 +379,7 @@ QUnit.test('videojs() works with the tech id', function(assert) { fixture.innerHTML += ''; const tag = document.querySelector('#player'); - const player = videojs('#player'); + const player = videojs('#player', {techOrder: ['html5']}); assert.strictEqual(videojs('player_html5_api'), player, 'the player was returned for the tech id'); assert.strictEqual(videojs(tag), player, 'the player was returned when using the original tag/element'); @@ -393,7 +393,7 @@ QUnit.test('getPlayer works with the tech id', function(assert) { fixture.innerHTML += ''; const tag = document.querySelector('#player'); - const player = videojs('#player'); + const player = videojs('#player', {techOrder: ['html5']}); assert.strictEqual(videojs.getPlayer('player_html5_api'), player, 'the player was returned for the tech id'); assert.strictEqual(videojs.getPlayer(tag), player, 'the player was returned when using the original tag/element');