Skip to content

Commit

Permalink
Removed the passing of playerOptions to plugins
Browse files Browse the repository at this point in the history
...because it caused an error, and it actually creates an inconsistent
plugin init process, when considering plugins that are initialized
outside of the player init.

fixes videojs#2510
  • Loading branch information
heff committed Sep 1, 2015
1 parent f492450 commit 9c90150
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class Player extends Component {
let plugins = options.plugins;

Object.getOwnPropertyNames(plugins).forEach(function(name){
plugins[name].playerOptions = playerOptionsCopy;
if (typeof this[name] === 'function') {
this[name](plugins[name]);
} else {
Expand Down
24 changes: 12 additions & 12 deletions test/unit/plugins.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Plugin from '../../src/js/plugins.js';
import registerPlugin from '../../src/js/plugins.js';
import Player from '../../src/js/player.js';
import TestHelpers from './test-helpers.js';
import window from 'global/window';
Expand All @@ -8,12 +8,12 @@ q.module('Plugins');
test('Plugin should get initialized and receive options', function(){
expect(2);

Plugin('myPlugin1', function(options){
registerPlugin('myPlugin1', function(options){
ok(true, 'Plugin initialized');
ok(options['test'], 'Option passed through');
});

Plugin('myPlugin2', function(options){
registerPlugin('myPlugin2', function(options){
ok(false, 'Plugin initialized and should not have been');
});

Expand All @@ -31,7 +31,7 @@ test('Plugin should get initialized and receive options', function(){
test('Plugin should have the option of being initilized outside of player init', function(){
expect(3);

Plugin('myPlugin3', function(options){
registerPlugin('myPlugin3', function(options){
ok(true, 'Plugin initialized after player init');
ok(options['test'], 'Option passed through');
});
Expand All @@ -50,7 +50,7 @@ test('Plugin should have the option of being initilized outside of player init',
test('Plugin should be able to add a UI component', function(){
expect(2);

Plugin('myPlugin4', function(options){
registerPlugin('myPlugin4', function(options){
ok((this instanceof Player), 'Plugin executed in player scope by default');
this.addChild('component');
});
Expand All @@ -72,21 +72,21 @@ test('Plugin should overwrite plugin of same name', function(){
v3Called = 0;

// Create initial plugin
Plugin('myPlugin5', function(options){
registerPlugin('myPlugin5', function(options){
v1Called++;
});
var player = TestHelpers.makePlayer({});
player['myPlugin5']({});

// Overwrite and create new player
Plugin('myPlugin5', function(options){
registerPlugin('myPlugin5', function(options){
v2Called++;
});
var player2 = TestHelpers.makePlayer({});
player2['myPlugin5']({});

// Overwrite and init new version on existing player
Plugin('myPlugin5', function(options){
registerPlugin('myPlugin5', function(options){
v3Called++;
});
player2['myPlugin5']({});
Expand All @@ -109,7 +109,7 @@ test('Plugins should get events in registration order', function() {
var name;
var player = TestHelpers.makePlayer({});
var plugin = function (name) {
Plugin(name, function (opts) {
registerPlugin(name, function (opts) {
this.on('test', function (event) {
order.push(name);
});
Expand All @@ -123,7 +123,7 @@ test('Plugins should get events in registration order', function() {
plugin(name);
}

Plugin('testerPlugin', function (opts) {
registerPlugin('testerPlugin', function (opts) {
this.trigger('test');
});

Expand All @@ -141,7 +141,7 @@ test('Plugins should not get events after stopImmediatePropagation is called', f
var name;
var player = TestHelpers.makePlayer({});
var plugin = function (name) {
Plugin(name, function (opts) {
registerPlugin(name, function (opts) {
this.on('test', function (event) {
order.push(name);
event.stopImmediatePropagation();
Expand All @@ -156,7 +156,7 @@ test('Plugins should not get events after stopImmediatePropagation is called', f
plugin(name);
}

Plugin('testerPlugin', function (opts) {
registerPlugin('testerPlugin', function (opts) {
this.trigger('test');
});

Expand Down

0 comments on commit 9c90150

Please sign in to comment.