Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose videojs.plugin() #2103

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as Lib from './lib';
import * as Util from './util.js';
import Player from './player';
import extendsFn from './extends.js';
import plugin from './plugins.js';

if (typeof HTMLVideoElement === 'undefined') {
document.createElement('video');
Expand All @@ -41,6 +42,8 @@ videojs.players = Player.players;

videojs.extends = extendsFn;

videojs.plugin = plugin;

// REMOVING: We probably should not include this in 5.0 thought it would make it
// more backwards compatible
// // Expose but deprecate the window[componentName] method for accessing components
Expand Down
23 changes: 23 additions & 0 deletions test/unit/video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import videojs from '../../src/js/video.js';
import TestHelpers from './test-helpers.js';

q.module('video.js');

test('should expose plugin registry function', function() {
var pluginName, pluginFunction, player;

pluginName = 'foo';
pluginFunction = function(options) {
console.log(this);
};

ok(videojs.plugin, 'should exist');

videojs.plugin(pluginName, pluginFunction);

player = TestHelpers.makePlayer();

ok(player.foo, 'should exist');
equal(player.foo, pluginFunction, 'should be equal');

});