diff options
author | Marios Tasos <marios.tasos@gmail.com> | 2017-03-15 17:18:34 +0200 |
---|---|---|
committer | Marios Tasos <marios.tasos@gmail.com> | 2017-03-15 17:18:34 +0200 |
commit | 9919d8078249c95b7c2c5a186f2dd783e7c96611 (patch) | |
tree | f0c6014591d961f07c48bd96fa15547ad5f2ce56 /src | |
parent | 8464ffe6ad3b72243385293a1e8a2e0bf73c8132 (diff) | |
download | plyr-9919d8078249c95b7c2c5a186f2dd783e7c96611.tar.lz plyr-9919d8078249c95b7c2c5a186f2dd783e7c96611.tar.xz plyr-9919d8078249c95b7c2c5a186f2dd783e7c96611.zip |
check if captions exists
Diffstat (limited to 'src')
-rw-r--r-- | src/js/plyr.js | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 117eb70d..2b664fc0 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1517,27 +1517,30 @@ function setCaption(caption) { var captions = getElement(config.selectors.captions); var content = document.createElement('span'); + if(captions) { - // Empty the container - captions.innerHTML = ''; + // Empty the container + captions.innerHTML = ''; - // Default to empty - if (is.undefined(caption)) { + // Default to empty + if (is.undefined(caption)) { caption = ''; - } + } - // Set the span content - if (is.string(caption)) { + // Set the span content + if (is.string(caption)) { content.innerHTML = caption.trim(); - } else { + } else { content.appendChild(caption); - } + } + + // Set new caption text + captions.appendChild(content); - // Set new caption text - captions.appendChild(content); + // Force redraw (for Safari) + var redraw = captions.offsetHeight; + } - // Force redraw (for Safari) - var redraw = captions.offsetHeight; } // Captions functions |