jQuery already tests for absence of a constructor, just move where the
test is.
That test (L33-37) is not about the absence of a constructor, but about testing if the object is an instance of Object (looking if the not own constructor is Object). In fact, your added test (the typeof) have no sense there.
I made some tests using the IE console, and I come with some conclusions:
- IE7 Document Mode - host objects have NOT the "constructor" property.
- IE8 Document Mode - host objects have the "constructor" property.
- IE7/IE8 Document Mode - host objects have NOT "isPrototypeOf" nor "hasOwnProperty" properties.
Perhaps we can replace
obj.nodeType || obj.setInterval with
!("isPrototypeOf" in obj).
However, since window is the global namespace, and defining a global
"isPrototypeOf" is quite possible, this one would be probably more safer:
- !("isPrototypeOf" in obj) || obj.setInterval && /\[native code\]/.test(obj.setInterval)
Now, this test would make $.isPlainObject more precise, but maybe less robust because IE6/7/8 specific.
However, if we are sure that in all other browsers (mobile too) the toString test is enough, then why not.
Unless, IE will in a next versions add "isPrototypeOf" to host objects without fixing the toString behavior...
EDIT: Forgotten the last sentence, plus minor changes.