Skip to content

Commit b58a220

Browse files
authored
fix: deprecate the extend() function (#7944)
This function will be removed in Video.js 8.0
1 parent ce1baba commit b58a220

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/js/extend.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
*/
55

66
import _inherits from '@babel/runtime/helpers/inherits';
7+
import log from './utils/log.js';
8+
9+
let hasLogged = false;
710

811
/**
912
* Used to subclass an existing class by emulating ES subclassing using the
1013
* `extends` keyword.
1114
*
1215
* @function
16+
* @deprecated
1317
* @example
1418
* var MyComponent = videojs.extend(videojs.getComponent('Component'), {
1519
* myCustomMethod: function() {
@@ -27,6 +31,15 @@ import _inherits from '@babel/runtime/helpers/inherits';
2731
* The new class with subClassMethods that inherited superClass.
2832
*/
2933
const extend = function(superClass, subClassMethods = {}) {
34+
35+
// Log a warning the first time extend is called to note that it is deprecated
36+
// It was previously deprecated in our documentation (guides, specifically),
37+
// but was never formally deprecated in code.
38+
if (!hasLogged) {
39+
log.warn('videojs.extend is deprecated as of Video.js 7.22.0 and will be removed in Video.js 8.0.0');
40+
hasLogged = true;
41+
}
42+
3043
let subClass = function() {
3144
superClass.apply(this, arguments);
3245
};

0 commit comments

Comments
 (0)