Created by: Darkseal
ownerDocument isn't guaranteed to have value. If you do something like $(document).tooltip(), the following error will occur:
Uncaught TypeError: Cannot read property ‘documentElement’ of null
This additional check (with a safe fallback provided) will fix it.