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