Skip to content

Remove broken optional debug feature #45

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

Merged
merged 1 commit into from
Jul 22, 2014
Merged
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 config.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ this.config = ( function() {
]
},
tests: [
'tests/lib/util/util.inherit.tests',
'tests/lib/globeCoordinate/globeCoordinate.tests',
'tests/lib/globeCoordinate/globeCoordinate.Formatter.tests',
'tests/lib/globeCoordinate/globeCoordinate.GlobeCoordinate.tests',
Expand Down
49 changes: 12 additions & 37 deletions lib/util/util.inherit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ this.util = this.util || {};
( function( util ) {
'use strict';

/**
* @type {Function}
*/
var EMPTY_FN = function() {};

/**
* Extends an object with the attributes of another object.
*
Expand All @@ -30,32 +25,15 @@ this.util = this.util || {};
}

/**
* Helper to create a named function which will execute a given function.
* Helper to create a function which will execute a given function.
*
* @param {string} name Name of the new function. All characters not matching [\w$] will be
* removed.
* @param {Function} [originalFn] Function which will be executed by new function. If not given,
* an empty function will be used instead.
* @param {Function} [originalFn] Optional function which will be executed by new function.
* @return {Function}
*
* @throws {Error} if the given name has no characters matching [\w$].
*/
function createNamedFunction( name, originalFn ) {
/* jshint evil: true */
/* jshint unused: false */
var namedFn;
var evilsSeed = originalFn || EMPTY_FN;
var fnName = name.replace( /(?:(^\d+)|[^\w$])/ig, '' );

if( !fnName ) {
// only bad characters were in the name!
throw new Error( 'Bad function name given. At least one word character or $ required.' );
}

eval( 'namedFn = function ' + fnName +
'(){ evilsSeed.apply( this, arguments ); }' );

return namedFn; // value got assigned in eval
function createFunction( originalFn ) {
return originalFn
? function() { originalFn.apply( this, arguments ) }
: function() {};
}

/**
Expand All @@ -82,7 +60,10 @@ this.util = this.util || {};
util.inherit = function( name, base, constructor, members ) {
// name is optional
if( typeof name !== 'string' ) {
members = constructor; constructor = base; base = name; name = false;
members = constructor;
constructor = base;
base = name;
name = false;
}

// allow to omit constructor since it can be inherited directly. But if given, require it as
Expand All @@ -96,19 +77,13 @@ this.util = this.util || {};
constructor = false;
}
}
// If no name is given, find suitable constructor name. We want proper names here, so
// instances can easily be identified during debugging.
var constructorName = name
|| constructor.name
|| ( base.name ? base.name + '_SubProto' : 'SomeInherited' ),
prototypeName = base.name || 'SomeProto';

// function we execute in our real constructor
var NewConstructor = createNamedFunction( constructorName, constructor || base );
var NewConstructor = createFunction( constructor || base );

// new constructor for avoiding direct use of base constructor and its potential
// side-effects
var NewPrototype = createNamedFunction( prototypeName );
var NewPrototype = createFunction();
NewPrototype.prototype = base.prototype;

NewConstructor.prototype = extend(
Expand Down
81 changes: 0 additions & 81 deletions tests/lib/util/util.inherit.tests.js

This file was deleted.