mirror of
https://github.com/videojs/video.js.git
synced 2025-01-17 10:46:00 +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:
parent
72fcb6c659
commit
430be94e7f
@ -37,7 +37,20 @@ class HtmlTrackElementList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTrackElement_(trackElement) {
|
addTrackElement_(trackElement) {
|
||||||
this.trackElements_.push(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) {
|
getTrackElementByTrack_(track) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user