Skip to content
This repository

[#1156] create track event _id before setup is called, still allow user ... #104

Merged
merged 1 commit into from almost 2 years ago

2 participants

ScottDowne Jon Buckley
ScottDowne
Collaborator

...defined ids, and still support addTrackEvent called outside of a plugin, in the case of internal padding plugins.

ScottDowne [#1156] create track event _id before setup is called, still allow us…
…er defined ids, and still support addTrackEvent called outside of a plugin, in the case of internal padding plugins.
d4ab4d4
Jon Buckley jbuck merged commit 84fdf64 into from June 20, 2012
Jon Buckley jbuck closed this June 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 15, 2012
ScottDowne [#1156] create track event _id before setup is called, still allow us…
…er defined ids, and still support addTrackEvent called outside of a plugin, in the case of internal padding plugins.
d4ab4d4
This page is out of date. Refresh to see the latest.
7  popcorn.js
@@ -860,7 +860,7 @@
860 860
 
861 861
     if ( track._natives ) {
862 862
       //  Supports user defined track event id
863  
-      track._id = !track.id ? Popcorn.guid( track._natives.type ) : track.id;
  863
+      track._id = track.id || track._id || Popcorn.guid( track._natives.type );
864 864
 
865 865
       //  Push track event ids into the history
866 866
       obj.data.history.push( track._id );
@@ -1466,6 +1466,11 @@
1466 1466
         options.target = manifestOpts && "target" in manifestOpts && manifestOpts.target;
1467 1467
       }
1468 1468
 
  1469
+      if ( options._natives ) {
  1470
+        // ensure an initial id is there before setup is called
  1471
+        options._id = Popcorn.guid( options._natives.type );
  1472
+      }
  1473
+
1469 1474
       // Trigger _setup method if exists
1470 1475
       options._natives._setup && options._natives._setup.call( this, options );
1471 1476
 
17  test/popcorn.unit.js
@@ -1830,6 +1830,23 @@ test( "UI/Mouse", function() {
1830 1830
 });
1831 1831
 
1832 1832
 module( "Popcorn Plugin" );
  1833
+
  1834
+test( "Plugin _id applied before setup", function() {
  1835
+
  1836
+  expect( 1 );
  1837
+
  1838
+  var p = Popcorn( "#video" );
  1839
+
  1840
+  Popcorn.plugin( "idPlugin", {
  1841
+    _setup: function( options ) {
  1842
+      ok( options._id, "_id was set before setup" );
  1843
+      Popcorn.removePlugin( "idPlugin" );
  1844
+    }
  1845
+  });
  1846
+
  1847
+  p.idPlugin({});
  1848
+});
  1849
+
1833 1850
 test( "Manifest", function() {
1834 1851
 
1835 1852
   var p = Popcorn( "#video" ),
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.