diff options
Diffstat (limited to 'themes/blowfish/assets/lib/lite-youtube-embed')
-rw-r--r-- | themes/blowfish/assets/lib/lite-youtube-embed/lite-yt-embed.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/themes/blowfish/assets/lib/lite-youtube-embed/lite-yt-embed.js b/themes/blowfish/assets/lib/lite-youtube-embed/lite-yt-embed.js index 49db80e..591954b 100644 --- a/themes/blowfish/assets/lib/lite-youtube-embed/lite-yt-embed.js +++ b/themes/blowfish/assets/lib/lite-youtube-embed/lite-yt-embed.js @@ -46,10 +46,23 @@ class LiteYTEmbed extends HTMLElement { this.addNoscriptIframe(); - playBtnEl.removeAttribute('href'); + // for the PE pattern, change anchor's semantics to button + if(playBtnEl.nodeName === 'A'){ + playBtnEl.removeAttribute('href'); + playBtnEl.setAttribute('tabindex', '0'); + playBtnEl.setAttribute('role', 'button'); + // fake button needs keyboard help + playBtnEl.addEventListener('keydown', e => { + if( e.key === 'Enter' || e.key === ' ' ){ + e.preventDefault(); + this.activate(); + } + }); + } // On hover (or tap), warm up the TCP connections we're (likely) about to use. this.addEventListener('pointerover', LiteYTEmbed.warmConnections, {once: true}); + this.addEventListener('focusin', LiteYTEmbed.warmConnections, {once: true}); // Once the user clicks, add the real iframe and drop our play button // TODO: In the future we could be like amp-youtube and silently swap in the iframe during idle time |