From 027063d0f2133d91943aec522fe91e2f69f61118 Mon Sep 17 00:00:00 2001 From: Anton Nesterov Date: Thu, 6 Aug 2020 16:47:29 +0000 Subject: [PATCH] fix: Respect controls: false, allows to create player without controls --- src/create-embed.js | 6 ++++-- test/create-embed.test.js | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/create-embed.js b/src/create-embed.js index a023d55..eb55cf7 100644 --- a/src/create-embed.js +++ b/src/create-embed.js @@ -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. @@ -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; diff --git a/test/create-embed.test.js b/test/create-embed.test.js index a4835a7..832af10 100644 --- a/test/create-embed.test.js +++ b/test/create-embed.test.js @@ -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,