Skip to content

Commit

Permalink
do less work
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jul 27, 2021
1 parent dac0cdd commit e85c076
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
14 changes: 1 addition & 13 deletions src/js/control-bar/audio-track-controls/audio-track-menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import MenuItem from '../../menu/menu-item.js';
import Component from '../../component.js';
import document from 'global/document';

/**
* An {@link AudioTrack} {@link MenuItem}
Expand Down Expand Up @@ -47,16 +46,7 @@ class AudioTrackMenuItem extends MenuItem {

createEl(type, props, attrs) {
const el = super.createEl(type, props, attrs);

while (el.firstChild) {
el.removeChild(el.firstChild);
}

const parentSpan = super.createEl('span', {
className: 'vjs-menu-item-text'
});

parentSpan.appendChild(document.createTextNode(this.localize(this.options_.label)));
const parentSpan = el.querySelector('.vjs-menu-item-text');

if (this.options_.track.kind === 'main-desc') {
parentSpan.appendChild(super.createEl('span', {
Expand All @@ -70,8 +60,6 @@ class AudioTrackMenuItem extends MenuItem {
}));
}

el.appendChild(parentSpan);

return el;
}

Expand Down
14 changes: 1 addition & 13 deletions src/js/control-bar/text-track-controls/subs-caps-menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import TextTrackMenuItem from './text-track-menu-item.js';
import Component from '../../component.js';
import document from 'global/document';
import {createEl} from '../../utils/dom.js';

/**
Expand All @@ -16,16 +15,7 @@ class SubsCapsMenuItem extends TextTrackMenuItem {

createEl(type, props, attrs) {
const el = super.createEl(type, props, attrs);

while (el.firstChild) {
el.removeChild(el.firstChild);
}

const parentSpan = createEl('span', {
className: 'vjs-menu-item-text'
});

parentSpan.appendChild(document.createTextNode(this.localize(this.options_.label)));
const parentSpan = el.querySelector('.vjs-menu-item-text');

if (this.options_.track.kind === 'captions') {
parentSpan.appendChild(createEl('span', {
Expand All @@ -41,8 +31,6 @@ class SubsCapsMenuItem extends TextTrackMenuItem {
}));
}

el.appendChild(parentSpan);

return el;
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/js/menu/menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ class MenuItem extends ClickableComponent {
tabIndex: -1
}, props), attrs);

while (el.firstChild) {
el.removeChild(el.firstChild);
}

el.appendChild(createEl('span', {
// swap icon with menu item text.
el.replaceChild(createEl('span', {
className: 'vjs-menu-item-text',
textContent: this.localize(this.options_.label)
}));
}), el.querySelector('.vjs-icon-placeholder'));

return el;
}
Expand Down

0 comments on commit e85c076

Please sign in to comment.