Document jQuery.isEmptyObject doesn't take symbols into account

オープン
#1,192 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
jquery
領域
documentation

調査の方向性

まず jQuery.isEmptyObject API のドキュメントを見つけ、現在の説明を issue に記載された動作と比較します。ドキュメントで Symbol プロパティとプロトタイプチェーンのプロパティについて説明すべきかを確認し、その後、該当するドキュメントを更新して、レンダリングされたエントリが合意した動作を反映していることを確認します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
HTML
スター
324
フォーク
259
平均マージ
1日 30分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

jquery/api.jquery.com のほかの issue

jquery/api.jquery.com の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。