Skip to content

Conversation

@jdufresne
Copy link
Contributor

Description

Before accessing window.CSS, the code now checks whether it exists. If it is undefined, the feature-detection path returns false, indicating no support.

This ensures compatibility with jsdom, commonly used in testing frameworks like Jest. Since jsdom does not implement window.CSS, calling it previously triggered errors such as:

VIDEOJS: ERROR: TypeError: Cannot read properties of undefined (reading 'supports')

For more context, see the upstream issue: jsdom/jsdom#3991

Specific Changes proposed

Before accessing window.CSS, the code now checks whether it exists. If it is undefined, the feature-detection path returns false, indicating no support.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
    • Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab)
    • Has no changes to JSDoc which cause npm run docs:api to error
  • Reviewed by Two Core Contributors

Before accessing `window.CSS`, the code now checks whether it exists. If
it is undefined, the feature-detection path returns `false`, indicating
no support.

This ensures compatibility with jsdom, commonly used in testing
frameworks like Jest. Since jsdom does not implement `window.CSS`,
calling it previously triggered errors such as:

```
VIDEOJS: ERROR: TypeError: Cannot read properties of undefined (reading 'supports')
```

For more context, see the upstream issue: jsdom/jsdom#3991
@welcome
Copy link

welcome bot commented Dec 7, 2025

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@jdufresne jdufresne changed the title Allow use in jsdom environments without window.CSS fix: Allow use in jsdom environments without window.CSS Dec 7, 2025
@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.32%. Comparing base (d203eab) to head (a56934c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9137      +/-   ##
==========================================
+ Coverage   84.31%   84.32%   +0.01%     
==========================================
  Files         120      120              
  Lines        8154     8154              
  Branches     1964     1964              
==========================================
+ Hits         6875     6876       +1     
+ Misses       1279     1278       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants