feat: Add configurable "parent" prop to twitch-video#226
feat: Add configurable "parent" prop to twitch-video#226ronalduQualabs wants to merge 1 commit intomuxinc:mainfrom
Conversation
|
@ronalduQualabs is attempting to deploy a commit to the Mux Team on Vercel. A member of the Team first needs to authorize it. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b6f1f68. Configure here.
| set parent(value) { | ||
| this.#parent = value; | ||
| this.load(); | ||
| } |
There was a problem hiding this comment.
Setter lacks guard, can permanently stall loadComplete
Medium Severity
The parent setter unconditionally calls load() without checking whether the value actually changed. Unlike attributeChangedCallback which guards with if (oldValue === newValue) return, repeated sets of the same parent value (common in framework re-renders) cause load() to replace loadComplete with a new pending PublicPromise. Because the iframe URL hasn't changed, the iframe isn't recreated, the Twitch player never fires a new ready event, and loadComplete never resolves. This silently breaks all subsequent currentTime, volume, and muted sets, which depend on loadComplete.then(...).
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b6f1f68. Configure here.
| function serialize(props, parent) { | ||
| const params = new URLSearchParams(filterParams(props)); | ||
| [].concat(parent).filter(Boolean).forEach(d => params.append('parent', d)); | ||
| return String(params); |
There was a problem hiding this comment.
If you pass parent inside props ( props.parent = parent) before calling serialize, this logic is implicitly done in filterParams
| ...props.config, | ||
| }; | ||
|
|
||
| const parent = [...new Set([].concat(props.parent ?? []).concat(globalThis.location?.hostname ?? []))].filter(Boolean); |
There was a problem hiding this comment.
| const parent = [...new Set([].concat(props.parent ?? []).concat(globalThis.location?.hostname ?? []))].filter(Boolean); | |
| const parent = [...new Set([].concat(props.parent ?? []).concat(globalThis.location?.hostname ?? []))].filter(Boolean); | |
| props.parent = parent; |
Regarding previous comment
There was a problem hiding this comment.
And rolling back to
return ${EMBED_BASE}/?video=v${videoId}&${serialize(params)};
| set parent(value) { | ||
| this.#parent = value; | ||
| this.load(); | ||
| } |
There was a problem hiding this comment.
I think Cursor wants this which makes sense to me
| set parent(value) { | |
| this.#parent = value; | |
| this.load(); | |
| } | |
| set parent(value) { | |
| if (value === this.#parent) return; | |
| this.#parent = value; | |
| this.load(); | |
| } |


Fixes #225
Adds a
parentprop/attribute to<twitch-video-element>that accepts a string or array of domain strings, allowing embeds hosted across multiple domains to pass all required parent values to the Twitch iframe URL.globalThis.location?.hostnameis still included automatically, so existing usage is unaffected.Note
Medium Risk
Changes how the Twitch iframe URL is constructed by appending one or more
parentquery params, which can affect embed loading if domains are misconfigured. Scope is small and mostly additive, but it touches the core URL serialization path used on every load.Overview
Adds a configurable
parentprop/attribute totwitch-video-element, allowing callers to provide one or more allowed parent domains for Twitch embeds.Updates iframe URL generation to always include the current
location.hostnameplus any providedparentvalues (deduped) by appending multipleparent=query params, and triggers a reload whenparentis set. Type definitions are updated to exposeparent: string | string[] | null.Reviewed by Cursor Bugbot for commit b6f1f68. Bugbot is set up for automated code reviews on this repo. Configure here.