1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-09 01:15:31 +02:00

@misteroneill updated source code for linter v5

This commit is contained in:
Pat O'Neill
2016-08-03 15:29:12 -04:00
committed by Gary Katsevman
parent 86068a5b45
commit 272d5eed83
39 changed files with 297 additions and 309 deletions

View File

@ -58,7 +58,7 @@ class Button extends ClickableComponent {
'aria-live': 'polite' 'aria-live': 'polite'
}, attributes); }, attributes);
let el = Component.prototype.createEl.call(this, tag, props, attributes); const el = Component.prototype.createEl.call(this, tag, props, attributes);
this.createControlTextEl(el); this.createControlTextEl(el);
@ -75,7 +75,7 @@ class Button extends ClickableComponent {
* @method addChild * @method addChild
*/ */
addChild(child, options = {}) { addChild(child, options = {}) {
let className = this.constructor.name; const className = this.constructor.name;
log.warn(`Adding an actionable (user controllable) child to a Button (${className}) is not supported; use a ClickableComponent instead.`); log.warn(`Adding an actionable (user controllable) child to a Button (${className}) is not supported; use a ClickableComponent instead.`);

View File

@ -57,7 +57,7 @@ class ClickableComponent extends Component {
'aria-live': 'polite' 'aria-live': 'polite'
}, attributes); }, attributes);
let el = super.createEl(tag, props, attributes); const el = super.createEl(tag, props, attributes);
this.createControlTextEl(el); this.createControlTextEl(el);

View File

