Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deprecation): deprecate the extend function #7944

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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