From 4e7b59eb615715c64b781f94b8b06961ee07e3d9 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Wed, 23 Feb 2011 15:10:46 -0600 Subject: [PATCH] [#336] tweak the comments in the test, address Scott's other review comment, and wrap something a little more nicely --- popcorn.js | 9 +++++---- test/popcorn.unit.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/popcorn.js b/popcorn.js index 7461da7..083f36b 100644 --- a/popcorn.js +++ b/popcorn.js @@ -684,7 +684,7 @@ plugin = {}, setup; - function pluginFn ( setup, options ) { + var pluginFn = function ( setup, options ) { if ( !options ) { return this; @@ -744,11 +744,12 @@ Popcorn.manifest[ name ] = manifest || definition.manifest; } + var isfn = typeof definition === "function"; // Assign new named definition plugin[ name ] = function( options ) { - return pluginFn.call( this, typeof definition === "function" ? - definition.call( this, options ) : - definition, options ); + return pluginFn.call( this, + isfn ? definition.call( this, options ) + : definition, options ); }; // Extend Popcorn.p with new named definition diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 21b74bf..4595a5a 100755 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -753,12 +753,12 @@ test("Plugin Factory", function () { options.endCount = 0; }, start: function ( event, options ) { - // test is run four times. Two closure tracks, called twice each + // called once for each instance; the test will fail if startCount is not actually unique per instance equals( startCount++, options.startCount++, options.nick + " has correct start counts" ); plus(); }, end: function ( event, options ) { - // test is run four times. Two closure tracks, called twice each + // likewise for endCount equals( endCount++, options.endCount++, options.nick + " has correct end counts" ); plus(); -- 2.43.0