From b58a2201c4e4af76f2d754aa633f21456f60cbdc Mon Sep 17 00:00:00 2001 From: Pat O'Neill Date: Mon, 3 Oct 2022 17:22:01 -0400 Subject: [PATCH] fix: deprecate the extend() function (#7944) This function will be removed in Video.js 8.0 --- src/js/extend.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/js/extend.js b/src/js/extend.js index 098129e4ce..024ba680f9 100644 --- a/src/js/extend.js +++ b/src/js/extend.js @@ -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() { @@ -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); };