MCPcopy
hub / github.com/aframevr/aframe / fixVideoAttributes

Function fixVideoAttributes

src/systems/material.js:252–266  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

250 * @returns {Element} Video element with the correct properties updated.
251 */
252function 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}

Callers 1

material.jsFile · 0.85

Calls 3

removeAttributeMethod · 0.80
getAttributeMethod · 0.45
setAttributeMethod · 0.45

Tested by

no test coverage detected