Skip to content

fix(slider): add null check for this.bar.el_ before accessing ownerDocument#9191

Open
xxiaoxiong wants to merge 1 commit into
videojs:mainfrom
xxiaoxiong:fix/slider-bar-null-check-9184
Open

fix(slider): add null check for this.bar.el_ before accessing ownerDocument#9191
xxiaoxiong wants to merge 1 commit into
videojs:mainfrom
xxiaoxiong:fix/slider-bar-null-check-9184

Conversation

@xxiaoxiong
Copy link
Copy Markdown

Fixes #9184

Why

Both disable() and handleMouseDown() access this.bar.el_.ownerDocument without checking if this.bar or this.bar.el_ exists. If a subclass or custom slider is created without a proper bar child component, this.bar would be undefined, causing a TypeError.

Changes

  • disable(): early return if this.bar or this.bar.el_ is null/undefined
  • handleMouseDown(): early return if this.bar or this.bar.el_ is null/undefined

Testing

No longer throws when bar is missing or has no element. Consistent with the existing null check in update() at line 245.

Surface area

  • Slider / UI component
  • Bug fix

…cument

Fixes videojs#9184

## Why
Both disable() and handleMouseDown() access this.bar.el_.ownerDocument
without checking if this.bar or this.bar.el_ exists. If a subclass or
custom slider is created without a proper bar child component,
this.bar would be undefined, causing a TypeError.

## Changes
- disable(): early return if this.bar or this.bar.el_ is null/undefined
- handleMouseDown(): early return if this.bar or this.bar.el_ is null/undefined

## Testing
No longer throws when bar is missing or has no element.
Consistent with existing this.bar check in update() (line 245).
@welcome
Copy link
Copy Markdown

welcome Bot commented May 24, 2026

💖 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.

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: slider.js disable() and handleMouseDown() access this.bar.el_ without null check

1 participant