Skip to content

Commit

Permalink
Bugfix: getInstanceType broken in IE
Browse files Browse the repository at this point in the history
For some reason, getting an object constructor name as a string in IE adds
a single space at the end.  This was breaking a couple plugin test specs,
and could possibly have been breaking other things as well, in the case
that the plugin needed to be referenced by name.
  • Loading branch information
c0bra committed Jun 26, 2013
1 parent 9fb3ed5 commit ccbdbfb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/services/UtilityService.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@
},
getInstanceType: function (o) {
var results = (funcNameRegex).exec(o.constructor.toString());
return (results && results.length > 1) ? results[1] : "";
if (results && results.length > 1) {
var instanceType = results[1].replace(/^\s+|\s+$/g, ""); // Trim surrounding whitespace; IE appears to add a space at the end
return instanceType;
}
else {
return "";
}
},
// Detect IE versions for bug workarounds (uses IE conditionals, not UA string, for robustness)
// Note that, since IE 10 does not support conditional comments, the following logic only detects IE < 10.
Expand Down

0 comments on commit ccbdbfb

Please sign in to comment.