From fb228f187531146b3aebde6f11e8f52689259442 Mon Sep 17 00:00:00 2001 From: Okan Sahin <39759830+mokimo@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:37:01 +0200 Subject: [PATCH] Revert "MWPW-156749: Fix video CLS " (#2899) (#2900) Revert "MWPW-156749: Fix video CLS (#2849)" This reverts commit d4134c85979cfbb88a01d331f8d946eb67251de5. --- libs/blocks/adobetv/adobetv.js | 34 +++++++++++---- libs/blocks/figure/figure.js | 36 ++++++++-------- libs/blocks/video/video.js | 43 +++++++++++++------ libs/utils/decorate.js | 29 +++---------- test/blocks/adobetv/adobetv.test.js | 11 +++++ test/blocks/adobetv/mocks/body.html | 2 +- test/blocks/figure/figure.test.js | 5 +-- test/blocks/figure/mocks/body.html | 16 +++++++- test/blocks/marquee/marquee.test.js | 21 ++-------- test/blocks/video/mocks/body.html | 2 +- test/blocks/video/video.test.js | 64 ++++++++++++++++------------- 11 files changed, 150 insertions(+), 113 deletions(-) diff --git a/libs/blocks/adobetv/adobetv.js b/libs/blocks/adobetv/adobetv.js index 85928d1c03..31cfc7a368 100644 --- a/libs/blocks/adobetv/adobetv.js +++ b/libs/blocks/adobetv/adobetv.js @@ -1,15 +1,22 @@ -import { decorateAnchorVideo } from '../../utils/decorate.js'; +import { createIntersectionObserver } from '../../utils/utils.js'; +import { applyHoverPlay, getVideoAttrs } from '../../utils/decorate.js'; -export default function init(a) { - a.classList.add('hide-video'); +const ROOT_MARGIN = 1000; + +const loadAdobeTv = (a) => { const bgBlocks = ['aside', 'marquee', 'hero-marquee']; if (a.href.includes('.mp4') && bgBlocks.some((b) => a.closest(`.${b}`))) { a.classList.add('hide'); + const { href, hash, dataset } = a; + const attrs = getVideoAttrs(hash || 'autoplay', dataset); + const video = ``; if (!a.parentNode) return; - decorateAnchorVideo({ - src: a.href, - anchorTag: a, - }); + a.insertAdjacentHTML('afterend', video); + const videoElem = document.body.querySelector(`source[src="${href}"]`)?.parentElement; + applyHoverPlay(videoElem); + a.remove(); } else { const embed = `