Skip to content

Commit

Permalink
feat(cors): allow both crossOrigin and crossorigin method and options (
Browse files Browse the repository at this point in the history
…#6571)

Fixes a bug with the setter and aliases crossorigin to crossOrigin.

This is a followup from #6533.
  • Loading branch information
gkatsev committed Apr 6, 2020
1 parent ea20edc commit f711ddc
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/js/player.js
Expand Up @@ -744,7 +744,8 @@ class Player extends Component {
this.fill(this.options_.fill);
this.fluid(this.options_.fluid);
this.aspectRatio(this.options_.aspectRatio);
this.crossOrigin(this.options_.crossOrigin);
// support both crossOrigin and crossorigin to reduce confusion and issues around the name
this.crossOrigin(this.options_.crossOrigin || this.options_.crossorigin);

// Hide any links within the video/audio tag,
// because IE doesn't hide them completely from screen readers.
Expand Down Expand Up @@ -803,7 +804,7 @@ class Player extends Component {
return this.techGet_('crossOrigin');
}

if (value !== 'anonymous' || value !== 'use-credentials') {
if (value !== 'anonymous' && value !== 'use-credentials') {
log.warn(`crossOrigin must be "anonymous" or "use-credentials", given "${value}"`);
return;
}
Expand Down Expand Up @@ -4778,6 +4779,23 @@ TRACK_TYPES.names.forEach(function(name) {
};
});

/**
* Get or set the `Player`'s crossorigin option. For the HTML5 player, this
* sets the `crossOrigin` property on the `<video>` tag to control the CORS
* behavior.
*
* @see [Video Element Attributes]{@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-crossorigin}
*
* @param {string} [value]
* The value to set the `Player`'s crossorigin to. If an argument is
* given, must be one of `anonymous` or `use-credentials`.
*
* @return {string|undefined}
* - The current crossorigin value of the `Player` when getting.
* - undefined when setting
*/
Player.prototype.crossorigin = Player.prototype.crossOrigin;

/**
* Global enumeration of players.
*
Expand Down

0 comments on commit f711ddc

Please sign in to comment.