Simplify toSource.

This commit is contained in:
John-David Dalton
2016-04-07 12:19:02 -07:00
parent 06412d5f12
commit f4ff4f29b1

View File

@@ -5291,8 +5291,8 @@
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) {
var result = objectToString.call(value),
Ctor = result == objectTag ? value.constructor : null,
ctorString = toSource(Ctor);
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : undefined;
if (ctorString) {
switch (ctorString) {
@@ -5791,12 +5791,15 @@
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (isFunction(func)) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return toString(func);
return '';
}
/**