@ -64,7 +64,7 @@ class Component {
// If there was no ID from the options, generate one // If there was no ID from the options, generate one
if (!this.id_) { if (!this.id_) {
// Don't require the player ID function in the case of mock players // Don't require the player ID function in the case of mock players
let id = player && player.id && player.id() || 'no_player'; const id = player && player.id && player.id() || 'no_player';
this.id_ = `${id}_component_${Guid.newGUID()}`; this.id_ = `${id}_component_${Guid.newGUID()}`;
} }
@ -217,21 +217,21 @@ class Component {
} }
localize(string) { localize(string) {
let code = this.player_.language && this.player_.language(); const code = this.player_.language && this.player_.language();
let languages = this.player_.languages && this.player_.languages(); const languages = this.player_.languages && this.player_.languages();
if (!code || !languages) { if (!code || !languages) {
return string; return string;
} }
let language = languages[code]; const language = languages[code];
if (language && language[string]) { if (language && language[string]) {
return language[string]; return language[string];
} }
let primaryCode = code.split('-')[0]; const primaryCode = code.split('-')[0];
let primaryLang = languages[primaryCode]; const primaryLang = languages[primaryCode];
if (primaryLang && primaryLang[string]) { if (primaryLang && primaryLang[string]) {
return primaryLang[string]; return primaryLang[string];
@ -359,14 +359,14 @@ class Component {
// If no componentClass in options, assume componentClass is the name lowercased // If no componentClass in options, assume componentClass is the name lowercased
// (e.g. playButton) // (e.g. playButton)
let componentClassName = options.componentClass || toTitleCase(componentName); const componentClassName = options.componentClass || toTitleCase(componentName);
// Set name through options // Set name through options
options.name = componentName; options.name = componentName;
// Create a new object & element for this controls set // Create a new object & element for this controls set
// If there's no .player_, this is a player // If there's no .player_, this is a player
let ComponentClass = Component.getComponent(componentClassName); const ComponentClass = Component.getComponent(componentClassName);
if (!ComponentClass) { if (!ComponentClass) {
throw new Error(`Component ${componentClassName} does not exist`); throw new Error(`Component ${componentClassName} does not exist`);
@ -404,8 +404,8 @@ class Component {
// Add the UI object's element to the container div (box) // Add the UI object's element to the container div (box)
// Having an element is not required // Having an element is not required
if (typeof component.el === 'function' && component.el()) { if (typeof component.el === 'function' && component.el()) {
let childNodes = this.contentEl().children; const childNodes = this.contentEl().children;
let refNode = childNodes[index] || null; const refNode = childNodes[index] || null;
this.contentEl().insertBefore(component.el(), refNode); this.contentEl().insertBefore(component.el(), refNode);
} }
@ -447,7 +447,7 @@ class Component {
this.childIndex_[component.id()] = null; this.childIndex_[component.id()] = null;
this.childNameIndex_[component.name()] = null; this.childNameIndex_[component.name()] = null;
let compEl = component.el(); const compEl = component.el();
if (compEl && compEl.parentNode === this.contentEl()) { if (compEl && compEl.parentNode === this.contentEl()) {
this.contentEl().removeChild(component.el()); this.contentEl().removeChild(component.el());
@ -501,14 +501,14 @@ class Component {
* @method initChildren * @method initChildren
*/ */
initChildren() { initChildren() {
let children = this.options_.children; const children = this.options_.children;
if (children) { if (children) {
// `this` is `parent` // `this` is `parent`
let parentOptions = this.options_; const parentOptions = this.options_;
let handleAdd = (child) => { const handleAdd = (child) => {
let name = child.name; const name = child.name;
let opts = child.opts; let opts = child.opts;
// Allow options for children to be set at the parent options // Allow options for children to be set at the parent options
@ -538,7 +538,7 @@ class Component {
// Add a direct reference to the child by name on the parent instance. // Add a direct reference to the child by name on the parent instance.
// If two of the same component are used, different names should be supplied // If two of the same component are used, different names should be supplied
// for each // for each
let newChild = this.addChild(name, opts); const newChild = this.addChild(name, opts);
if (newChild) { if (newChild) {
this[name] = newChild; this[name] = newChild;
@ -547,7 +547,7 @@ class Component {
// Allow for an array of children details to passed in the options // Allow for an array of children details to passed in the options
let workingChildren; let workingChildren;
let Tech = Component.getComponent('Tech'); const Tech = Component.getComponent('Tech');
if (Array.isArray(children)) { if (Array.isArray(children)) {
workingChildren = children; workingChildren = children;
@ -585,7 +585,7 @@ class Component {
// we have to make sure that child.name isn't in the techOrder since // we have to make sure that child.name isn't in the techOrder since
// techs are registerd as Components but can't aren't compatible // techs are registerd as Components but can't aren't compatible
// See https://github.com/videojs/video.js/issues/2772 // See https://github.com/videojs/video.js/issues/2772
let c = Component.getComponent(child.opts.componentClass || const c = Component.getComponent(child.opts.componentClass ||
toTitleCase(child.name)); toTitleCase(child.name));
return c && !Tech.isTech(c); return c && !Tech.isTech(c);
@ -826,7 +826,7 @@ class Component {
// Ensure ready is triggerd asynchronously // Ensure ready is triggerd asynchronously
this.setTimeout(function() { this.setTimeout(function() {
let readyQueue = this.readyQueue_; const readyQueue = this.readyQueue_;
// Reset Ready Queue // Reset Ready Queue
this.readyQueue_ = []; this.readyQueue_ = [];
@ -1078,8 +1078,8 @@ class Component {
} }
// Get dimension value from style // Get dimension value from style
let val = this.el_.style[widthOrHeight]; const val = this.el_.style[widthOrHeight];
let pxIndex = val.indexOf('px'); const pxIndex = val.indexOf('px');
if (pxIndex !== -1) { if (pxIndex !== -1) {
// Return the pixel value with no 'px' // Return the pixel value with no 'px'
@ -1300,7 +1300,7 @@ class Component {
fn = Fn.bind(this, fn); fn = Fn.bind(this, fn);
// window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't. // window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't.
let timeoutId = window.setTimeout(fn, timeout); const timeoutId = window.setTimeout(fn, timeout);
const disposeFn = function() { const disposeFn = function() {
this.clearTimeout(timeoutId); this.clearTimeout(timeoutId);
@ -1343,7 +1343,7 @@ class Component {
setInterval(fn, interval) { setInterval(fn, interval) {
fn = Fn.bind(this, fn); fn = Fn.bind(this, fn);
let intervalId = window.setInterval(fn, interval); const intervalId = window.setInterval(fn, interval);
const disposeFn = function() { const disposeFn = function() {
this.clearInterval(intervalId); this.clearInterval(intervalId);
@ -1428,7 +1428,7 @@ class Component {
// Set up the constructor using the supplied init method // Set up the constructor using the supplied init method
// or using the init of the parent object // or using the init of the parent object
// Make sure to check the unobfuscated version for external libs // Make sure to check the unobfuscated version for external libs
let init = props.init || props.init || this.prototype.init || this.prototype.init || function() {}; const init = props.init || props.init || this.prototype.init || this.prototype.init || function() {};
// In Resig's simple class inheritance (previously used) the constructor // In Resig's simple class inheritance (previously used) the constructor
// is a function that calls `this.init.apply(arguments)` // is a function that calls `this.init.apply(arguments)`
// However that would prevent us from using `ParentObject.call(this);` // However that would prevent us from using `ParentObject.call(this);`
@ -1438,7 +1438,7 @@ class Component {
// `ParentObject.prototype.init.apply(this, arguments);` // `ParentObject.prototype.init.apply(this, arguments);`
// Bleh. We're not creating a _super() function, so it's good to keep // Bleh. We're not creating a _super() function, so it's good to keep
// the parent constructor reference simple. // the parent constructor reference simple.
let subObj = function() { const subObj = function() {
init.apply(this, arguments); init.apply(this, arguments);
}; };
@ -1452,7 +1452,7 @@ class Component {
subObj.extend = Component.extend; subObj.extend = Component.extend;
// Extend subObj's prototype with functions and other properties from props // Extend subObj's prototype with functions and other properties from props
for (let name in props) { for (const name in props) {
if (props.hasOwnProperty(name)) { if (props.hasOwnProperty(name)) {
subObj.prototype[name] = props[name]; subObj.prototype[name] = props[name];
} }

View File

@ -43,7 +43,7 @@ class ErrorDisplay extends ModalDialog {
* @return {String|Null} * @return {String|Null}
*/ */
content() { content() {
let error = this.player().error(); const error = this.player().error();
return error ? this.localize(error.message) : ''; return error ? this.localize(error.message) : '';
} }

View File

@ -10,7 +10,7 @@ EventTarget.prototype.allowedEvents_ = {};
EventTarget.prototype.on = function(type, fn) { EventTarget.prototype.on = function(type, fn) {
// Remove the addEventListener alias before calling Events.on // Remove the addEventListener alias before calling Events.on
// so we don't get into an infinite type loop // so we don't get into an infinite type loop
let ael = this.addEventListener; const ael = this.addEventListener;
this.addEventListener = () => {}; this.addEventListener = () => {};
Events.on(this, type, fn); Events.on(this, type, fn);
@ -28,7 +28,7 @@ EventTarget.prototype.removeEventListener = EventTarget.prototype.off;
EventTarget.prototype.one = function(type, fn) { EventTarget.prototype.one = function(type, fn) {
// Remove the addEventListener alias before calling Events.on // Remove the addEventListener alias before calling Events.on
// so we don't get into an infinite type loop // so we don't get into an infinite type loop
let ael = this.addEventListener; const ael = this.addEventListener;
this.addEventListener = () => {}; this.addEventListener = () => {};
Events.one(this, type, fn); Events.one(this, type, fn);
@ -36,7 +36,7 @@ EventTarget.prototype.one = function(type, fn) {
}; };
EventTarget.prototype.trigger = function(event) { EventTarget.prototype.trigger = function(event) {
let type = event.type || event; const type = event.type || event;
if (typeof event === 'string') { if (typeof event === 'string') {
event = {type}; event = {type};

View File

@ -67,7 +67,7 @@ const extendFn = function(superClass, subClassMethods = {}) {
_inherits(subClass, superClass); _inherits(subClass, superClass);
// Extend subObj's prototype with functions and other properties from props // Extend subObj's prototype with functions and other properties from props
for (let name in methods) { for (const name in methods) {
if (methods.hasOwnProperty(name)) { if (methods.hasOwnProperty(name)) {
subClass.prototype[name] = methods[name]; subClass.prototype[name] = methods[name];
} }

View File

@ -8,7 +8,7 @@ import document from 'global/document';
* @type {Object|undefined} * @type {Object|undefined}
* @private * @private
*/ */
let FullscreenApi = {}; const FullscreenApi = {};
// browser API methods // browser API methods
// map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js // map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
@ -60,7 +60,7 @@ const apiMap = [
] ]
]; ];
let specApi = apiMap[0]; const specApi = apiMap[0];
let browserApi; let browserApi;
// determine the supported set of functions // determine the supported set of functions

View File

@ -8,7 +8,7 @@ import assign from 'object.assign';
* *
* @param {Number} code The media error code * @param {Number} code The media error code
*/ */
let MediaError = function(code) { const MediaError = function(code) {
if (typeof code === 'number') { if (typeof code === 'number') {
this.code = code; this.code = code;
} else if (typeof code === 'string') { } else if (typeof code === 'string') {

View File

@ -150,7 +150,7 @@ class ModalDialog extends Component {
*/ */
open() { open() {
if (!this.opened_) { if (!this.opened_) {
let player = this.player(); const player = this.player();
this.trigger('beforemodalopen'); this.trigger('beforemodalopen');
this.opened_ = true; this.opened_ = true;
@ -206,7 +206,7 @@ class ModalDialog extends Component {
*/ */
close() { close() {
if (this.opened_) { if (this.opened_) {
let player = this.player(); const player = this.player();
this.trigger('beforemodalclose'); this.trigger('beforemodalclose');
this.opened_ = false; this.opened_ = false;
@ -242,7 +242,7 @@ class ModalDialog extends Component {
*/ */
closeable(value) { closeable(value) {
if (typeof value === 'boolean') { if (typeof value === 'boolean') {
let closeable = this.closeable_ = !!value; const closeable = this.closeable_ = !!value;
let close = this.getChild('closeButton'); let close = this.getChild('closeButton');
// If this is being made closeable and has no close button, add one. // If this is being made closeable and has no close button, add one.
@ -250,7 +250,7 @@ class ModalDialog extends Component {
// The close button should be a child of the modal - not its // The close button should be a child of the modal - not its
// content element, so temporarily change the content element. // content element, so temporarily change the content element.
let temp = this.contentEl_; const temp = this.contentEl_;
this.contentEl_ = this.el_; this.contentEl_ = this.el_;
close = this.addChild('closeButton', {controlText: 'Close Modal Dialog'}); close = this.addChild('closeButton', {controlText: 'Close Modal Dialog'});
@ -292,9 +292,9 @@ class ModalDialog extends Component {
* @return {ModalDialog} * @return {ModalDialog}
*/ */
fillWith(content) { fillWith(content) {
let contentEl = this.contentEl(); const contentEl = this.contentEl();
let parentEl = contentEl.parentNode; const parentEl = contentEl.parentNode;
let nextSiblingEl = contentEl.nextSibling; const nextSiblingEl = contentEl.nextSibling;
this.trigger('beforemodalfill'); this.trigger('beforemodalfill');
this.hasBeenFilled_ = true; this.hasBeenFilled_ = true;

View File

@ -97,7 +97,7 @@ class Player extends Component {
// If language is not set, get the closest lang attribute // If language is not set, get the closest lang attribute
if (!options.language) { if (!options.language) {
if (typeof tag.closest === 'function') { if (typeof tag.closest === 'function') {
let closest = tag.closest('[lang]'); const closest = tag.closest('[lang]');
if (closest) { if (closest) {
options.language = closest.getAttribute('lang'); options.language = closest.getAttribute('lang');
@ -140,7 +140,7 @@ class Player extends Component {
// Update Supported Languages // Update Supported Languages
if (options.languages) { if (options.languages) {
// Normalise player option languages to lowercase // Normalise player option languages to lowercase
let languagesToLower = {}; const languagesToLower = {};
Object.getOwnPropertyNames(options.languages).forEach(function(name) { Object.getOwnPropertyNames(options.languages).forEach(function(name) {
languagesToLower[name.toLowerCase()] = options.languages[name]; languagesToLower[name.toLowerCase()] = options.languages[name];
@ -178,11 +178,11 @@ class Player extends Component {
// as well so they don't need to reach back into the player for options later. // as well so they don't need to reach back into the player for options later.
// We also need to do another copy of this.options_ so we don't end up with // We also need to do another copy of this.options_ so we don't end up with
// an infinite loop. // an infinite loop.
let playerOptionsCopy = mergeOptions(this.options_); const playerOptionsCopy = mergeOptions(this.options_);
// Load plugins // Load plugins
if (options.plugins) { if (options.plugins) {
let plugins = options.plugins; const plugins = options.plugins;
Object.getOwnPropertyNames(plugins).forEach(function(name) { Object.getOwnPropertyNames(plugins).forEach(function(name) {
if (typeof this[name] === 'function') { if (typeof this[name] === 'function') {
@ -292,8 +292,8 @@ class Player extends Component {
* @method createEl * @method createEl
*/ */
createEl() { createEl() {
let el = this.el_ = super.createEl('div'); const el = this.el_ = super.createEl('div');
let tag = this.tag; const tag = this.tag;
// Remove width/height attrs from tag so CSS can make it 100% width/height // Remove width/height attrs from tag so CSS can make it 100% width/height
tag.removeAttribute('width'); tag.removeAttribute('width');
@ -330,8 +330,8 @@ class Player extends Component {
// video element // video element
if (window.VIDEOJS_NO_DYNAMIC_STYLE !== true) { if (window.VIDEOJS_NO_DYNAMIC_STYLE !== true) {
this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions'); this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions');
let defaultsStyleEl = Dom.$('.vjs-styles-defaults'); const defaultsStyleEl = Dom.$('.vjs-styles-defaults');
let head = Dom.$('head'); const head = Dom.$('head');
head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild); head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild);
} }
@ -343,10 +343,10 @@ class Player extends Component {
this.aspectRatio(this.options_.aspectRatio); this.aspectRatio(this.options_.aspectRatio);
// Hide any links within the video/audio tag, because IE doesn't hide them completely. // Hide any links within the video/audio tag, because IE doesn't hide them completely.
let links = tag.getElementsByTagName('a'); const links = tag.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) { for (let i = 0; i < links.length; i++) {
let linkEl = links.item(i); const linkEl = links.item(i);
Dom.addElClass(linkEl, 'vjs-hidden'); Dom.addElClass(linkEl, 'vjs-hidden');
linkEl.setAttribute('hidden', 'hidden'); linkEl.setAttribute('hidden', 'hidden');
@ -405,7 +405,7 @@ class Player extends Component {
* @method dimension * @method dimension
*/ */
dimension(dimension, value) { dimension(dimension, value) {
let privDimension = dimension + '_'; const privDimension = dimension + '_';
if (value === undefined) { if (value === undefined) {
return this[privDimension] || 0; return this[privDimension] || 0;
@ -415,7 +415,7 @@ class Player extends Component {
// If an empty string is given, reset the dimension to be automatic // If an empty string is given, reset the dimension to be automatic
this[privDimension] = undefined; this[privDimension] = undefined;
} else { } else {
let parsedVal = parseFloat(value); const parsedVal = parseFloat(value);
if (isNaN(parsedVal)) { if (isNaN(parsedVal)) {
log.error(`Improper value "${value}" supplied for for ${dimension}`); log.error(`Improper value "${value}" supplied for for ${dimension}`);
@ -483,7 +483,7 @@ class Player extends Component {
if (window.VIDEOJS_NO_DYNAMIC_STYLE === true) { if (window.VIDEOJS_NO_DYNAMIC_STYLE === true) {
const width = typeof this.width_ === 'number' ? this.width_ : this.options_.width; const width = typeof this.width_ === 'number' ? this.width_ : this.options_.width;
const height = typeof this.height_ === 'number' ? this.height_ : this.options_.height; const height = typeof this.height_ === 'number' ? this.height_ : this.options_.height;
let techEl = this.tech_ && this.tech_.el(); const techEl = this.tech_ && this.tech_.el();
if (techEl) { if (techEl) {
if (width >= 0) { if (width >= 0) {
@ -515,8 +515,8 @@ class Player extends Component {
} }
// Get the ratio as a decimal we can use to calculate dimensions // Get the ratio as a decimal we can use to calculate dimensions
let ratioParts = aspectRatio.split(':'); const ratioParts = aspectRatio.split(':');
let ratioMultiplier = ratioParts[1] / ratioParts[0]; const ratioMultiplier = ratioParts[1] / ratioParts[0];
if (this.width_ !== undefined) { if (this.width_ !== undefined) {
// Use any width that's been specifically set // Use any width that's been specifically set
@ -589,7 +589,7 @@ class Player extends Component {
this.isReady_ = false; this.isReady_ = false;
// Grab tech-specific options from player options and add source and parent element to use. // Grab tech-specific options from player options and add source and parent element to use.
let techOptions = assign({ const techOptions = assign({
source, source,
'nativeControlsForTouch': this.options_.nativeControlsForTouch, 'nativeControlsForTouch': this.options_.nativeControlsForTouch,
'playerId': this.id(), 'playerId': this.id(),
@ -717,7 +717,7 @@ class Player extends Component {
if (safety && safety.IWillNotUseThisInPlugins) { if (safety && safety.IWillNotUseThisInPlugins) {
return this.tech_; return this.tech_;
} }
let errorText = ` const errorText = `
Please make sure that you are not using this inside of a plugin. Please make sure that you are not using this inside of a plugin.
To disable this alert and error, please pass in an object with To disable this alert and error, please pass in an object with
\`IWillNotUseThisInPlugins\` to the \`tech\` method. See \`IWillNotUseThisInPlugins\` to the \`tech\` method. See
@ -1148,7 +1148,7 @@ class Player extends Component {
* @method handleTechError_ * @method handleTechError_
*/ */
handleTechError_() { handleTechError_() {
let error = this.tech_.error(); const error = this.tech_.error();
this.error(error); this.error(error);
} }
@ -1553,8 +1553,8 @@ class Player extends Component {
* @method bufferedEnd * @method bufferedEnd
*/ */
bufferedEnd() { bufferedEnd() {
let buffered = this.buffered(); const buffered = this.buffered();
let duration = this.duration(); const duration = this.duration();
let end = buffered.end(buffered.length - 1); let end = buffered.end(buffered.length - 1);
if (end > duration) { if (end > duration) {
@ -1671,7 +1671,7 @@ class Player extends Component {
* @method requestFullscreen * @method requestFullscreen
*/ */
requestFullscreen() { requestFullscreen() {
let fsApi = FullscreenApi; const fsApi = FullscreenApi;
this.isFullscreen(true); this.isFullscreen(true);
@ -1721,7 +1721,7 @@ class Player extends Component {
* @method exitFullscreen * @method exitFullscreen
*/ */
exitFullscreen() { exitFullscreen() {
let fsApi = FullscreenApi; const fsApi = FullscreenApi;
this.isFullscreen(false); this.isFullscreen(false);
@ -1809,7 +1809,7 @@ class Player extends Component {
// Loop through each playback technology in the options order // Loop through each playback technology in the options order
for (let i = 0, j = this.options_.techOrder; i < j.length; i++) { for (let i = 0, j = this.options_.techOrder; i < j.length; i++) {
let techName = toTitleCase(j[i]); const techName = toTitleCase(j[i]);
let tech = Tech.getTech(techName); let tech = Tech.getTech(techName);
// Support old behavior of techs being registered as components. // Support old behavior of techs being registered as components.
@ -1849,7 +1849,7 @@ class Player extends Component {
selectSource(sources) { selectSource(sources) {
// Get only the techs specified in `techOrder` that exist and are supported by the // Get only the techs specified in `techOrder` that exist and are supported by the
// current platform // current platform
let techs = const techs =
this.options_.techOrder this.options_.techOrder
.map(toTitleCase) .map(toTitleCase)
.map((techName) => { .map((techName) => {
@ -1872,7 +1872,7 @@ class Player extends Component {
// Iterate over each `innerArray` element once per `outerArray` element and execute // Iterate over each `innerArray` element once per `outerArray` element and execute
// `tester` with both. If `tester` returns a non-falsy value, exit early and return // `tester` with both. If `tester` returns a non-falsy value, exit early and return
// that value. // that value.
let findFirstPassingTechSourcePair = function(outerArray, innerArray, tester) { const findFirstPassingTechSourcePair = function(outerArray, innerArray, tester) {
let found; let found;
outerArray.some((outerChoice) => { outerArray.some((outerChoice) => {
@ -1889,8 +1889,8 @@ class Player extends Component {
}; };
let foundSourceAndTech; let foundSourceAndTech;
let flip = (fn) => (a, b) => fn(b, a); const flip = (fn) => (a, b) => fn(b, a);
let finder = ([techName, tech], source) => { const finder = ([techName, tech], source) => {
if (tech.canPlaySource(source, this.options_[techName.toLowerCase()])) { if (tech.canPlaySource(source, this.options_[techName.toLowerCase()])) {
return {source, tech: techName}; return {source, tech: techName};
} }
@ -2012,7 +2012,7 @@ class Player extends Component {
* @method sourceList_ * @method sourceList_
*/ */
sourceList_(sources) { sourceList_(sources) {
let sourceTech = this.selectSource(sources); const sourceTech = this.selectSource(sources);
if (sourceTech) { if (sourceTech) {
if (sourceTech.tech === this.techName_) { if (sourceTech.tech === this.techName_) {
@ -2426,9 +2426,9 @@ class Player extends Component {
let mouseInProgress; let mouseInProgress;
let lastMoveX; let lastMoveX;
let lastMoveY; let lastMoveY;
let handleActivity = Fn.bind(this, this.reportUserActivity); const handleActivity = Fn.bind(this, this.reportUserActivity);
let handleMouseMove = function(e) { const handleMouseMove = function(e) {
// #1068 - Prevent mousemove spamming // #1068 - Prevent mousemove spamming
// Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970 // Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) { if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
@ -2438,7 +2438,7 @@ class Player extends Component {
} }
}; };
let handleMouseDown = function() { const handleMouseDown = function() {
handleActivity(); handleActivity();
// For as long as the they are touching the device or have their mouse down, // For as long as the they are touching the device or have their mouse down,
// we consider them active even if they're not moving their finger or mouse. // we consider them active even if they're not moving their finger or mouse.
@ -2450,7 +2450,7 @@ class Player extends Component {
mouseInProgress = this.setInterval(handleActivity, 250); mouseInProgress = this.setInterval(handleActivity, 250);
}; };
let handleMouseUp = function(event) { const handleMouseUp = function(event) {
handleActivity(); handleActivity();
// Stop the interval that maintains activity if the mouse/touch is down // Stop the interval that maintains activity if the mouse/touch is down
this.clearInterval(mouseInProgress); this.clearInterval(mouseInProgress);
@ -2485,7 +2485,7 @@ class Player extends Component {
// Clear any existing inactivity timeout to start the timer over // Clear any existing inactivity timeout to start the timer over
this.clearTimeout(inactivityTimeout); this.clearTimeout(inactivityTimeout);
let timeout = this.options_.inactivityTimeout; const timeout = this.options_.inactivityTimeout;
if (timeout > 0) { if (timeout > 0) {
// In <timeout> milliseconds, if no more activity has occurred the // In <timeout> milliseconds, if no more activity has occurred the
@ -2786,8 +2786,8 @@ class Player extends Component {
* @method toJSON * @method toJSON
*/ */
toJSON() { toJSON() {
let options = mergeOptions(this.options_); const options = mergeOptions(this.options_);
let tracks = options.tracks; const tracks = options.tracks;
options.tracks = []; options.tracks = [];
@ -2823,7 +2823,7 @@ class Player extends Component {
options = options || {}; options = options || {};
options.content = content || ''; options.content = content || '';
let modal = new ModalDialog(this, options); const modal = new ModalDialog(this, options);
this.addChild(modal); this.addChild(modal);
modal.on('dispose', () => { modal.on('dispose', () => {
@ -2842,7 +2842,7 @@ class Player extends Component {
* @method getTagSettings * @method getTagSettings
*/ */
static getTagSettings(tag) { static getTagSettings(tag) {
let baseOptions = { const baseOptions = {
sources: [], sources: [],
tracks: [] tracks: []
}; };
@ -2893,7 +2893,7 @@ class Player extends Component {
*/ */
Player.players = {}; Player.players = {};
let navigator = window.navigator; const navigator = window.navigator;
/* /*
* Player instance options, surfaced using options * Player instance options, surfaced using options
@ -3015,10 +3015,10 @@ Player.prototype.handleVolumeChange_; // eslint-disable-line
* *
* @event error * @event error
*/ */
Player.prototype.handleError_ = Player.prototype.handleError_; Player.prototype.handleError_; // eslint-disable-line
Player.prototype.flexNotSupported_ = function() { Player.prototype.flexNotSupported_ = function() {
let elem = document.createElement('i'); const elem = document.createElement('i');
// Note: We don't actually use flexBasis (or flexOrder), but it's one of the more // Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
// common flex features that we can rely on when checking for flex support. // common flex features that we can rely on when checking for flex support.

View File

@ -41,7 +41,7 @@ class PosterImage extends ClickableComponent {
* @method createEl * @method createEl
*/ */
createEl() { createEl() {
let el = Dom.createEl('div', { const el = Dom.createEl('div', {
className: 'vjs-poster', className: 'vjs-poster',
// Don't want poster to be tabbable. // Don't want poster to be tabbable.
@ -66,7 +66,7 @@ class PosterImage extends ClickableComponent {
* @method update * @method update
*/ */
update() { update() {
let url = this.player().poster(); const url = this.player().poster();
this.setSrc(url); this.setSrc(url);

View File

@ -10,7 +10,6 @@ import window from 'global/window';
let _windowLoaded = false; let _windowLoaded = false;
let videojs; let videojs;
let autoSetupTimeout;
// Automatically set up any tags that have a data-setup attribute // Automatically set up any tags that have a data-setup attribute
const autoSetup = function() { const autoSetup = function() {
@ -41,7 +40,7 @@ const autoSetup = function() {
if (mediaEls && mediaEls.length > 0) { if (mediaEls && mediaEls.length > 0) {
for (let i = 0, e = mediaEls.length; i < e; i++) { for (let i = 0, e = mediaEls.length; i < e; i++) {
let mediaEl = mediaEls[i]; const mediaEl = mediaEls[i];
// Check if element exists, has getAttribute func. // Check if element exists, has getAttribute func.
// IE seems to consider typeof el.getAttribute == 'object' instead of // IE seems to consider typeof el.getAttribute == 'object' instead of
@ -50,7 +49,7 @@ const autoSetup = function() {
// Make sure this player hasn't already been set up. // Make sure this player hasn't already been set up.
if (mediaEl.player === undefined) { if (mediaEl.player === undefined) {
let options = mediaEl.getAttribute('data-setup'); const options = mediaEl.getAttribute('data-setup');
// Check if data-setup attr exists. // Check if data-setup attr exists.
// We only auto-setup if they've added the data-setup attr. // We only auto-setup if they've added the data-setup attr.
@ -74,13 +73,13 @@ const autoSetup = function() {
}; };
// Pause to let the DOM keep processing // Pause to let the DOM keep processing
autoSetupTimeout = function(wait, vjs) { function autoSetupTimeout(wait, vjs) {
if (vjs) { if (vjs) {
videojs = vjs; videojs = vjs;
} }
setTimeout(autoSetup, wait); setTimeout(autoSetup, wait);
}; }
if (document.readyState === 'complete') { if (document.readyState === 'complete') {
_windowLoaded = true; _windowLoaded = true;

View File

@ -12,7 +12,7 @@ function FlashRtmpDecorator(Flash) {
}; };
Flash.streamToParts = function(src) { Flash.streamToParts = function(src) {
let parts = { const parts = {
connection: '', connection: '',
stream: '' stream: ''
}; };
@ -82,7 +82,7 @@ function FlashRtmpDecorator(Flash) {
* @return {String} 'probably', 'maybe', or '' (empty string) * @return {String} 'probably', 'maybe', or '' (empty string)
*/ */
Flash.rtmpSourceHandler.canHandleSource = function(source, options) { Flash.rtmpSourceHandler.canHandleSource = function(source, options) {
let can = Flash.rtmpSourceHandler.canPlayType(source.type); const can = Flash.rtmpSourceHandler.canPlayType(source.type);
if (can) { if (can) {
return can; return can;
@ -104,7 +104,7 @@ function FlashRtmpDecorator(Flash) {
* @param {Object} options The options to pass to the source * @param {Object} options The options to pass to the source
*/ */
Flash.rtmpSourceHandler.handleSource = function(source, tech, options) { Flash.rtmpSourceHandler.handleSource = function(source, tech, options) {
let srcParts = Flash.streamToParts(source.src); const srcParts = Flash.streamToParts(source.src);
tech.setRtmpConnection(srcParts.connection); tech.setRtmpConnection(srcParts.connection);
tech.setRtmpStream(srcParts.stream); tech.setRtmpStream(srcParts.stream);

View File

@ -14,7 +14,7 @@ import Component from '../component';
import window from 'global/window'; import window from 'global/window';
import assign from 'object.assign'; import assign from 'object.assign';
let navigator = window.navigator; const navigator = window.navigator;
/** /**
* Flash Media Controller - Wrapper for fallback SWF API * Flash Media Controller - Wrapper for fallback SWF API
@ -68,7 +68,7 @@ class Flash extends Tech {
* @method createEl * @method createEl
*/ */
createEl() { createEl() {
let options = this.options_; const options = this.options_;
// If video.js is hosted locally you should also set the location // If video.js is hosted locally you should also set the location
// for the hosted swf, which should be relative to the page (not video.js) // for the hosted swf, which should be relative to the page (not video.js)
@ -79,10 +79,10 @@ class Flash extends Tech {
} }
// Generate ID for swf object // Generate ID for swf object
let objId = options.techId; const objId = options.techId;
// Merge default flashvars with ones passed in to init // Merge default flashvars with ones passed in to init
let flashVars = assign({ const flashVars = assign({
// SWF Callback Functions // SWF Callback Functions
readyFunction: 'videojs.Flash.onReady', readyFunction: 'videojs.Flash.onReady',
@ -98,7 +98,7 @@ class Flash extends Tech {
}, options.flashVars); }, options.flashVars);
// Merge default parames with ones passed in // Merge default parames with ones passed in
let params = assign({ const params = assign({
// Opaque is needed to overlay controls, but can affect playback performance // Opaque is needed to overlay controls, but can affect playback performance
wmode: 'opaque', wmode: 'opaque',
// Using bgcolor prevents a white flash when the object is loading // Using bgcolor prevents a white flash when the object is loading
@ -106,7 +106,7 @@ class Flash extends Tech {
}, options.params); }, options.params);
// Merge default attributes with ones passed in // Merge default attributes with ones passed in
let attributes = assign({ const attributes = assign({
// Both ID and Name needed or swf to identify itself // Both ID and Name needed or swf to identify itself
id: objId, id: objId,
name: objId, name: objId,
@ -190,7 +190,7 @@ class Flash extends Tech {
* @method setCurrentTime * @method setCurrentTime
*/ */
setCurrentTime(time) { setCurrentTime(time) {
let seekable = this.seekable(); const seekable = this.seekable();
if (seekable.length) { if (seekable.length) {
// clamp to the current seekable range // clamp to the current seekable range
@ -241,7 +241,7 @@ class Flash extends Tech {
if (this.readyState() === 0) { if (this.readyState() === 0) {
return NaN; return NaN;
} }
let duration = this.el_.vjs_getProperty('duration'); const duration = this.el_.vjs_getProperty('duration');
return duration >= 0 ? duration : Infinity; return duration >= 0 ? duration : Infinity;
} }
@ -293,7 +293,7 @@ class Flash extends Tech {
* @method buffered * @method buffered
*/ */
buffered() { buffered() {
let ranges = this.el_.vjs_getProperty('buffered'); const ranges = this.el_.vjs_getProperty('buffered');
if (ranges.length === 0) { if (ranges.length === 0) {
return createTimeRange(); return createTimeRange();
@ -334,7 +334,7 @@ const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playba
const _readOnly = 'networkState,readyState,initialTime,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(','); const _readOnly = 'networkState,readyState,initialTime,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',');
function _createSetter(attr) { function _createSetter(attr) {
let attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1); const attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
_api['set' + attrUpper] = function(val) { _api['set' + attrUpper] = function(val) {
return this.el_.vjs_setProperty(attr, val); return this.el_.vjs_setProperty(attr, val);
@ -401,7 +401,7 @@ Flash.nativeSourceHandler.canHandleSource = function(source, options) {
let type; let type;
function guessMimeType(src) { function guessMimeType(src) {
let ext = Url.getFileExtension(src); const ext = Url.getFileExtension(src);
if (ext) { if (ext) {
return `video/${ext}`; return `video/${ext}`;
@ -449,8 +449,8 @@ Flash.formats = {
}; };
Flash.onReady = function(currSwf) { Flash.onReady = function(currSwf) {
let el = Dom.getEl(currSwf); const el = Dom.getEl(currSwf);
let tech = el && el.tech; const tech = el && el.tech;
// if there is no el then the tech has been disposed // if there is no el then the tech has been disposed
// and the tech element was removed from the player div // and the tech element was removed from the player div
@ -482,7 +482,7 @@ Flash.checkReady = function(tech) {
// Trigger events from the swf on the player // Trigger events from the swf on the player
Flash.onEvent = function(swfID, eventName) { Flash.onEvent = function(swfID, eventName) {
let tech = Dom.getEl(swfID).tech; const tech = Dom.getEl(swfID).tech;
tech.trigger(eventName, Array.prototype.slice.call(arguments, 2)); tech.trigger(eventName, Array.prototype.slice.call(arguments, 2));
}; };

View File

@ -45,13 +45,13 @@ class Html5 extends Tech {
if (this.el_.hasChildNodes()) { if (this.el_.hasChildNodes()) {
let nodes = this.el_.childNodes; const nodes = this.el_.childNodes;
let nodesLength = nodes.length; let nodesLength = nodes.length;
let removeNodes = []; const removeNodes = [];
while (nodesLength--) { while (nodesLength--) {
let node = nodes[nodesLength]; const node = nodes[nodesLength];
let nodeName = node.nodeName.toLowerCase(); const nodeName = node.nodeName.toLowerCase();
if (nodeName === 'track') { if (nodeName === 'track') {
if (!this.featuresNativeTextTracks) { if (!this.featuresNativeTextTracks) {
@ -78,16 +78,16 @@ class Html5 extends Tech {
} }
} }
let trackTypes = ['audio', 'video']; const trackTypes = ['audio', 'video'];
// ProxyNativeTextTracks // ProxyNativeTextTracks
trackTypes.forEach((type) => { trackTypes.forEach((type) => {
let capitalType = toTitleCase(type); const capitalType = toTitleCase(type);
if (!this[`featuresNative${capitalType}Tracks`]) { if (!this[`featuresNative${capitalType}Tracks`]) {
return; return;
} }
let tl = this.el()[`${type}Tracks`]; const tl = this.el()[`${type}Tracks`];
if (tl && tl.addEventListener) { if (tl && tl.addEventListener) {
tl.addEventListener('change', Fn.bind(this, this[`handle${capitalType}TrackChange_`])); tl.addEventListener('change', Fn.bind(this, this[`handle${capitalType}TrackChange_`]));
@ -131,8 +131,8 @@ class Html5 extends Tech {
dispose() { dispose() {
// Un-ProxyNativeTracks // Un-ProxyNativeTracks
['audio', 'video', 'text'].forEach((type) => { ['audio', 'video', 'text'].forEach((type) => {
let capitalType = toTitleCase(type); const capitalType = toTitleCase(type);
let tl = this.el_[`${type}Tracks`]; const tl = this.el_[`${type}Tracks`];
if (tl && tl.removeEventListener) { if (tl && tl.removeEventListener) {
tl.removeEventListener('change', this[`handle${capitalType}TrackChange_`]); tl.removeEventListener('change', this[`handle${capitalType}TrackChange_`]);
@ -176,8 +176,8 @@ class Html5 extends Tech {
el = document.createElement('video'); el = document.createElement('video');
// determine if native controls should be used // determine if native controls should be used
let tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag); const tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
let attributes = mergeOptions({}, tagAttributes); const attributes = mergeOptions({}, tagAttributes);
if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) { if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
delete attributes.controls; delete attributes.controls;
@ -193,11 +193,11 @@ class Html5 extends Tech {
} }
// Update specific tag settings, in case they were overridden // Update specific tag settings, in case they were overridden
let settingsAttrs = ['autoplay', 'preload', 'loop', 'muted']; const settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
for (let i = settingsAttrs.length - 1; i >= 0; i--) { for (let i = settingsAttrs.length - 1; i >= 0; i--) {
const attr = settingsAttrs[i]; const attr = settingsAttrs[i];
let overwriteAttrs = {}; const overwriteAttrs = {};
if (typeof this.options_[attr] !== 'undefined') { if (typeof this.options_[attr] !== 'undefined') {
overwriteAttrs[attr] = this.options_[attr]; overwriteAttrs[attr] = this.options_[attr];
@ -232,13 +232,13 @@ class Html5 extends Tech {
// which could also happen between now and the next loop, so we'll // which could also happen between now and the next loop, so we'll
// watch for that also. // watch for that also.
let loadstartFired = false; let loadstartFired = false;
let setLoadstartFired = function() { const setLoadstartFired = function() {
loadstartFired = true; loadstartFired = true;
}; };
this.on('loadstart', setLoadstartFired); this.on('loadstart', setLoadstartFired);
let triggerLoadstart = function() { const triggerLoadstart = function() {
// We did miss the original loadstart. Make sure the player // We did miss the original loadstart. Make sure the player
// sees loadstart before loadedmetadata // sees loadstart before loadedmetadata
if (!loadstartFired) { if (!loadstartFired) {
@ -265,7 +265,7 @@ class Html5 extends Tech {
// The other readyState events aren't as much of a problem if we double // The other readyState events aren't as much of a problem if we double
// them, so not going to go to as much trouble as loadstart to prevent // them, so not going to go to as much trouble as loadstart to prevent
// that unless we find reason to. // that unless we find reason to.
let eventsToTrigger = ['loadstart']; const eventsToTrigger = ['loadstart'];
// loadedmetadata: newly equal to HAVE_METADATA (1) or greater // loadedmetadata: newly equal to HAVE_METADATA (1) or greater
eventsToTrigger.push('loadedmetadata'); eventsToTrigger.push('loadedmetadata');
@ -294,7 +294,7 @@ class Html5 extends Tech {
} }
proxyNativeTextTracks_() { proxyNativeTextTracks_() {
let tt = this.el().textTracks; const tt = this.el().textTracks;
if (tt) { if (tt) {
// Add tracks - if player is initialised after DOM loaded, textTracks // Add tracks - if player is initialised after DOM loaded, textTracks
@ -315,7 +315,7 @@ class Html5 extends Tech {
} }
handleTextTrackChange(e) { handleTextTrackChange(e) {
let tt = this.textTracks(); const tt = this.textTracks();
this.textTracks().trigger({ this.textTracks().trigger({
type: 'change', type: 'change',
@ -334,7 +334,7 @@ class Html5 extends Tech {
} }
handleVideoTrackChange_(e) { handleVideoTrackChange_(e) {
let vt = this.videoTracks(); const vt = this.videoTracks();
this.videoTracks().trigger({ this.videoTracks().trigger({
type: 'change', type: 'change',
@ -353,7 +353,7 @@ class Html5 extends Tech {
} }
handleAudioTrackChange_(e) { handleAudioTrackChange_(e) {
let audioTrackList = this.audioTracks(); const audioTrackList = this.audioTracks();
this.audioTracks().trigger({ this.audioTracks().trigger({
type: 'change', type: 'change',
@ -381,14 +381,14 @@ class Html5 extends Tech {
removeOldTracks_(techTracks, elTracks) { removeOldTracks_(techTracks, elTracks) {
// This will loop over the techTracks and check if they are still used by the HTML5 video element // This will loop over the techTracks and check if they are still used by the HTML5 video element
// If not, they will be removed from the emulated list // If not, they will be removed from the emulated list
let removeTracks = []; const removeTracks = [];
if (!elTracks) { if (!elTracks) {
return; return;
} }
for (let i = 0; i < techTracks.length; i++) { for (let i = 0; i < techTracks.length; i++) {
let techTrack = techTracks[i]; const techTrack = techTracks[i];
let found = false; let found = false;
for (let j = 0; j < elTracks.length; j++) { for (let j = 0; j < elTracks.length; j++) {
@ -574,7 +574,7 @@ class Html5 extends Tech {
*/ */
supportsFullScreen() { supportsFullScreen() {
if (typeof this.el_.webkitEnterFullScreen === 'function') { if (typeof this.el_.webkitEnterFullScreen === 'function') {
let userAgent = window.navigator.userAgent; const userAgent = window.navigator.userAgent;
// Seems to be broken in Chromium/Chrome && Safari in Leopard // Seems to be broken in Chromium/Chrome && Safari in Leopard
if ((/Android/).test(userAgent) || !(/Chrome|Mac OS X 10.5/).test(userAgent)) { if ((/Android/).test(userAgent) || !(/Chrome|Mac OS X 10.5/).test(userAgent)) {
@ -590,7 +590,7 @@ class Html5 extends Tech {
* @method enterFullScreen * @method enterFullScreen
*/ */
enterFullScreen() { enterFullScreen() {
let video = this.el_; const video = this.el_;
if ('webkitDisplayingFullscreen' in video) { if ('webkitDisplayingFullscreen' in video) {
this.one('webkitbeginfullscreen', function() { this.one('webkitbeginfullscreen', function() {
@ -963,7 +963,7 @@ class Html5 extends Tech {
return super.addRemoteTextTrack(options); return super.addRemoteTextTrack(options);
} }
let htmlTrackElement = document.createElement('track'); const htmlTrackElement = document.createElement('track');
if (options.kind) { if (options.kind) {
htmlTrackElement.kind = options.kind; htmlTrackElement.kind = options.kind;
@ -1004,14 +1004,13 @@ class Html5 extends Tech {
return super.removeRemoteTextTrack(track); return super.removeRemoteTextTrack(track);
} }
let tracks; const trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
let trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
// remove HTMLTrackElement and TextTrack from remote list // remove HTMLTrackElement and TextTrack from remote list
this.remoteTextTrackEls().removeTrackElement_(trackElement); this.remoteTextTrackEls().removeTrackElement_(trackElement);
this.remoteTextTracks().removeTrack_(track); this.remoteTextTracks().removeTrack_(track);
tracks = this.$$('track'); const tracks = this.$$('track');
let i = tracks.length; let i = tracks.length;
@ -1034,7 +1033,7 @@ class Html5 extends Tech {
* @private * @private
*/ */
Html5.TEST_VID = document.createElement('video'); Html5.TEST_VID = document.createElement('video');
let track = document.createElement('track'); const track = document.createElement('track');
track.kind = 'captions'; track.kind = 'captions';
track.srclang = 'en'; track.srclang = 'en';
@ -1100,7 +1099,7 @@ Html5.nativeSourceHandler.canHandleSource = function(source, options) {
// If no type, fall back to checking 'video/[EXTENSION]' // If no type, fall back to checking 'video/[EXTENSION]'
} else if (source.src) { } else if (source.src) {
let ext = Url.getFileExtension(source.src); const ext = Url.getFileExtension(source.src);
return Html5.nativeSourceHandler.canPlayType(`video/${ext}`); return Html5.nativeSourceHandler.canPlayType(`video/${ext}`);
} }
@ -1140,7 +1139,7 @@ Html5.registerSourceHandler(Html5.nativeSourceHandler);
Html5.canControlVolume = function() { Html5.canControlVolume = function() {
// IE will error if Windows Media Player not installed #3315 // IE will error if Windows Media Player not installed #3315
try { try {
let volume = Html5.TEST_VID.volume; const volume = Html5.TEST_VID.volume;
Html5.TEST_VID.volume = (volume / 2) + 0.1; Html5.TEST_VID.volume = (volume / 2) + 0.1;
return volume !== Html5.TEST_VID.volume; return volume !== Html5.TEST_VID.volume;
@ -1162,7 +1161,7 @@ Html5.canControlPlaybackRate = function() {
} }
// IE will error if Windows Media Player not installed #3315 // IE will error if Windows Media Player not installed #3315
try { try {
let playbackRate = Html5.TEST_VID.playbackRate; const playbackRate = Html5.TEST_VID.playbackRate;
Html5.TEST_VID.playbackRate = (playbackRate / 2) + 0.1; Html5.TEST_VID.playbackRate = (playbackRate / 2) + 0.1;
return playbackRate !== Html5.TEST_VID.playbackRate; return playbackRate !== Html5.TEST_VID.playbackRate;
@ -1204,7 +1203,7 @@ Html5.supportsNativeTextTracks = function() {
* @return {Boolean} * @return {Boolean}
*/ */
Html5.supportsNativeVideoTracks = function() { Html5.supportsNativeVideoTracks = function() {
let supportsVideoTracks = !!Html5.TEST_VID.videoTracks; const supportsVideoTracks = !!Html5.TEST_VID.videoTracks;
return supportsVideoTracks; return supportsVideoTracks;
}; };
@ -1215,7 +1214,7 @@ Html5.supportsNativeVideoTracks = function() {
* @return {Boolean} * @return {Boolean}
*/ */
Html5.supportsNativeAudioTracks = function() { Html5.supportsNativeAudioTracks = function() {
let supportsAudioTracks = !!Html5.TEST_VID.audioTracks; const supportsAudioTracks = !!Html5.TEST_VID.audioTracks;
return supportsAudioTracks; return supportsAudioTracks;
}; };
@ -1343,7 +1342,7 @@ Html5.patchCanPlayType = function() {
}; };
Html5.unpatchCanPlayType = function() { Html5.unpatchCanPlayType = function() {
let r = Html5.TEST_VID.constructor.prototype.canPlayType; const r = Html5.TEST_VID.constructor.prototype.canPlayType;
Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType; Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType;
canPlayType = null; canPlayType = null;
@ -1390,7 +1389,7 @@ Html5.resetMediaElement = function(el) {
return; return;
} }
let sources = el.querySelectorAll('source'); const sources = el.querySelectorAll('source');
let i = sources.length; let i = sources.length;
while (i--) { while (i--) {

View File

@ -25,7 +25,7 @@ class MediaLoader extends Component {
if (!options.playerOptions.sources || options.playerOptions.sources.length === 0) { if (!options.playerOptions.sources || options.playerOptions.sources.length === 0) {
for (let i = 0, j = options.playerOptions.techOrder; i < j.length; i++) { for (let i = 0, j = options.playerOptions.techOrder; i < j.length; i++) {
let techName = toTitleCase(j[i]); const techName = toTitleCase(j[i]);
let tech = Tech.getTech(techName); let tech = Tech.getTech(techName);
// Support old behavior of techs being registered as components. // Support old behavior of techs being registered as components.

View File

@ -21,7 +21,7 @@ import window from 'global/window';
import document from 'global/document'; import document from 'global/document';
function createTrackHelper(self, kind, label, language, options = {}) { function createTrackHelper(self, kind, label, language, options = {}) {
let tracks = self.textTracks(); const tracks = self.textTracks();
options.kind = kind; options.kind = kind;
@ -33,7 +33,7 @@ function createTrackHelper(self, kind, label, language, options = {}) {
} }
options.tech = self; options.tech = self;
let track = new TextTrack(options); const track = new TextTrack(options);
tracks.addTrack_(track); tracks.addTrack_(track);
@ -135,7 +135,7 @@ class Tech extends Component {
this.progressInterval = this.setInterval(Fn.bind(this, function() { this.progressInterval = this.setInterval(Fn.bind(this, function() {
// Don't trigger unless buffered amount is greater than last time // Don't trigger unless buffered amount is greater than last time
let numBufferedPercent = this.bufferedPercent(); const numBufferedPercent = this.bufferedPercent();
if (this.bufferedPercent_ !== numBufferedPercent) { if (this.bufferedPercent_ !== numBufferedPercent) {
this.trigger('progress'); this.trigger('progress');
@ -277,11 +277,11 @@ class Tech extends Component {
types = [].concat(types); types = [].concat(types);
// clear out all tracks because we can't reuse them between techs // clear out all tracks because we can't reuse them between techs
types.forEach((type) => { types.forEach((type) => {
let list = this[`${type}Tracks`]() || []; const list = this[`${type}Tracks`]() || [];
let i = list.length; let i = list.length;
while (i--) { while (i--) {
let track = list[i]; const track = list[i];
if (type === 'text') { if (type === 'text') {
this.removeRemoteTextTrack(track); this.removeRemoteTextTrack(track);
@ -353,11 +353,11 @@ class Tech extends Component {
* @method initTextTrackListeners * @method initTextTrackListeners
*/ */
initTextTrackListeners() { initTextTrackListeners() {
let textTrackListChanges = Fn.bind(this, function() { const textTrackListChanges = Fn.bind(this, function() {
this.trigger('texttrackchange'); this.trigger('texttrackchange');
}); });
let tracks = this.textTracks(); const tracks = this.textTracks();
if (!tracks) { if (!tracks) {
return; return;
@ -381,11 +381,11 @@ class Tech extends Component {
const trackTypes = ['video', 'audio']; const trackTypes = ['video', 'audio'];
trackTypes.forEach((type) => { trackTypes.forEach((type) => {
let trackListChanges = () => { const trackListChanges = () => {
this.trigger(`${type}trackchange`); this.trigger(`${type}trackchange`);
}; };
let tracks = this[`${type}Tracks`](); const tracks = this[`${type}Tracks`]();
tracks.addEventListener('removetrack', trackListChanges); tracks.addEventListener('removetrack', trackListChanges);
tracks.addEventListener('addtrack', trackListChanges); tracks.addEventListener('addtrack', trackListChanges);
@ -403,14 +403,14 @@ class Tech extends Component {
* @method emulateTextTracks * @method emulateTextTracks
*/ */
emulateTextTracks() { emulateTextTracks() {
let tracks = this.textTracks(); const tracks = this.textTracks();
if (!tracks) { if (!tracks) {
return; return;
} }
if (!window.WebVTT && this.el().parentNode != null) { if (!window.WebVTT && this.el().parentNode !== null && this.el().parentNode !== undefined) {
let script = document.createElement('script'); const script = document.createElement('script');
script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js'; script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js';
script.onload = () => { script.onload = () => {
@ -429,12 +429,12 @@ class Tech extends Component {
this.el().parentNode.appendChild(script); this.el().parentNode.appendChild(script);
} }
let updateDisplay = () => this.trigger('texttrackchange'); const updateDisplay = () => this.trigger('texttrackchange');
let textTracksChanges = () => { const textTracksChanges = () => {
updateDisplay(); updateDisplay();
for (let i = 0; i < tracks.length; i++) { for (let i = 0; i < tracks.length; i++) {
let track = tracks[i]; const track = tracks[i];
track.removeEventListener('cuechange', updateDisplay); track.removeEventListener('cuechange', updateDisplay);
if (track.mode === 'showing') { if (track.mode === 'showing') {
@ -539,11 +539,11 @@ class Tech extends Component {
* @method addRemoteTextTrack * @method addRemoteTextTrack
*/ */
addRemoteTextTrack(options) { addRemoteTextTrack(options) {
let track = mergeOptions(options, { const track = mergeOptions(options, {
tech: this tech: this
}); });
let htmlTrackElement = new HTMLTrackElement(track); const htmlTrackElement = new HTMLTrackElement(track);
// store HTMLTrackElement and TextTrack to remote list // store HTMLTrackElement and TextTrack to remote list
this.remoteTextTrackEls().addTrackElement_(htmlTrackElement); this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
@ -564,7 +564,7 @@ class Tech extends Component {
removeRemoteTextTrack(track) { removeRemoteTextTrack(track) {
this.textTracks().removeTrack_(track); this.textTracks().removeTrack_(track);
let trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track); const trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
// remove HTMLTrackElement and TextTrack from remote list // remove HTMLTrackElement and TextTrack from remote list
this.remoteTextTrackEls().removeTrackElement_(trackElement); this.remoteTextTrackEls().removeTrackElement_(trackElement);
@ -723,7 +723,7 @@ Tech.withSourceHandlers = function(_Tech) {
* @return {String} 'probably', 'maybe', or '' (empty string) * @return {String} 'probably', 'maybe', or '' (empty string)
*/ */
_Tech.canPlayType = function(type) { _Tech.canPlayType = function(type) {
let handlers = _Tech.sourceHandlers || []; const handlers = _Tech.sourceHandlers || [];
let can; let can;
for (let i = 0; i < handlers.length; i++) { for (let i = 0; i < handlers.length; i++) {
@ -746,7 +746,7 @@ Tech.withSourceHandlers = function(_Tech) {
* @returns {null} Null if no source handler is found * @returns {null} Null if no source handler is found
*/ */
_Tech.selectSourceHandler = function(source, options) { _Tech.selectSourceHandler = function(source, options) {
let handlers = _Tech.sourceHandlers || []; const handlers = _Tech.sourceHandlers || [];
let can; let can;
for (let i = 0; i < handlers.length; i++) { for (let i = 0; i < handlers.length; i++) {
@ -767,7 +767,7 @@ Tech.withSourceHandlers = function(_Tech) {
* @return {String} 'probably', 'maybe', or '' (empty string) * @return {String} 'probably', 'maybe', or '' (empty string)
*/ */
_Tech.canPlaySource = function(srcObj, options) { _Tech.canPlaySource = function(srcObj, options) {
let sh = _Tech.selectSourceHandler(srcObj, options); const sh = _Tech.selectSourceHandler(srcObj, options);
if (sh) { if (sh) {
return sh.canHandleSource(srcObj, options); return sh.canHandleSource(srcObj, options);
@ -780,13 +780,13 @@ Tech.withSourceHandlers = function(_Tech) {
* When using a source handler, prefer its implementation of * When using a source handler, prefer its implementation of
* any function normally provided by the tech. * any function normally provided by the tech.
*/ */
let deferrable = [ const deferrable = [
'seekable', 'seekable',
'duration' 'duration'
]; ];
deferrable.forEach(function(fnName) { deferrable.forEach(function(fnName) {
let originalFn = this[fnName]; const originalFn = this[fnName];
if (typeof originalFn !== 'function') { if (typeof originalFn !== 'function') {
return; return;

View File

@ -58,12 +58,12 @@ class AudioTrackList extends TrackList {
// as it does not support Object.defineProperty properly // as it does not support Object.defineProperty properly
if (browser.IS_IE8) { if (browser.IS_IE8) {
list = document.createElement('custom'); list = document.createElement('custom');
for (let prop in TrackList.prototype) { for (const prop in TrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop]; list[prop] = TrackList.prototype[prop];
} }
} }
for (let prop in AudioTrackList.prototype) { for (const prop in AudioTrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = AudioTrackList.prototype[prop]; list[prop] = AudioTrackList.prototype[prop];
} }

View File

@ -20,16 +20,16 @@ import * as browser from '../utils/browser.js';
*/ */
class AudioTrack extends Track { class AudioTrack extends Track {
constructor(options = {}) { constructor(options = {}) {
let settings = merge(options, { const settings = merge(options, {
kind: AudioTrackKind[options.kind] || '' kind: AudioTrackKind[options.kind] || ''
}); });
// on IE8 this will be a document element // on IE8 this will be a document element
// for every other browser this will be a normal object // for every other browser this will be a normal object
let track = super(settings); const track = super(settings);
let enabled = false; let enabled = false;
if (browser.IS_IE8) { if (browser.IS_IE8) {
for (let prop in AudioTrack.prototype) { for (const prop in AudioTrack.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
track[prop] = AudioTrack.prototype[prop]; track[prop] = AudioTrack.prototype[prop];
} }

View File

@ -12,7 +12,7 @@ class HtmlTrackElementList {
if (browser.IS_IE8) { if (browser.IS_IE8) {
list = document.createElement('custom'); list = document.createElement('custom');
for (let prop in HtmlTrackElementList.prototype) { for (const prop in HtmlTrackElementList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = HtmlTrackElementList.prototype[prop]; list[prop] = HtmlTrackElementList.prototype[prop];
} }

View File

@ -45,14 +45,14 @@ class HTMLTrackElement extends EventTarget {
if (browser.IS_IE8) { if (browser.IS_IE8) {
trackElement = document.createElement('custom'); trackElement = document.createElement('custom');
for (let prop in HTMLTrackElement.prototype) { for (const prop in HTMLTrackElement.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
trackElement[prop] = HTMLTrackElement.prototype[prop]; trackElement[prop] = HTMLTrackElement.prototype[prop];
} }
} }
} }
let track = new TextTrack(options); const track = new TextTrack(options);
trackElement.kind = track.kind; trackElement.kind = track.kind;
trackElement.src = track.src; trackElement.src = track.src;

View File

@ -25,7 +25,7 @@ class TextTrackCueList {
if (browser.IS_IE8) { if (browser.IS_IE8) {
list = document.createElement('custom'); list = document.createElement('custom');
for (let prop in TextTrackCueList.prototype) { for (const prop in TextTrackCueList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = TextTrackCueList.prototype[prop]; list[prop] = TextTrackCueList.prototype[prop];
} }
@ -53,14 +53,14 @@ class TextTrackCueList {
* @private * @private
*/ */
setCues_(cues) { setCues_(cues) {
let oldLength = this.length || 0; const oldLength = this.length || 0;
let i = 0; let i = 0;
let l = cues.length; const l = cues.length;
this.cues_ = cues; this.cues_ = cues;
this.length_ = cues.length; this.length_ = cues.length;
let defineProp = function(index) { const defineProp = function(index) {
if (!('' + index in this)) { if (!('' + index in this)) {
Object.defineProperty(this, '' + index, { Object.defineProperty(this, '' + index, {
get() { get() {
@ -90,7 +90,7 @@ class TextTrackCueList {
let result = null; let result = null;
for (let i = 0, l = this.length; i < l; i++) { for (let i = 0, l = this.length; i < l; i++) {
let cue = this[i]; const cue = this[i];
if (cue.id === id) { if (cue.id === id) {
result = cue; result = cue;

View File

@ -85,20 +85,20 @@ class TextTrackDisplay extends Component {
player.on('fullscreenchange', Fn.bind(this, this.updateDisplay)); player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
let tracks = this.options_.playerOptions.tracks || []; const tracks = this.options_.playerOptions.tracks || [];
for (let i = 0; i < tracks.length; i++) { for (let i = 0; i < tracks.length; i++) {
this.player_.addRemoteTextTrack(tracks[i]); this.player_.addRemoteTextTrack(tracks[i]);
} }
let modes = {captions: 1, subtitles: 1}; const modes = {captions: 1, subtitles: 1};
let trackList = this.player_.textTracks(); const trackList = this.player_.textTracks();
let firstDesc; let firstDesc;
let firstCaptions; let firstCaptions;
if (trackList) { if (trackList) {
for (let i = 0; i < trackList.length; i++) { for (let i = 0; i < trackList.length; i++) {
let track = trackList[i]; const track = trackList[i];
if (track.default) { if (track.default) {
if (track.kind === 'descriptions' && !firstDesc) { if (track.kind === 'descriptions' && !firstDesc) {
@ -167,7 +167,7 @@ class TextTrackDisplay extends Component {
* @method updateDisplay * @method updateDisplay
*/ */
updateDisplay() { updateDisplay() {
let tracks = this.player_.textTracks(); const tracks = this.player_.textTracks();
this.clearDisplay(); this.clearDisplay();
@ -185,7 +185,7 @@ class TextTrackDisplay extends Component {
let i = tracks.length; let i = tracks.length;
while (i--) { while (i--) {
let track = tracks[i]; const track = tracks[i];
if (track.mode === 'showing') { if (track.mode === 'showing') {
if (track.kind === 'descriptions') { if (track.kind === 'descriptions') {
@ -214,8 +214,8 @@ class TextTrackDisplay extends Component {
return; return;
} }
let overrides = this.player_.textTrackSettings.getValues(); const overrides = this.player_.textTrackSettings.getValues();
let cues = []; const cues = [];
for (let i = 0; i < track.activeCues.length; i++) { for (let i = 0; i < track.activeCues.length; i++) {
cues.push(track.activeCues[i]); cues.push(track.activeCues[i]);
@ -226,13 +226,13 @@ class TextTrackDisplay extends Component {
let i = cues.length; let i = cues.length;
while (i--) { while (i--) {
let cue = cues[i]; const cue = cues[i];
if (!cue) { if (!cue) {
continue; continue;
} }
let cueDiv = cue.displayState; const cueDiv = cue.displayState;
if (overrides.color) { if (overrides.color) {
cueDiv.firstChild.style.color = overrides.color; cueDiv.firstChild.style.color = overrides.color;

View File

@ -12,8 +12,8 @@
* @return {Object} a serializable javascript representation of the * @return {Object} a serializable javascript representation of the
* @private * @private
*/ */
let trackToJson_ = function(track) { const trackToJson_ = function(track) {
let ret = [ const ret = [
'kind', 'label', 'language', 'id', 'kind', 'label', 'language', 'id',
'inBandMetadataTrackDispatchType', 'mode', 'src' 'inBandMetadataTrackDispatchType', 'mode', 'src'
].reduce((acc, prop, i) => { ].reduce((acc, prop, i) => {
@ -45,13 +45,13 @@ let trackToJson_ = function(track) {
* @return {Array} a serializable javascript representation of the * @return {Array} a serializable javascript representation of the
* @function textTracksToJson * @function textTracksToJson
*/ */
let textTracksToJson = function(tech) { const textTracksToJson = function(tech) {
let trackEls = tech.$$('track'); const trackEls = tech.$$('track');
let trackObjs = Array.prototype.map.call(trackEls, (t) => t.track); const trackObjs = Array.prototype.map.call(trackEls, (t) => t.track);
let tracks = Array.prototype.map.call(trackEls, function(trackEl) { const tracks = Array.prototype.map.call(trackEls, function(trackEl) {
let json = trackToJson_(trackEl.track); const json = trackToJson_(trackEl.track);
if (trackEl.src) { if (trackEl.src) {
json.src = trackEl.src; json.src = trackEl.src;
@ -72,9 +72,9 @@ let textTracksToJson = function(tech) {
* @param tech {tech} the tech to create text tracks on * @param tech {tech} the tech to create text tracks on
* @function jsonToTextTracks * @function jsonToTextTracks
*/ */
let jsonToTextTracks = function(json, tech) { const jsonToTextTracks = function(json, tech) {
json.forEach(function(track) { json.forEach(function(track) {
let addedTrack = tech.addRemoteTextTrack(track).track; const addedTrack = tech.addRemoteTextTrack(track).track;
if (!track.src && track.cues) { if (!track.src && track.cues) {
track.cues.forEach((cue) => addedTrack.addCue(cue)); track.cues.forEach((cue) => addedTrack.addCue(cue));

View File

@ -33,12 +33,12 @@ class TextTrackList extends TrackList {
// as it does not support Object.defineProperty properly // as it does not support Object.defineProperty properly
if (browser.IS_IE8) { if (browser.IS_IE8) {
list = document.createElement('custom'); list = document.createElement('custom');
for (let prop in TrackList.prototype) { for (const prop in TrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop]; list[prop] = TrackList.prototype[prop];
} }
} }
for (let prop in TextTrackList.prototype) { for (const prop in TextTrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = TextTrackList.prototype[prop]; list[prop] = TextTrackList.prototype[prop];
} }
@ -102,7 +102,7 @@ class TextTrackList extends TrackList {
let result = null; let result = null;
for (let i = 0, l = this.length; i < l; i++) { for (let i = 0, l = this.length; i < l; i++) {
let track = this[i]; const track = this[i];
if (track.id === id) { if (track.id === id) {
result = track; result = track;

View File

@ -9,7 +9,7 @@ import safeParseTuple from 'safe-json-parse/tuple';
import window from 'global/window'; import window from 'global/window';
function captionOptionsMenuTemplate(uniqueId, dialogLabelId, dialogDescriptionId) { function captionOptionsMenuTemplate(uniqueId, dialogLabelId, dialogDescriptionId) {
let template = ` const template = `
<div role="document"> <div role="document">
<div role="heading" aria-level="1" id="${dialogLabelId}" class="vjs-control-text">Captions Settings Dialog</div> <div role="heading" aria-level="1" id="${dialogLabelId}" class="vjs-control-text">Captions Settings Dialog</div>
<div id="${dialogDescriptionId}" class="vjs-control-text">Beginning of dialog window. Escape will cancel and close the window.</div> <div id="${dialogDescriptionId}" class="vjs-control-text">Beginning of dialog window. Escape will cancel and close the window.</div>
@ -220,9 +220,9 @@ class TextTrackSettings extends Component {
* @method createEl * @method createEl
*/ */
createEl() { createEl() {
let uniqueId = this.id_; const uniqueId = this.id_;
let dialogLabelId = 'TTsettingsDialogLabel-' + uniqueId; const dialogLabelId = 'TTsettingsDialogLabel-' + uniqueId;
let dialogDescriptionId = 'TTsettingsDialogDescription-' + uniqueId; const dialogDescriptionId = 'TTsettingsDialogDescription-' + uniqueId;
return super.createEl('div', { return super.createEl('div', {
className: 'vjs-caption-settings vjs-modal-overlay', className: 'vjs-caption-settings vjs-modal-overlay',
@ -261,7 +261,7 @@ class TextTrackSettings extends Component {
const windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select')); const windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select'));
const fontPercent = window.parseFloat(getSelectedOptionValue(this.$('.vjs-font-percent > select'))); const fontPercent = window.parseFloat(getSelectedOptionValue(this.$('.vjs-font-percent > select')));
let result = { const result = {
fontPercent, fontPercent,
fontFamily, fontFamily,
textOpacity, textOpacity,
@ -273,7 +273,7 @@ class TextTrackSettings extends Component {
backgroundColor: bgColor backgroundColor: bgColor
}; };
for (let name in result) { for (const name in result) {
if (result[name] === '' || result[name] === 'none' || (name === 'fontPercent' && result[name] === 1.00)) { if (result[name] === '' || result[name] === 'none' || (name === 'fontPercent' && result[name] === 1.00)) {
delete result[name]; delete result[name];
} }
@ -349,7 +349,7 @@ class TextTrackSettings extends Component {
return; return;
} }
let values = this.getValues(); const values = this.getValues();
try { try {
if (Object.getOwnPropertyNames(values).length > 0) { if (Object.getOwnPropertyNames(values).length > 0) {
@ -368,7 +368,7 @@ class TextTrackSettings extends Component {
* @method updateDisplay * @method updateDisplay
*/ */
updateDisplay() { updateDisplay() {
let ttDisplay = this.player_.getChild('textTrackDisplay'); const ttDisplay = this.player_.getChild('textTrackDisplay');
if (ttDisplay) { if (ttDisplay) {
ttDisplay.updateDisplay(); ttDisplay.updateDisplay();

View File

@ -19,10 +19,10 @@ import * as browser from '../utils/browser.js';
* @param {Track} track track to addcues to * @param {Track} track track to addcues to
*/ */
const parseCues = function(srcContent, track) { const parseCues = function(srcContent, track) {
let parser = new window.WebVTT.Parser(window, const parser = new window.WebVTT.Parser(window,
window.vttjs, window.vttjs,
window.WebVTT.StringDecoder()); window.WebVTT.StringDecoder());
let errors = []; const errors = [];
parser.oncue = function(cue) { parser.oncue = function(cue) {
track.addCue(cue); track.addCue(cue);
@ -60,10 +60,10 @@ const parseCues = function(srcContent, track) {
* @param {Track} track track to addcues to * @param {Track} track track to addcues to
*/ */
const loadTrack = function(src, track) { const loadTrack = function(src, track) {
let opts = { const opts = {
uri: src uri: src
}; };
let crossOrigin = isCrossOrigin(src); const crossOrigin = isCrossOrigin(src);
if (crossOrigin) { if (crossOrigin) {
opts.cors = crossOrigin; opts.cors = crossOrigin;
@ -80,7 +80,7 @@ const loadTrack = function(src, track) {
// NOTE: this is only used for the alt/video.novtt.js build // NOTE: this is only used for the alt/video.novtt.js build
if (typeof window.WebVTT !== 'function') { if (typeof window.WebVTT !== 'function') {
if (track.tech_) { if (track.tech_) {
let loadHandler = () => parseCues(responseBody, track); const loadHandler = () => parseCues(responseBody, track);
track.tech_.on('vttjsloaded', loadHandler); track.tech_.on('vttjsloaded', loadHandler);
track.tech_.on('vttjserror', () => { track.tech_.on('vttjserror', () => {
@ -129,24 +129,24 @@ class TextTrack extends Track {
throw new Error('A tech was not provided.'); throw new Error('A tech was not provided.');
} }
let settings = merge(options, { const settings = merge(options, {
kind: TextTrackKind[options.kind] || 'subtitles', kind: TextTrackKind[options.kind] || 'subtitles',
language: options.language || options.srclang || '' language: options.language || options.srclang || ''
}); });
let mode = TextTrackMode[settings.mode] || 'disabled'; let mode = TextTrackMode[settings.mode] || 'disabled';
let default_ = settings.default; const default_ = settings.default;
if (settings.kind === 'metadata' || settings.kind === 'chapters') { if (settings.kind === 'metadata' || settings.kind === 'chapters') {
mode = 'hidden'; mode = 'hidden';
} }
// on IE8 this will be a document element // on IE8 this will be a document element
// for every other browser this will be a normal object // for every other browser this will be a normal object
let tt = super(settings); const tt = super(settings);
tt.tech_ = settings.tech; tt.tech_ = settings.tech;
if (browser.IS_IE8) { if (browser.IS_IE8) {
for (let prop in TextTrack.prototype) { for (const prop in TextTrack.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
tt[prop] = TextTrack.prototype[prop]; tt[prop] = TextTrack.prototype[prop];
} }
@ -156,15 +156,17 @@ class TextTrack extends Track {
tt.cues_ = []; tt.cues_ = [];
tt.activeCues_ = []; tt.activeCues_ = [];
let cues = new TextTrackCueList(tt.cues_); const cues = new TextTrackCueList(tt.cues_);
let activeCues = new TextTrackCueList(tt.activeCues_); const activeCues = new TextTrackCueList(tt.activeCues_);
let changed = false; let changed = false;
let timeupdateHandler = Fn.bind(tt, function() { const timeupdateHandler = Fn.bind(tt, function() {
// Accessing this.activeCues for the side-effects of updating itself // Accessing this.activeCues for the side-effects of updating itself
// due to it's nature as a getter function. Do not remove or cues will // due to it's nature as a getter function. Do not remove or cues will
// stop updating! // stop updating!
/* eslint-disable no-unused-expressions */
this.activeCues; this.activeCues;
/* eslint-enable no-unused-expressions */
if (changed) { if (changed) {
this.trigger('cuechange'); this.trigger('cuechange');
changed = false; changed = false;
@ -220,11 +222,11 @@ class TextTrack extends Track {
return activeCues; return activeCues;
} }
let ct = this.tech_.currentTime(); const ct = this.tech_.currentTime();
let active = []; const active = [];
for (let i = 0, l = this.cues.length; i < l; i++) { for (let i = 0, l = this.cues.length; i < l; i++) {
let cue = this.cues[i]; const cue = this.cues[i];
if (cue.startTime <= ct && cue.endTime >= ct) { if (cue.startTime <= ct && cue.endTime >= ct) {
active.push(cue); active.push(cue);
@ -272,7 +274,7 @@ class TextTrack extends Track {
* @method addCue * @method addCue
*/ */
addCue(cue) { addCue(cue) {
let tracks = this.tech_.textTracks(); const tracks = this.tech_.textTracks();
if (tracks) { if (tracks) {
for (let i = 0; i < tracks.length; i++) { for (let i = 0; i < tracks.length; i++) {
@ -296,7 +298,7 @@ class TextTrack extends Track {
let removed = false; let removed = false;
for (let i = 0, l = this.cues_.length; i < l; i++) { for (let i = 0, l = this.cues_.length; i < l; i++) {
let cue = this.cues_[i]; const cue = this.cues_[i];
if (cue === removeCue) { if (cue === removeCue) {
this.cues_.splice(i, 1); this.cues_.splice(i, 1);

View File

@ -22,7 +22,7 @@ class TrackList extends EventTarget {
list = this; // eslint-disable-line list = this; // eslint-disable-line
if (browser.IS_IE8) { if (browser.IS_IE8) {
list = document.createElement('custom'); list = document.createElement('custom');
for (let prop in TrackList.prototype) { for (const prop in TrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop]; list[prop] = TrackList.prototype[prop];
} }
@ -52,7 +52,7 @@ class TrackList extends EventTarget {
* @private * @private
*/ */
addTrack_(track) { addTrack_(track) {
let index = this.tracks_.length; const index = this.tracks_.length;
if (!('' + index in this)) { if (!('' + index in this)) {
Object.defineProperty(this, index, { Object.defineProperty(this, index, {
@ -117,7 +117,7 @@ class TrackList extends EventTarget {
let result = null; let result = null;
for (let i = 0, l = this.length; i < l; i++) { for (let i = 0, l = this.length; i < l; i++) {
let track = this[i]; const track = this[i];
if (track.id === id) { if (track.id === id) {
result = track; result = track;
@ -141,7 +141,7 @@ TrackList.prototype.allowedEvents_ = {
}; };
// emulate attribute EventHandler support to allow for feature detection // emulate attribute EventHandler support to allow for feature detection
for (let event in TrackList.prototype.allowedEvents_) { for (const event in TrackList.prototype.allowedEvents_) {
TrackList.prototype['on' + event] = null; TrackList.prototype['on' + event] = null;
} }

View File

@ -23,21 +23,21 @@ class Track extends EventTarget {
if (browser.IS_IE8) { if (browser.IS_IE8) {
track = document.createElement('custom'); track = document.createElement('custom');
for (let prop in Track.prototype) { for (const prop in Track.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
track[prop] = Track.prototype[prop]; track[prop] = Track.prototype[prop];
} }
} }
} }
let trackProps = { const trackProps = {
id: options.id || 'vjs_track_' + Guid.newGUID(), id: options.id || 'vjs_track_' + Guid.newGUID(),
kind: options.kind || '', kind: options.kind || '',
label: options.label || '', label: options.label || '',
language: options.language || '' language: options.language || ''
}; };
for (let key in trackProps) { for (const key in trackProps) {
Object.defineProperty(track, key, { Object.defineProperty(track, key, {
get() { get() {
return trackProps[key]; return trackProps[key];

View File

@ -59,12 +59,12 @@ class VideoTrackList extends TrackList {
// as it does not support Object.defineProperty properly // as it does not support Object.defineProperty properly
if (browser.IS_IE8) { if (browser.IS_IE8) {
list = document.createElement('custom'); list = document.createElement('custom');
for (let prop in TrackList.prototype) { for (const prop in TrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop]; list[prop] = TrackList.prototype[prop];
} }
} }
for (let prop in VideoTrackList.prototype) { for (const prop in VideoTrackList.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
list[prop] = VideoTrackList.prototype[prop]; list[prop] = VideoTrackList.prototype[prop];
} }

View File

@ -20,17 +20,17 @@ import * as browser from '../utils/browser.js';
*/ */
class VideoTrack extends Track { class VideoTrack extends Track {
constructor(options = {}) { constructor(options = {}) {
let settings = merge(options, { const settings = merge(options, {
kind: VideoTrackKind[options.kind] || '' kind: VideoTrackKind[options.kind] || ''
}); });
// on IE8 this will be a document element // on IE8 this will be a document element
// for every other browser this will be a normal object // for every other browser this will be a normal object
let track = super(settings); const track = super(settings);
let selected = false; let selected = false;
if (browser.IS_IE8) { if (browser.IS_IE8) {
for (let prop in VideoTrack.prototype) { for (const prop in VideoTrack.prototype) {
if (prop !== 'constructor') { if (prop !== 'constructor') {
track[prop] = VideoTrack.prototype[prop]; track[prop] = VideoTrack.prototype[prop];
} }

View File

@ -25,7 +25,7 @@ export const IS_IPOD = (/iPod/i).test(USER_AGENT);
export const IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD; export const IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
export const IOS_VERSION = (function() { export const IOS_VERSION = (function() {
let match = USER_AGENT.match(/OS (\d+)_/i); const match = USER_AGENT.match(/OS (\d+)_/i);
if (match && match[1]) { if (match && match[1]) {
return match[1]; return match[1];
@ -36,16 +36,14 @@ export const IS_ANDROID = (/Android/i).test(USER_AGENT);
export const ANDROID_VERSION = (function() { export const ANDROID_VERSION = (function() {
// This matches Android Major.Minor.Patch versions // This matches Android Major.Minor.Patch versions
// ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
let match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i); const match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);
let major;
let minor;
if (!match) { if (!match) {
return null; return null;
} }
major = match[1] && parseFloat(match[1]); const major = match[1] && parseFloat(match[1]);
minor = match[2] && parseFloat(match[2]); const minor = match[2] && parseFloat(match[2]);
if (major && minor) { if (major && minor) {
return parseFloat(match[1] + '.' + match[2]); return parseFloat(match[1] + '.' + match[2]);

View File

@ -97,10 +97,10 @@ export function getEl(id) {
* @function createEl * @function createEl
*/ */
export function createEl(tagName = 'div', properties = {}, attributes = {}) { export function createEl(tagName = 'div', properties = {}, attributes = {}) {
let el = document.createElement(tagName); const el = document.createElement(tagName);
Object.getOwnPropertyNames(properties).forEach(function(propName) { Object.getOwnPropertyNames(properties).forEach(function(propName) {
let val = properties[propName]; const val = properties[propName];
// See #2176 // See #2176
// We originally were accepting both properties and attributes in the // We originally were accepting both properties and attributes in the
@ -220,7 +220,7 @@ export function hasElData(el) {
* @function removeElData * @function removeElData
*/ */
export function removeElData(el) { export function removeElData(el) {
let id = el[elIdAttr]; const id = el[elIdAttr];
if (!id) { if (!id) {
return; return;
@ -314,7 +314,7 @@ export function toggleElClass(element, classToToggle, predicate) {
// This CANNOT use `classList` internally because IE does not support the // This CANNOT use `classList` internally because IE does not support the
// second parameter to the `classList.toggle()` method! Which is fine because // second parameter to the `classList.toggle()` method! Which is fine because
// `classList` will be used by the add/remove functions. // `classList` will be used by the add/remove functions.
let has = hasElClass(element, classToToggle); const has = hasElClass(element, classToToggle);
if (typeof predicate === 'function') { if (typeof predicate === 'function') {
predicate = predicate(element, classToToggle); predicate = predicate(element, classToToggle);
@ -349,7 +349,7 @@ export function toggleElClass(element, classToToggle, predicate) {
*/ */
export function setElAttributes(el, attributes) { export function setElAttributes(el, attributes) {
Object.getOwnPropertyNames(attributes).forEach(function(attrName) { Object.getOwnPropertyNames(attributes).forEach(function(attrName) {
let attrValue = attributes[attrName]; const attrValue = attributes[attrName];
if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) { if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
el.removeAttribute(attrName); el.removeAttribute(attrName);
@ -371,25 +371,19 @@ export function setElAttributes(el, attributes) {
* @function getElAttributes * @function getElAttributes
*/ */
export function getElAttributes(tag) { export function getElAttributes(tag) {
let obj; const obj = {};
let knownBooleans;
let attrs;
let attrName;
let attrVal;
obj = {};
// known boolean attributes // known boolean attributes
// we can check for matching boolean properties, but older browsers // we can check for matching boolean properties, but older browsers
// won't know about HTML5 boolean attributes that we still read from // won't know about HTML5 boolean attributes that we still read from
knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ','; const knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ',';
if (tag && tag.attributes && tag.attributes.length > 0) { if (tag && tag.attributes && tag.attributes.length > 0) {
attrs = tag.attributes; const attrs = tag.attributes;
for (let i = attrs.length - 1; i >= 0; i--) { for (let i = attrs.length - 1; i >= 0; i--) {
attrName = attrs[i].name; const attrName = attrs[i].name;
attrVal = attrs[i].value; let attrVal = attrs[i].value;
// check for known booleans // check for known booleans
// the matching element property will return a value for typeof // the matching element property will return a value for typeof
@ -484,13 +478,13 @@ export function findElPosition(el) {
* @return {Object} This object will have x and y coordinates corresponding to the mouse position * @return {Object} This object will have x and y coordinates corresponding to the mouse position
*/ */
export function getPointerPosition(el, event) { export function getPointerPosition(el, event) {
let position = {}; const position = {};
let box = findElPosition(el); const box = findElPosition(el);
let boxW = el.offsetWidth; const boxW = el.offsetWidth;
let boxH = el.offsetHeight; const boxH = el.offsetHeight;
let boxY = box.top; const boxY = box.top;
let boxX = box.left; const boxX = box.left;
let pageY = event.pageY; let pageY = event.pageY;
let pageX = event.pageX; let pageX = event.pageX;

View File

@ -21,7 +21,7 @@ import document from 'global/document';
* @method _cleanUpEvents * @method _cleanUpEvents
*/ */
function _cleanUpEvents(elem, type) { function _cleanUpEvents(elem, type) {
let data = Dom.getElData(elem); const data = Dom.getElData(elem);
// Remove the events of a particular type if there are none left // Remove the events of a particular type if there are none left
if (data.handlers[type].length === 0) { if (data.handlers[type].length === 0) {
@ -91,7 +91,7 @@ export function fixEvent(event) {
// other expected methods like isPropagationStopped. Seems to be a problem // other expected methods like isPropagationStopped. Seems to be a problem
// with the Javascript Ninja code. So we're just overriding all events now. // with the Javascript Ninja code. So we're just overriding all events now.
if (!event || !event.isPropagationStopped) { if (!event || !event.isPropagationStopped) {
let old = event || window.event; const old = event || window.event;
event = {}; event = {};
// Clone the old object so that we can modify the values event = {}; // Clone the old object so that we can modify the values event = {};
@ -99,7 +99,7 @@ export function fixEvent(event) {
// Firefox returns false for event.hasOwnProperty('type') and other props // Firefox returns false for event.hasOwnProperty('type') and other props
// which makes copying more difficult. // which makes copying more difficult.
// TODO: Probably best to create a whitelist of event props // TODO: Probably best to create a whitelist of event props
for (let key in old) { for (const key in old) {
// Safari 6.0.3 warns you if you try to copy deprecated layerX/Y // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
// Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
// and webkitMovementX/Y // and webkitMovementX/Y
@ -161,9 +161,9 @@ export function fixEvent(event) {
event.isImmediatePropagationStopped = returnFalse; event.isImmediatePropagationStopped = returnFalse;
// Handle mouse position // Handle mouse position
if (event.clientX != null) { if (event.clientX !== null && event.clientX !== undefined) {
let doc = document.documentElement; const doc = document.documentElement;
let body = document.body; const body = document.body;
event.pageX = event.clientX + event.pageX = event.clientX +
(doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.scrollLeft || body && body.scrollLeft || 0) -
@ -178,7 +178,7 @@ export function fixEvent(event) {
// Fix button for mouse clicks: // Fix button for mouse clicks:
// 0 == left; 1 == middle; 2 == right // 0 == left; 1 == middle; 2 == right
if (event.button != null) { if (event.button !== null && event.button !== undefined) {
// The following is disabled because it does not pass videojs-standard // The following is disabled because it does not pass videojs-standard
// and... yikes. // and... yikes.
@ -210,7 +210,7 @@ export function on(elem, type, fn) {
return _handleMultipleEvents(on, elem, type, fn); return _handleMultipleEvents(on, elem, type, fn);
} }
let data = Dom.getElData(elem); const data = Dom.getElData(elem);
// We need a place to store all our handler data // We need a place to store all our handler data
if (!data.handlers) { if (!data.handlers) {
@ -238,11 +238,11 @@ export function on(elem, type, fn) {
event = fixEvent(event); event = fixEvent(event);
let handlers = data.handlers[event.type]; const handlers = data.handlers[event.type];
if (handlers) { if (handlers) {
// Copy handlers so if handlers are added/removed during the process it doesn't throw everything off. // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
let handlersCopy = handlers.slice(0); const handlersCopy = handlers.slice(0);
for (let m = 0, n = handlersCopy.length; m < n; m++) { for (let m = 0, n = handlersCopy.length; m < n; m++) {
if (event.isImmediatePropagationStopped()) { if (event.isImmediatePropagationStopped()) {
@ -278,7 +278,7 @@ export function off(elem, type, fn) {
return; return;
} }
let data = Dom.getElData(elem); const data = Dom.getElData(elem);
// If no events exist, nothing to unbind // If no events exist, nothing to unbind
if (!data.handlers) { if (!data.handlers) {
@ -290,20 +290,20 @@ export function off(elem, type, fn) {
} }
// Utility function // Utility function
let removeType = function(t) { const removeType = function(t) {
data.handlers[t] = []; data.handlers[t] = [];
_cleanUpEvents(elem, t); _cleanUpEvents(elem, t);
}; };
// Are we removing all bound events? // Are we removing all bound events?
if (!type) { if (!type) {
for (let t in data.handlers) { for (const t in data.handlers) {
removeType(t); removeType(t);
} }
return; return;
} }
let handlers = data.handlers[type]; const handlers = data.handlers[type];
// If no handlers exist, nothing to unbind // If no handlers exist, nothing to unbind
if (!handlers) { if (!handlers) {
@ -341,8 +341,8 @@ export function trigger(elem, event, hash) {
// Fetches element data and a reference to the parent (for bubbling). // Fetches element data and a reference to the parent (for bubbling).
// Don't want to add a data object to cache for every parent, // Don't want to add a data object to cache for every parent,
// so checking hasElData first. // so checking hasElData first.
let elemData = (Dom.hasElData(elem)) ? Dom.getElData(elem) : {}; const elemData = (Dom.hasElData(elem)) ? Dom.getElData(elem) : {};
let parent = elem.parentNode || elem.ownerDocument; const parent = elem.parentNode || elem.ownerDocument;
// type = event.type || event, // type = event.type || event,
// handler; // handler;
@ -365,7 +365,7 @@ export function trigger(elem, event, hash) {
// If at the top of the DOM, triggers the default action unless disabled. // If at the top of the DOM, triggers the default action unless disabled.
} else if (!parent && !event.defaultPrevented) { } else if (!parent && !event.defaultPrevented) {
let targetData = Dom.getElData(event.target); const targetData = Dom.getElData(event.target);
// Checks if the target has a default action for this event. // Checks if the target has a default action for this event.
if (event.target[event.type]) { if (event.target[event.type]) {
@ -396,7 +396,7 @@ export function one(elem, type, fn) {
if (Array.isArray(type)) { if (Array.isArray(type)) {
return _handleMultipleEvents(one, elem, type, fn); return _handleMultipleEvents(one, elem, type, fn);
} }
let func = function() { const func = function() {
off(elem, type, func); off(elem, type, func);
fn.apply(this, arguments); fn.apply(this, arguments);
}; };

View File

@ -21,7 +21,7 @@ export const bind = function(context, fn, uid) {
} }
// Create the new function that changes the context // Create the new function that changes the context
let ret = function() { const ret = function() {
return fn.apply(context, arguments); return fn.apply(context, arguments);
}; };

View File

@ -10,14 +10,12 @@ function isPlain(obj) {
obj.constructor === Object; obj.constructor === Object;
} }
let mergeOptions;
/** /**
* Merge customizer. video.js simply overwrites non-simple objects * Merge customizer. video.js simply overwrites non-simple objects
* (like arrays) instead of attempting to overlay them. * (like arrays) instead of attempting to overlay them.
* @see https://lodash.com/docs#merge * @see https://lodash.com/docs#merge
*/ */
const customizer = function(destination, source) { function customizer(destination, source) {
// If we're not working with a plain object, copy the value as is // If we're not working with a plain object, copy the value as is
// If source is an array, for instance, it will replace destination // If source is an array, for instance, it will replace destination
if (!isPlain(source)) { if (!isPlain(source)) {
@ -32,7 +30,7 @@ const customizer = function(destination, source) {
if (!isPlain(destination)) { if (!isPlain(destination)) {
return mergeOptions(source); return mergeOptions(source);
} }
}; }
/** /**
* Merge one or more options objects, recursively merging **only** * Merge one or more options objects, recursively merging **only**
@ -43,10 +41,10 @@ const customizer = function(destination, source) {
* provided objects * provided objects
* @function mergeOptions * @function mergeOptions
*/ */
mergeOptions = function() { export default function mergeOptions() {
// contruct the call dynamically to handle the variable number of // contruct the call dynamically to handle the variable number of
// objects to merge // objects to merge
let args = Array.prototype.slice.call(arguments); const args = Array.prototype.slice.call(arguments);
// unshift an empty object into the front of the call as the target // unshift an empty object into the front of the call as the target
// of the merge // of the merge
@ -59,6 +57,4 @@ mergeOptions = function() {
// return the mutated result object // return the mutated result object
return args[0]; return args[0];
}; }
export default mergeOptions;

View File

@ -1,14 +1,14 @@
import document from 'global/document'; import document from 'global/document';
export let createStyleElement = function(className) { export const createStyleElement = function(className) {
let style = document.createElement('style'); const style = document.createElement('style');
style.className = className; style.className = className;
return style; return style;
}; };
export let setTextContent = function(el, content) { export const setTextContent = function(el, content) {
if (el.styleSheet) { if (el.styleSheet) {
el.styleSheet.cssText = content; el.styleSheet.cssText = content;
} else { } else {

View File

@ -22,7 +22,7 @@ export const parseUrl = function(url) {
// IE8 (and 9?) Fix // IE8 (and 9?) Fix
// ie8 doesn't parse the URL correctly until the anchor is actually // ie8 doesn't parse the URL correctly until the anchor is actually
// added to the body, and an innerHTML is needed to trigger the parsing // added to the body, and an innerHTML is needed to trigger the parsing
let addToBody = (a.host === '' && a.protocol !== 'file:'); const addToBody = (a.host === '' && a.protocol !== 'file:');
let div; let div;
if (addToBody) { if (addToBody) {
@ -37,7 +37,7 @@ export const parseUrl = function(url) {
// Copy the specific URL properties to a new object // Copy the specific URL properties to a new object
// This is also needed for IE8 because the anchor loses its // This is also needed for IE8 because the anchor loses its
// properties when it's removed from the dom // properties when it's removed from the dom
let details = {}; const details = {};
for (let i = 0; i < props.length; i++) { for (let i = 0; i < props.length; i++) {
details[props[i]] = a[props[i]]; details[props[i]] = a[props[i]];
@ -73,7 +73,7 @@ export const getAbsoluteURL = function(url) {
// Check if absolute URL // Check if absolute URL
if (!url.match(/^https?:\/\//)) { if (!url.match(/^https?:\/\//)) {
// Convert to absolute URL. Flash hosted off-site needs an absolute URL. // Convert to absolute URL. Flash hosted off-site needs an absolute URL.
let div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = `<a href="${url}">x</a>`; div.innerHTML = `<a href="${url}">x</a>`;
url = div.firstChild.href; url = div.firstChild.href;
@ -91,8 +91,8 @@ export const getAbsoluteURL = function(url) {
*/ */
export const getFileExtension = function(path) { export const getFileExtension = function(path) {
if (typeof path === 'string') { if (typeof path === 'string') {
let splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i; const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
let pathParts = splitPathRe.exec(path); const pathParts = splitPathRe.exec(path);
if (pathParts) { if (pathParts) {
return pathParts.pop().toLowerCase(); return pathParts.pop().toLowerCase();
@ -110,15 +110,15 @@ export const getFileExtension = function(path) {
* @method isCrossOrigin * @method isCrossOrigin
*/ */
export const isCrossOrigin = function(url) { export const isCrossOrigin = function(url) {
let winLoc = window.location; const winLoc = window.location;
let urlInfo = parseUrl(url); const urlInfo = parseUrl(url);
// IE8 protocol relative urls will return ':' for protocol // IE8 protocol relative urls will return ':' for protocol
let srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol; const srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;
// Check if url is for another domain/origin // Check if url is for another domain/origin
// IE8 doesn't know location.origin, so we won't rely on it here // IE8 doesn't know location.origin, so we won't rely on it here
let crossOrigin = (srcProtocol + urlInfo.host) !== (winLoc.protocol + winLoc.host); const crossOrigin = (srcProtocol + urlInfo.host) !== (winLoc.protocol + winLoc.host);
return crossOrigin; return crossOrigin;
}; };

View File

@ -106,7 +106,7 @@ if (window.VIDEOJS_NO_DYNAMIC_STYLE !== true) {
if (!style) { if (!style) {
style = stylesheet.createStyleElement('vjs-styles-defaults'); style = stylesheet.createStyleElement('vjs-styles-defaults');
let head = Dom.$('head'); const head = Dom.$('head');
head.insertBefore(style, head.firstChild); head.insertBefore(style, head.firstChild);
stylesheet.setTextContent(style, ` stylesheet.setTextContent(style, `