mirror of
https://github.com/videojs/video.js.git
synced 2024-12-25 02:42:10 +02:00
@llun fixed menus from throwing when focused when empty. closes #3218
This commit is contained in:
parent
6845cbedc3
commit
31b2f9d489
@ -2,7 +2,7 @@ CHANGELOG
|
||||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
* @llun fixed menus from throwing when focused when empty ([view](https://github.com/videojs/video.js/pull/3218))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -118,14 +118,13 @@ class Menu extends Component {
|
||||
*/
|
||||
focus (item = 0) {
|
||||
let children = this.children().slice();
|
||||
let haveTitle = children[0].className &&
|
||||
let haveTitle = children.length && children[0].className &&
|
||||
/vjs-menu-title/.test(children[0].className);
|
||||
|
||||
if (haveTitle) {
|
||||
children.shift();
|
||||
}
|
||||
|
||||
|
||||
if (children.length > 0) {
|
||||
if (item < 0) {
|
||||
item = 0;
|
||||
|
@ -1,11 +1,27 @@
|
||||
import MenuButton from '../../src/js/menu/menu-button.js';
|
||||
import TestHelpers from './test-helpers.js';
|
||||
import * as Events from '../../src/js/utils/events.js';
|
||||
|
||||
q.module('MenuButton');
|
||||
|
||||
test('should place title list item into ul', function() {
|
||||
var player, menuButton;
|
||||
q.test('should not throw an error when there is no children', function() {
|
||||
expect(0);
|
||||
let player = TestHelpers.makePlayer();
|
||||
|
||||
let menuButton = new MenuButton(player);
|
||||
let el = menuButton.el();
|
||||
|
||||
try {
|
||||
Events.trigger(el, 'click');
|
||||
} catch (error) {
|
||||
ok(!error, 'click should not throw anything');
|
||||
}
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
q.test('should place title list item into ul', function() {
|
||||
var player, menuButton;
|
||||
player = TestHelpers.makePlayer();
|
||||
|
||||
menuButton = new MenuButton(player, {
|
||||
@ -18,4 +34,4 @@ test('should place title list item into ul', function() {
|
||||
ok(titleElement.innerHTML === 'TestTitle', 'title element placed in ul');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user