diff options
author | Sam Potts <sam@potts.es> | 2018-07-31 09:08:08 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-31 09:08:08 +1000 |
commit | e3dfd160965d09fa3aee517f0a7aefe17c9dd69b (patch) | |
tree | 1b86ac5153429ccff21a6a428be4dae9618a3d12 /src/js/controls.js | |
parent | 2679c5898edd534d19b5b2f68d895641c3e3fb1a (diff) | |
parent | c230ccce866711e977af44ca955e56a0db43d0a4 (diff) | |
download | plyr-e3dfd160965d09fa3aee517f0a7aefe17c9dd69b.tar.lz plyr-e3dfd160965d09fa3aee517f0a7aefe17c9dd69b.tar.xz plyr-e3dfd160965d09fa3aee517f0a7aefe17c9dd69b.zip |
Merge pull request #1139 from friday/controls-input
Controls input fixes
Diffstat (limited to 'src/js/controls.js')
-rw-r--r-- | src/js/controls.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/js/controls.js b/src/js/controls.js index e95cfc86..c01e3584 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -1117,11 +1117,6 @@ const controls = { // Build the default HTML // TODO: Set order based on order in the config.controls array? create(data) { - // Do nothing if we want no controls - if (is.empty(this.config.controls)) { - return null; - } - // Create the container const container = createElement('div', getAttributesFromSelector(this.config.selectors.controls.wrapper)); @@ -1401,13 +1396,19 @@ const controls = { }; let update = true; - if (is.string(this.config.controls) || is.element(this.config.controls)) { - // String or HTMLElement passed as the option + // If function, run it and use output + if (is.function(this.config.controls)) { + this.config.controls = this.config.controls.call(this.props); + } + + // Convert falsy controls to empty array (primarily for empty strings) + if (!this.config.controls) { + this.config.controls = []; + } + + if (is.element(this.config.controls) || is.string(this.config.controls)) { + // HTMLElement or Non-empty string passed as the option container = this.config.controls; - } else if (is.function(this.config.controls)) { - // A custom function to build controls - // The function can return a HTMLElement or String - container = this.config.controls.call(this, props); } else { // Create controls container = controls.create.call(this, { |