mirror of
https://github.com/videojs/video.js.git
synced 2025-02-02 11:34:50 +02:00
fix(middleware): do a null check in mediator methods (#4913)
This commit is contained in:
parent
4404e071ba
commit
7670db63cd
@ -96,7 +96,9 @@ function executeRight(mws, method, value, terminated) {
|
||||
for (let i = mws.length - 1; i >= 0; i--) {
|
||||
const mw = mws[i];
|
||||
|
||||
mw[method](terminated, value);
|
||||
if (mw[method]) {
|
||||
mw[method](terminated, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,3 +394,18 @@ QUnit.test('setSource will select all middleware of a given type, until src chan
|
||||
middleware.getMiddleware('video/foo').pop();
|
||||
middleware.getMiddleware('video/foo').pop();
|
||||
});
|
||||
|
||||
QUnit.test('a middleware without a mediator method will not throw an error', function(assert) {
|
||||
let pauseCalled = 0;
|
||||
const myMw = {};
|
||||
const mwFactory = () => myMw;
|
||||
const mwFactory2 = () => ({
|
||||
pause() {
|
||||
pauseCalled++;
|
||||
}
|
||||
});
|
||||
|
||||
middleware.mediate([mwFactory(), mwFactory2()], {pause: () => {}}, 'pause');
|
||||
|
||||
assert.equal(pauseCalled, 1, 'pauseCalled was called once and no error was thrown');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user