qunit.completenessTest: Correct walkTheObject behaviour wrt breadcrumb
authorAdrian Lang <adrian.lang@wikimedia.de>
Fri, 28 Mar 2014 09:11:07 +0000 (10:11 +0100)
committerKrinkle <krinklemail@gmail.com>
Thu, 19 Jun 2014 05:47:29 +0000 (05:47 +0000)
The function documentation states that currName is not included in
parentPathArray, although it actually is. This change makes the
implementation match the documentated behavior.

Change-Id: I6e44ad84de2e31320309438b8aa09ec929d15e8e

resources/src/jquery/jquery.qunit.completenessTest.js

index 1c47feb..d6dfedd 100644 (file)
                        }
                        return keys;
                },
-               extend: function () {
-                       var options, name, src, copy,
-                               target = arguments[0] || {},
-                               i = 1,
-                               length = arguments.length;
-
-                       for ( ; i < length; i++ ) {
-                               options = arguments[ i ];
-                               // Only deal with non-null/undefined values
-                               if ( options !== null && options !== undefined ) {
-                                       // Extend the base object
-                                       for ( name in options ) {
-                                               src = target[ name ];
-                                               copy = options[ name ];
-
-                                               // Prevent never-ending loop
-                                               if ( target === copy ) {
-                                                       continue;
-                                               }
-
-                                               if ( copy !== undefined ) {
-                                                       target[ name ] = copy;
-                                               }
-                                       }
-                               }
-                       }
-
-                       // Return the modified object
-                       return target;
-               },
                each: function ( object, callback ) {
                        var name;
                        for ( name in object ) {
                 * @param action {Number} What is this function supposed to do (ACTION_INJECT or ACTION_CHECK)
                 */
                walkTheObject: function ( currName, currVar, masterVariable, parentPathArray, action ) {
-
-                       var key, value, tmpPathArray,
+                       var key, value, currPathArray,
                                type = util.type( currVar ),
                                that = this;
 
+                       currPathArray = parentPathArray;
+                       if ( currName ) {
+                               currPathArray.push( currName );
+                       }
+
                        // Hard ignores
-                       if ( this.ignoreFn( currVar, that, parentPathArray ) ) {
+                       if ( this.ignoreFn( currVar, that, currPathArray ) ) {
                                return null;
                        }
 
                        // Handle the lazy limit
                        this.lazyCounter++;
                        if ( this.lazyCounter > this.lazyLimit ) {
-                               log( 'CompletenessTest.fn.walkTheObject> Limit reached: ' + this.lazyCounter, parentPathArray );
+                               log( 'CompletenessTest.fn.walkTheObject> Limit reached: ' + this.lazyCounter, currPathArray );
                                return null;
                        }
 
 
                                        if ( action === CompletenessTest.ACTION_INJECT ) {
 
-                                               that.injectionTracker[ parentPathArray.join( '.' ) ] = true;
-                                               that.injectCheck( masterVariable, parentPathArray, function () {
-                                                       that.methodCallTracker[ parentPathArray.join( '.' ) ] = true;
+                                               that.injectionTracker[ currPathArray.join( '.' ) ] = true;
+                                               that.injectCheck( masterVariable, currPathArray, function () {
+                                                       that.methodCallTracker[ currPathArray.join( '.' ) ] = true;
                                                } );
                                        }
 
                                                                        continue;
                                                                }
 
-                                                               // Clone and break reference to parentPathArray
-                                                               tmpPathArray = util.extend( [], parentPathArray );
-                                                               tmpPathArray.push( 'prototype' );
-                                                               tmpPathArray.push( key );
-
-                                                               that.walkTheObject( key, value, masterVariable, tmpPathArray, action );
+                                                               that.walkTheObject( key, value, masterVariable, currPathArray.concat( 'prototype' ), action );
                                                        }
                                                }
 
                                        if ( hasOwn.call( currVar, key ) ) {
                                                value = currVar[key];
 
-                                               // Clone and break reference to parentPathArray
-                                               tmpPathArray = util.extend( [], parentPathArray );
-                                               tmpPathArray.push( key );
-
-                                               that.walkTheObject( key, value, masterVariable, tmpPathArray, action );
+                                               that.walkTheObject( key, value, masterVariable, currPathArray.slice(), action );
                                        }
                                }
                        }