Skip to content

Commit

Permalink
fix: Respect controls: false, allows to create player without controls
Browse files Browse the repository at this point in the history
  • Loading branch information
komachi committed Aug 6, 2020
1 parent 62f2fe4 commit 027063d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/create-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const createIframeEmbed = (params) => {
* The DOM element that will ultimately be passed to the `bc()` function.
*/
const createInPageEmbed = (params) => {
const {embedOptions} = params;
const {embedOptions, options} = params;

// We DO NOT include the data-account, data-player, or data-embed attributes
// here because we will be manually initializing the player.
Expand Down Expand Up @@ -107,7 +107,9 @@ const createInPageEmbed = (params) => {
el.setAttribute(paramsToAttrs[key], value);
});

el.setAttribute('controls', 'controls');
if (!options || options.controls !== false) {
el.setAttribute('controls', 'controls');
}
el.classList.add('video-js');

return el;
Expand Down
12 changes: 12 additions & 0 deletions test/create-embed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ QUnit.module('create-embed', function(hooks) {
assert.notOk(embed.hasAttribute('data-embed'), 'we never include data-embed because we want to init players ourselves');
});

QUnit.test('creates player without controls', function(assert) {
const embed = createEmbed({
refNode: this.fixture,
refNodeInsert: 'append',
options: {
controls: false
}
});

assert.notOk(embed.hasAttribute('controls'), 'doesn\'t have controls attribute');
});

QUnit.test('populates certain attributes from params', function(assert) {
const embed = createEmbed({
refNode: this.fixture,
Expand Down

0 comments on commit 027063d

Please sign in to comment.