-
Notifications
You must be signed in to change notification settings - Fork 266
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
jQuery.isPlainObject( { ... } ) can be tricked by manipulating Symbol.toStringTag #1182
Comments
https://github.com/jquery/jquery/blob/3.6.0/src/core.js#L223 It's not clear to me that the |
@gibson042 do you know why do we need this part? Tests pass in Chrome & Firefox if you cut it out. |
Looking at jquery/jquery@e0d3bfa#diff-8ab41fe13597e1554b5d6b4c227b5f123ff2d6726a7f3688a8b8d1224fe1d4f3R231 , there might be/have been supported environments where a window object and/or (IE?) host object had no prototype. Assuming that's not the case now, I have no problem with removing the |
I've just checked; the |
@Andrew-Cottrell would you like to submit a PR updating the documentation? I think we won't be able to change the implementation. |
Sorry, I have no prior experience with GitHub PRs and I am currently too busy with work to take the time to learn. I suggest a single sentence is appended to the Note section, just before the Example section.
The sentence could be expanded
Or perhaps
The same, or a similar, sentence might also be added to https://github.com/jquery/jquery/wiki/Won't-Fix |
The documentation for isPlainObject indicates the following evaluates to
true
, but in jQuery v3.5.1 it evaluates tofalse
.jQuery.isPlainObject( { [Symbol.toStringTag]: "Tag" } );
I suggest the documentation be changed to clarify the behaviour when an otherwise plain object has a
[Symbol.toStringTag]
property unequal to"Object"
.The text was updated successfully, but these errors were encountered: