Skip to content

Commit

Permalink
fix: reset() should null check the controlBar (#7692)
Browse files Browse the repository at this point in the history
Fixes #7689

Co-authored-by: alex <try2betheb3st@gmail.com>
Co-authored-by: Pat O'Neill <pgoneill@gmail.com>
  • Loading branch information
3 people authored May 4, 2022
1 parent 0543298 commit 7e2b9ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3605,7 +3605,7 @@ class Player extends Component {
resetProgressBar_() {
this.currentTime(0);

const { durationDisplay, remainingTimeDisplay } = this.controlBar;
const { durationDisplay, remainingTimeDisplay } = this.controlBar || {};

if (durationDisplay) {
durationDisplay.updateContent();
Expand Down
18 changes: 18 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,24 @@ QUnit.test('player#reset removes remote text tracks', function(assert) {
log.warn.restore();
});

QUnit.test('player#reset progress bar', function(assert) {

let error;

const player = TestHelpers.makePlayer();

player.removeChild('controlBar');
player.controlBar = null;

try {
player.resetProgressBar_();
} catch (e) {
error = e;
}

assert.notOk(error, 'Function did not throw an error on resetProgressBar');
});

QUnit.test('Remove waiting class after tech waiting when timeupdate shows a time change', function(assert) {
const player = TestHelpers.makePlayer();

Expand Down

0 comments on commit 7e2b9ec

Please sign in to comment.