diff --git a/CHANGELOG.md b/CHANGELOG.md index feb45d2fa..d6a89dccd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ CHANGELOG * @dmlap fixed a vjs_getProperty error caused by a progress check before the swf was ready ([view](https://github.com/videojs/video.js/pull/2316)) * @dmlap exported the videojs.log function ([view](https://github.com/videojs/video.js/pull/2317)) * @gkatsev updated vttjs to fix a trailing comma JSON error ([view](https://github.com/videojs/video.js/pull/2331)) +* @gkatsev exported the videojs.bind() function ([view](https://github.com/videojs/video.js/pull/2332)) -------------------- diff --git a/src/js/video.js b/src/js/video.js index 4c59c1a18..ff7a5e73f 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -8,6 +8,7 @@ import globalOptions from './global-options.js'; import Player from './player'; import plugin from './plugins.js'; import mergeOptions from '../../src/js/utils/merge-options.js'; +import * as Fn from './utils/fn.js'; import assign from 'object.assign'; import log from './utils/log.js'; @@ -257,6 +258,23 @@ videojs.extends = extendsFn; */ videojs.mergeOptions = mergeOptions; +/** + * Change the context (this) of a function + * + * videojs.bind(newContext, function(){ + * this === newContext + * }); + * + * NOTE: as of v5.0 we require an ES5 shim, so you should use the native + * `function(){}.bind(newContext);` instead of this. + * + * @param {*} context The object to bind as scope + * @param {Function} fn The function to be bound to a scope + * @param {Number=} uid An optional unique ID for the function to be set + * @return {Function} + */ +videojs.bind = Fn.bind; + /** * Create a Video.js player plugin * Plugins are only initialized when options for the plugin are included