Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(text-cta): prevent order of operations issues #11911

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions packages/web-components/src/component-mixins/cta/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,49 +132,51 @@ const VideoCTAMixin = <T extends Constructor<HTMLElement>>(Base: T) => {
// Declaring this mixin as it extends `LitElement` seems to cause a TS error
// @ts-ignore
super.updated(changedProperties);
const { ctaType, videoName, videoDescription, href, videoDuration } =
this;
const { eventRequestVideoData } = this
.constructor as typeof VideoCTAMixinImpl;
if (changedProperties.has('ctaType') && ctaType === CTA_TYPE.VIDEO) {
if (typeof videoDuration === 'undefined') {
customElements.whenDefined(`${ddsPrefix}-video-cta-container`).then((response) => {
const { ctaType, videoName, videoDescription, href, videoDuration } =
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: {
href,
videoName,
videoDescription,
href,
},
})
);
}
}

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();
}
if (ctaType === CTA_TYPE.VIDEO && this.offsetWidth > 0) {
m4olivei marked this conversation as resolved.
Show resolved Hide resolved
this._updateVideoThumbnailUrl();
}
});
}

/**
Expand Down
Loading