-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isXMLDoc() - Uncaught TypeError: Cannot read property 'namespaceURI' of undefined #4782
Comments
Can you post a test case showing when this happens? Also can you use the latest jQuery 3 in your test case? Be aware that version 2.x is no longer supported. If there is a bug to fix we'd only be fixing it in jQuery 3.x, or 4.x if it requires a breaking change. |
I'am afraid if I present my use case, the attention will move away from my finding. Which is: jQuery 3.3.1 returns: jQuery 3.5.1 doesn't check the argument, 3.3.1 does. I'am talking about jQuery 3.x, not 2.x, only 2.x I mentioned is Sizzle update from 2.3.3 to 2.3.4, where this |
As indicated in the signature of that method on its API page, only arguments of Element type are allowed as input to that method. Behavior for all other inputs is undefined as jQuery generally doesn't validate whether input is of a correct type. If you want to make sure you only use allowed types, using TypeScript with jQuery typings is a good idea. I'll let it open for discussion for now but generally we've been leaning towards not handling |
We're deliberating whether we want to add back the falsey check. |
I think we're willing to add back the falsey check, but we'd all feel better if there was a valid use case presented.
Just the opposite btw. It will grant some validity to your finding. |
Sorry for the late reply. Here is a part of that code working with ajax responses.
The Could you reopen this issue please? |
Thanks for the use case, reopening. |
PR to jQuery ( |
Landed in jquery/sizzle#474 & #4814 but we still need to update Sizzle on |
Reopening as it awaits a Sizzle update. |
Description
isXMLDoc()
throws an error ifundefined
given, starting from version 3.4.0Test script:
jQuery.isXMLDoc(undefined)
jQuery 3.3.1 result:
false
jQuery 3.5.1 (currently the latest, but starting from 3.4.0) result:
Uncaught TypeError: Cannot read property 'namespaceURI' of undefined
Techinfo
Before the Sizzle update from 2.3.3 to 2.3.4 (see related commit below),
isXML()
function looked liked this:This doesn't throw an error, when the
elem
isundefined
, because it checks it.In the update from 3.4.0, it looks like this:
This throws an error when the
elem
isundefined
:Uncaught TypeError: Cannot read property 'namespaceURI' of undefined
Please, if you can, bring back the previous functionality:
undefined
is not an XML node, so it should return a false boolean instead of a TypeError.Thanks in advance!
Additional info
Related commit: d940bc0 (from line 562)
Related blog-post: https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/
The text was updated successfully, but these errors were encountered: