Skip to content

Commit

Permalink
fix: deprecate the extend() function (#7944)
Browse files Browse the repository at this point in the history
This function will be removed in Video.js 8.0
  • Loading branch information
misteroneill committed Oct 3, 2022
1 parent ce1baba commit b58a220
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/js/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
*/

import _inherits from '@babel/runtime/helpers/inherits';
import log from './utils/log.js';

let hasLogged = false;

/**
* Used to subclass an existing class by emulating ES subclassing using the
* `extends` keyword.
*
* @function
* @deprecated
* @example
* var MyComponent = videojs.extend(videojs.getComponent('Component'), {
* myCustomMethod: function() {
Expand All @@ -27,6 +31,15 @@ import _inherits from '@babel/runtime/helpers/inherits';
* The new class with subClassMethods that inherited superClass.
*/
const extend = function(superClass, subClassMethods = {}) {

// Log a warning the first time extend is called to note that it is deprecated
// It was previously deprecated in our documentation (guides, specifically),
// but was never formally deprecated in code.
if (!hasLogged) {
log.warn('videojs.extend is deprecated as of Video.js 7.22.0 and will be removed in Video.js 8.0.0');
hasLogged = true;
}

let subClass = function() {
superClass.apply(this, arguments);
};
Expand Down

0 comments on commit b58a220

Please sign in to comment.