From 9de463e35c57f0801c567f0759d7b7e054088dcd Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Thu, 9 Jul 2015 16:32:45 -0400 Subject: [PATCH] Export bind on videojs. Fixes #2322 closes #2332 --- CHANGELOG.md | 1 + src/js/video.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) 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