diff --git a/CHANGELOG.md b/CHANGELOG.md index e509c04f2..e81d12a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG * @BrandonOCasey Document audio/video track usage ([view](https://github.com/videojs/video.js/pull/3295)) * @hartman Correct documentation to refer to nativeTextTracks option ([view](https://github.com/videojs/video.js/pull/3309)) * @nickygerritsen Also pass tech options to canHandleSource ([view](https://github.com/videojs/video.js/pull/3303)) +* @misteroneill Un-deprecate the videojs.players property ([view](https://github.com/videojs/video.js/pull/3299)) -------------------- diff --git a/src/js/utils/create-deprecation-proxy.js b/src/js/utils/create-deprecation-proxy.js deleted file mode 100644 index fa2d446f9..000000000 --- a/src/js/utils/create-deprecation-proxy.js +++ /dev/null @@ -1,50 +0,0 @@ -import log from './log.js'; - -/** - * Object containing the default behaviors for available handler methods. - * - * @private - * @type {Object} - */ -const defaultBehaviors = { - get(obj, key) { - return obj[key]; - }, - set(obj, key, value) { - obj[key] = value; - return true; - } -}; - -/** - * Expose private objects publicly using a Proxy to log deprecation warnings. - * - * Browsers that do not support Proxy objects will simply return the `target` - * object, so it can be directly exposed. - * - * @param {Object} target The target object. - * @param {Object} messages Messages to display from a Proxy. Only operations - * with an associated message will be proxied. - * @param {String} [messages.get] - * @param {String} [messages.set] - * @return {Object} A Proxy if supported or the `target` argument. - */ -export default (target, messages={}) => { - if (typeof Proxy === 'function') { - let handler = {}; - - // Build a handler object based on those keys that have both messages - // and default behaviors. - Object.keys(messages).forEach(key => { - if (defaultBehaviors.hasOwnProperty(key)) { - handler[key] = function() { - log.warn(messages[key]); - return defaultBehaviors[key].apply(this, arguments); - }; - } - }); - - return new Proxy(target, handler); - } - return target; -}; diff --git a/src/js/video.js b/src/js/video.js index f591efe7a..bd8ed19c9 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -16,7 +16,6 @@ import TextTrack from './tracks/text-track.js'; import AudioTrack from './tracks/audio-track.js'; import VideoTrack from './tracks/video-track.js'; -import assign from 'object.assign'; import { createTimeRanges } from './utils/time-ranges.js'; import formatTime from './utils/format-time.js'; import log from './utils/log.js'; @@ -25,7 +24,6 @@ import * as browser from './utils/browser.js'; import * as Url from './utils/url.js'; import extendFn from './extend.js'; import merge from 'lodash-compat/object/merge'; -import createDeprecationProxy from './utils/create-deprecation-proxy.js'; import xhr from 'xhr'; // Include the built-in techs @@ -153,21 +151,15 @@ videojs.options = Player.prototype.options_; * @mixes videojs * @method getPlayers */ -videojs.getPlayers = function() { - return Player.players; -}; +videojs.getPlayers = () => Player.players; /** - * For backward compatibility, expose players object. + * Expose players object. * - * @deprecated * @memberOf videojs - * @property {Object|Proxy} players + * @property {Object} players */ -videojs.players = createDeprecationProxy(Player.players, { - get: 'Access to videojs.players is deprecated; use videojs.getPlayers instead', - set: 'Modification of videojs.players is deprecated' -}); +videojs.players = Player.players; /** * Get a component class object by name diff --git a/test/unit/utils/create-deprecation-proxy.test.js b/test/unit/utils/create-deprecation-proxy.test.js deleted file mode 100644 index 17f990f63..000000000 --- a/test/unit/utils/create-deprecation-proxy.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import createDeprecationProxy from '../../../src/js/utils/create-deprecation-proxy.js'; -import log from '../../../src/js/utils/log.js'; - -const proxySupported = typeof Proxy === 'function'; - -test('should return a Proxy object when supported or the target object by reference', function() { - let target = {foo: 1}; - let subject = createDeprecationProxy(target, { - get: 'get message', - set: 'set message' - }); - - // Testing for a Proxy is really difficult because Proxy objects by their - // nature disguise the fact that they are in fact Proxy objects. So, this - // tests that the log.warn method gets called on property get/set operations - // to detect the Proxy. - if (proxySupported) { - sinon.stub(log, 'warn'); - - subject.foo; // Triggers a "get" - subject.foo = 2; // Triggers a "set" - - equal(log.warn.callCount, 2, 'proxied operations cause deprecation warnings'); - ok(log.warn.calledWith('get message'), 'proxied get logs expected message'); - ok(log.warn.calledWith('set message'), 'proxied set logs expected message'); - - log.warn.restore(); - } else { - strictEqual(target, subject, 'identical to target'); - } -}); - -// Tests run only in Proxy-supporting environments. -if (proxySupported) { - test('no deprecation warning is logged for operations without a message', function() { - let subject = createDeprecationProxy({}, { - get: 'get message' - }); - - sinon.stub(log, 'warn'); - subject.foo = 'bar'; // Triggers a "set," but not a "get" - equal(log.warn.callCount, 0, 'no deprecation warning expected'); - log.warn.restore(); - }); -}