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

Removed the passing of playerOptions to plugins #2532

Closed
wants to merge 1 commit 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
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') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only interesting change.

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