1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-14 11:23:30 +02:00

fix(HtmlTrackElementList): allow to reference by index via bracket notation (#3776)

Previously, HtmlTrackElementList did not actually let you access HtmlTrackElements via bracket notation (`list[0]`) unlike TextTrackList. This adds that feature.
This commit is contained in:
ldayananda 2016-11-14 15:32:30 -05:00 committed by Gary Katsevman
parent 72fcb6c659
commit 430be94e7f

View File

@ -37,8 +37,21 @@ class HtmlTrackElementList {
}
addTrackElement_(trackElement) {
const index = this.trackElements_.length;
if (!('' + index in this)) {
Object.defineProperty(this, index, {
get() {
return this.trackElements_[index];
}
});
}
// Do not add duplicate elements
if (this.trackElements_.indexOf(trackElement) === -1) {
this.trackElements_.push(trackElement);
}
}
getTrackElementByTrack_(track) {
let trackElement_;