Using "hasOwnProperty" to check for direct properties "type" and

This is the same change as https://github.com/jquery/jquery/pull/1140, minus a few back and forth commits that were reverted, and with a simpler unit test, as per @gnarf37's request.