jquery / jquery/api.jquery.com
Document jQuery.isEmptyObject doesn't take symbols into account
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 325
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
Description
On version 3.6.0, I found a vulnerability,I find that the method of detecting empty objects is not perfect.
isEmptyObject: function( obj ) {
var name;
for ( name in obj ) {
return false;
}
return true;
},
The downside of writing this is that the properties of the prototype chain and the Symbol type are not taken into account,I have a better way to implement it as follows.
isEmptyObject: function( obj ) {
var keys = Object.keys(obj);
// 看浏览器是否支持 Symbol
if (typeof Symbol !== "undefined") {
keys = keys.concat(Object.getOwnPropertySymbols(obj));
}
return keys.length === 0;
}
Link to test case
This direct modification of the source code test is good, I do not have a service to run this test. I'm looking forward to hearing from you.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the jQuery.isEmptyObject API documentation and compare its current description with the behavior described in the issue. Confirm whether the documentation should explain Symbol properties and prototype-chain properties, then update the relevant documentation and verify the rendered entry reflects the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jquery
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100