jquery / sizzle

A sizzlin' hot selector engine.
https://sizzlejs.com
Other
6.29k stars 951 forks source link

document.documentElement can be null in Safari #444

Closed mihhail-lapushkin closed 5 years ago

mihhail-lapushkin commented 5 years ago

I am not quite sure when it can be null, but I've observed this in our application. It happens only in Safari 12 and might be related to iframes. I am not sure if this is a good fix, but does not seem like a bad idea to protect against this case if there is a real world case suggesting document.documentElement can be null.

jsf-clabot commented 5 years ago

CLA assistant check
All committers have signed the CLA.

mgol commented 5 years ago

Thanks for the PR. Adding a check like that without understanding the underlying issue may lead to further issues, though so we can't accept the PR as-is. Also, all changes need unit tests.

If you can construct a test case, please let us know (& please open an issue in it so that we have a place to track it other than this PR).

mihhail-lapushkin commented 5 years ago

So far I could trace it to https://github.com/jquery/jquery/blob/master/src/manipulation.js#L152 then https://github.com/jquery/jquery/blob/master/src/manipulation/buildFragment.js#L81 then https://github.com/jquery/jquery/blob/master/src/core/isAttached.js#L9

Safari inspector crashes every time I try to see the cause. Probably due to app being so huge.