Skip to content

Commit

Permalink
Merge pull request mozilla#104 from ScottDowne/t1156
Browse files Browse the repository at this point in the history
[#1156] create track event _id before setup is called, still allow user ...
  • Loading branch information
jbuck committed Jun 20, 2012
2 parents 6abc9b7 + d4ab4d4 commit 84fdf64
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion popcorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@

if ( track._natives ) {
// Supports user defined track event id
track._id = !track.id ? Popcorn.guid( track._natives.type ) : track.id;
track._id = track.id || track._id || Popcorn.guid( track._natives.type );

// Push track event ids into the history
obj.data.history.push( track._id );
Expand Down Expand Up @@ -1536,6 +1536,11 @@
options.target = manifestOpts && "target" in manifestOpts && manifestOpts.target;
}

if ( options._natives ) {
// ensure an initial id is there before setup is called
options._id = Popcorn.guid( options._natives.type );
}

// Trigger _setup method if exists
options._natives._setup && options._natives._setup.call( this, options );

Expand Down
17 changes: 17 additions & 0 deletions test/popcorn.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,23 @@ test( "UI/Mouse", function() {
});

module( "Popcorn Plugin" );

test( "Plugin _id applied before setup", function() {

expect( 1 );

var p = Popcorn( "#video" );

Popcorn.plugin( "idPlugin", {
_setup: function( options ) {
ok( options._id, "_id was set before setup" );
Popcorn.removePlugin( "idPlugin" );
}
});

p.idPlugin({});
});

test( "Manifest", function() {

var p = Popcorn( "#video" ),
Expand Down

0 comments on commit 84fdf64

Please sign in to comment.