Skip to content

fix(dom): guard against null document.head in copyStyleSheetsToWindow#9203

Open
okxint wants to merge 1 commit into
videojs:mainfrom
okxint:fix/copy-stylesheets-null-head
Open

fix(dom): guard against null document.head in copyStyleSheetsToWindow#9203
okxint wants to merge 1 commit into
videojs:mainfrom
okxint:fix/copy-stylesheets-null-head

Conversation

@okxint

@okxint okxint commented Jun 16, 2026

Copy link
Copy Markdown

If win.document.head is null, the appendChild call throws. Resolved the insertion target once before the loop (head || documentElement) and bail early if neither is available.

Closes #9186

When the target window (e.g. a Picture-in-Picture window) is closing or
in an invalid state, win.document.head can be null. Appending to a null
node throws an uncaught TypeError.

Resolve the insertion target once before iterating: prefer document.head,
fall back to documentElement, and bail out early if neither is available.

Fixes videojs#9186
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.

Bug: copyStyleSheetsToWindow() may fail if win.document.head is null

1 participant