1
0
Fork 0

Revert "Removed unnecessary try/catch from isInstanceOf"

This reverts commit 58ee52ad4a.

As it turns out, IE9 allows use of instanceof with special object types, not
just functions. One such example is HTMLElement; its type is `object', whereas
in Firefox and Chromium it is `function'. There is no reliable way to perform
this detection.

Therefore, the try/catch here is more reliable.
newmaster
Mike Gerwitz 2014-04-21 22:22:42 -04:00
parent 8391bc007d
commit bb98c9afb3
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
1 changed files with 8 additions and 6 deletions

View File

@ -244,14 +244,16 @@ exports.isInstanceOf = function( type, instance )
return false;
}
// check prototype chain (will throw an error if type is not a
// constructor (function)
if ( ( typeof type === 'function' )
&& ( instance instanceof type )
)
try
{
return true;
// check prototype chain (will throw an error if type is not a
// constructor (function)
if ( instance instanceof type )
{
return true;
}
}
catch ( e ) {}
// if no metadata is available, then our remaining checks cannot be
// performed