* Fixes a video element's attributes to prevent developers from accidentally passing the * wrong attribute values to commonly misused video attributes. * * does not treat `autoplay`, `controls`, `crossorigin`, `loop`, and `preload` as * as booleans. Existence of those attributes will mea
(videoEl)
| 250 | * @returns {Element} Video element with the correct properties updated. |
| 251 | */ |
| 252 | function fixVideoAttributes (videoEl) { |
| 253 | videoEl.autoplay = videoEl.hasAttribute('autoplay') && videoEl.getAttribute('autoplay') !== 'false'; |
| 254 | videoEl.controls = videoEl.hasAttribute('controls') && videoEl.getAttribute('controls') !== 'false'; |
| 255 | if (videoEl.getAttribute('loop') === 'false') { |
| 256 | videoEl.removeAttribute('loop'); |
| 257 | } |
| 258 | if (videoEl.getAttribute('preload') === 'false') { |
| 259 | videoEl.preload = 'none'; |
| 260 | } |
| 261 | videoEl.crossOrigin = videoEl.crossOrigin || 'anonymous'; |
| 262 | // To support inline videos in iOS webviews. |
| 263 | videoEl.setAttribute('playsinline', ''); |
| 264 | videoEl.setAttribute('webkit-playsinline', ''); |
| 265 | return videoEl; |
| 266 | } |
no test coverage detected