diff --git a/packages/web-components/src/component-mixins/cta/video.ts b/packages/web-components/src/component-mixins/cta/video.ts index 5ca7380c435..2a6b3d0475f 100644 --- a/packages/web-components/src/component-mixins/cta/video.ts +++ b/packages/web-components/src/component-mixins/cta/video.ts @@ -136,42 +136,46 @@ const VideoCTAMixin = >(Base: T) => { this; const { eventRequestVideoData } = this .constructor as typeof VideoCTAMixinImpl; - if (changedProperties.has('ctaType') && ctaType === CTA_TYPE.VIDEO) { - if (typeof videoDuration === 'undefined') { - this.dispatchEvent( - new CustomEvent(eventRequestVideoData, { - bubbles: true, - cancelable: true, - composed: true, - detail: { - href, - videoName, - videoDescription, - }, - }) - ); - } - } - if ( - (changedProperties.has('videoName') && - (videoName === null || videoName === 'null')) || - changedProperties.has('videoDescription') - ) { - this.dispatchEvent( - new CustomEvent(eventRequestVideoData, { - bubbles: true, - cancelable: true, - composed: true, - detail: { - videoName, - videoDescription, - href, - }, - }) - ); - } + customElements + .whenDefined(`${ddsPrefix}-video-cta-container`) + .then(() => { + if (changedProperties.has('ctaType') && ctaType === CTA_TYPE.VIDEO) { + if (typeof videoDuration === 'undefined') { + this.dispatchEvent( + new CustomEvent(eventRequestVideoData, { + bubbles: true, + cancelable: true, + composed: true, + detail: { + href, + videoName, + videoDescription, + }, + }) + ); + } + } + if ( + (changedProperties.has('videoName') && + (videoName === null || videoName === 'null')) || + changedProperties.has('videoDescription') + ) { + this.dispatchEvent( + new CustomEvent(eventRequestVideoData, { + bubbles: true, + cancelable: true, + composed: true, + detail: { + videoName, + videoDescription, + href, + }, + }) + ); + } + }); if (ctaType === CTA_TYPE.VIDEO && this.offsetWidth > 0) { this._updateVideoThumbnailUrl(); }