Skip to content

Fix operator precedence bug dropping custom className on iframe embeds#1846

Open
jphilung wants to merge 1 commit into
vidstack:mainfrom
jphilung:main
Open

Fix operator precedence bug dropping custom className on iframe embeds#1846
jphilung wants to merge 1 commit into
vidstack:mainfrom
jphilung:main

Conversation

@jphilung

@jphilung jphilung commented Jul 9, 2026

Copy link
Copy Markdown

Problem

The className concatenation for the iframe embed had a missing set of parentheses, causing a subtle operator precedence bug:

(iframeProps?.className ? `${iframeProps.className} ` : '') + isYouTubeEmbed
  ? 'vds-youtube'
  : 'vds-vimeo',

Since + has higher precedence than the ternary ?:, this actually evaluates as:

((iframeProps?.className ? `${iframeProps.className} ` : '') + isYouTubeEmbed)
  ? 'vds-youtube'
  : 'vds-vimeo'

Two consequences:

  1. Any iframeProps.className passed in gets concatenated with the string-coerced isYouTubeEmbed value into a throwaway string, then discarded — the custom class never makes it onto the element.
  2. That concatenated string is always non-empty, so it's always truthy — meaning the ternary always resolves to 'vds-youtube', regardless of the actual value of isYouTubeEmbed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant