summaryrefslogtreecommitdiff
path: root/themes/blowfish/assets/lib/lite-youtube-embed
diff options
context:
space:
mode:
authorChristoph Cullmann <christoph@cullmann.io>2024-08-28 22:54:34 +0200
committerChristoph Cullmann <christoph@cullmann.io>2024-08-28 22:54:34 +0200
commit8f3d03b1888fed23e6aa07d6077045e673357481 (patch)
treea914b8f43b8486380ccc1c35721b28da2ff7986a /themes/blowfish/assets/lib/lite-youtube-embed
parent8db6bd0e555dca050d7d885582100c5ca5ba3aa2 (diff)
sync themeHEADmaster
Diffstat (limited to 'themes/blowfish/assets/lib/lite-youtube-embed')
-rw-r--r--themes/blowfish/assets/lib/lite-youtube-embed/lite-yt-embed.js15
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