You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 a different outcome for the same function and argument then 3.5.1
jQuery 3.3.1 returns: false
jQuery 3.5.1 returns: Uncaught TypeError: Cannot read property 'namespaceURI' of undefined
For this line of code: jQuery.isXMLDoc(undefined)
jQuery 3.5.1 doesn't check the argument, 3.3.1 does. undefined is not an XML node, so in my interpretation it should return false, as version 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 isXML() function is changed and causing this new TypeError since 3.4.0. Linked under Additional info in my original post.
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 undefined inputs in APIs where it's not expected.
Activity
dmethvin commentedon Aug 29, 2020
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.
borzaka commentedon Aug 30, 2020
I'am afraid if I present my use case, the attention will move away from my finding. Which is:
jQuery 3.3.1 returns a different outcome for the same function and argument then 3.5.1
jQuery 3.3.1 returns:
falsejQuery 3.5.1 returns:
Uncaught TypeError: Cannot read property 'namespaceURI' of undefinedFor this line of code:
jQuery.isXMLDoc(undefined)jQuery 3.5.1 doesn't check the argument, 3.3.1 does.
undefinedis not an XML node, so in my interpretation it should returnfalse, as version 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
isXML()function is changed and causing this new TypeError since 3.4.0. Linked under Additional info in my original post.mgol commentedon Aug 30, 2020
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
undefinedinputs in APIs where it's not expected.timmywil commentedon Aug 31, 2020
We're deliberating whether we want to add back the falsey check.
timmywil commentedon Sep 14, 2020
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.
borzaka commentedon Nov 6, 2020
Sorry for the late reply. Here is a part of that code working with ajax responses.
The
$.isXMLDoc(xhr.responseXML)is failing because of the lack of the falsey check as before.Could you reopen this issue please?
mgol commentedon Nov 6, 2020
Thanks for the use case, reopening.
22 remaining items
Selector: Update Sizzle from 2.3.5 to 2.3.6
Selector: Update Sizzle from 2.3.5 to 2.3.6
mgol commentedon Feb 18, 2021
Fixed on
3.x-stable(jQuery 3.x) by #4846.Previously, it was only fixed on
main(jQuery 4.0) by #4814.Closing.
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input
Core: Make jQuery.isXMLDoc accept falsy input