Skip to content
Open
Changes from all 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
12 changes: 12 additions & 0 deletions packages/mux-video/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,14 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo
if (this.#loadRequested) return;
await (this.#loadRequested = Promise.resolve());
this.#loadRequested = null;
// Defer load() until the element is connected to the document. A parent
// custom element (e.g. <mux-player>) propagates `metadata-*` attributes via
// its own connectedCallback, which fires before this element's
// connectedCallback in tree order. Without this guard, an `await` between
// setAttribute and appendChild lets load() — and thus the first Mux Data
// beacon — fire with empty metadata. The connectedCallback re-invokes
// #requestLoad() once we're connected.
if (!this.isConnected) return;
Comment thread
cursor[bot] marked this conversation as resolved.
this.load();
}

Expand Down Expand Up @@ -951,6 +959,10 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo
break;
case Attributes.DISABLE_TRACKING: {
if (newValue == null || newValue !== oldValue) {
// Skip unload/reload when disconnected: #requestLoad() bails on !isConnected,
// so the .then() would fire without a corresponding load(). connectedCallback
// will trigger #requestLoad() with the updated tracking setting when connected.
if (!this.isConnected) break;
const currentTime = this.currentTime;
const paused = this.paused;
this.unload();
Expand Down
Loading