Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use guid to ensure uniqueness of track setting options #8762

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/js/tracks/text-track-select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '../component';
import * as Dom from '../utils/dom';
import { newGUID } from '../utils/guid';

/** @import Player from './player' */
/** @import { ContentDescriptor } from '../utils/dom' */
Expand Down Expand Up @@ -29,11 +30,10 @@ class TextTrackSelect extends Component {
* @param {string} [options.id]
* A text with part of an string to create atribute of aria-labelledby.
*
* @param {array} [options.SelectOptions]
* @param {Array} [options.SelectOptions]
* Array that contains the value & textContent of for each of the
* options elements.
*/

Comment on lines -32 to -36
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to issue, resolving jsdoc warnings from lint.

constructor(player, options = {}) {
super(player, options);

Expand All @@ -57,7 +57,11 @@ class TextTrackSelect extends Component {
},
{},
this.options_.SelectOptions.map((optionText) => {
const optionId = this.options_.labelId + '-' + optionText[1].replace(/\W+/g, '');
// Constructs an id for the <option>.
// For the colour settings that have two <selects> with a <label> each, generates an id based off the label value
// For font size/family and edge style with one <select> and no <label>, generates an id with a guid
const optionId = (this.options_.labelId ? this.options_.labelId : `vjs-track-option-${newGUID()}`) +
'-' + optionText[1].replace(/\W+/g, '');

const option = Dom.createEl(
'option',
Expand Down