Skip to content

Commit

Permalink
@dmlap Check a component is a function before new-ing. closes #2814
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlap authored and gkatsev committed Nov 16, 2015
1 parent 0e1c424 commit 3852663
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CHANGELOG
=========

## HEAD (Unreleased)
_(none)_
* @dmlap Check a component is a function before new-ing ([view](https://github.com/videojs/video.js/pull/2814))

--------------------

Expand Down
8 changes: 8 additions & 0 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ class Component {
throw new Error(`Component ${componentClassName} does not exist`);
}

// data stored directly on the videojs object may be
// misidentified as a component to retain
// backwards-compatibility with 4.x. check to make sure the
// component class can be instantiated.
if (typeof ComponentClass !== 'function') {
return null;
}

component = new ComponentClass(this.player_ || this, options);

// child is a component instance
Expand Down

0 comments on commit 3852663

Please sign in to comment.