Skip to content

Commit

Permalink
Softened requirement for key path. It is now only in the case when a …
Browse files Browse the repository at this point in the history
…path is passed.
  • Loading branch information
Kevin Malakoff committed Sep 22, 2011
1 parent 2195566 commit 5d2c423
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions underscore-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion underscore.js
Expand Up @@ -755,7 +755,9 @@
switch (typeof(constructor_or_string)) {
// Resolve string to constructor
case 'string':
var constructor = _.keypathValue(window, constructor_or_string); if (!constructor || !_.isConstructor(constructor)) return null;
var keypath_parts = constructor_or_string.split('.');
var constructor = (keypath_parts.length===1) ? window[constructor_or_string] : _.keypathValue(window, keypath_parts);
if (!constructor || !_.isConstructor(constructor)) return null;
if (!include_name) return constructor;
if (constructor.name.length) return [constructor, constructor.name];
// Provide a name for is{SomeType}(), to{SomeType}() convention
Expand Down

0 comments on commit 5d2c423

Please sign in to comment.