In what scenarios the docs about 'The name "class" must be quoted in the object...' are relevant?

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

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

評価

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

調査の方向性

https://api.jquery.com/jquery/ の jquery API ドキュメントページを確認し、"class" の引用符に関する記述を、提供された JavaScript の例およびブラウザーバージョンごとの結果と比較してください。該当するバージョンに対してこのガイダンスが現在も正確かどうかを確認し、そのうえで適用されるシナリオを明確に記載するようドキュメントを更新してください。

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

説明

jQuery version: 3.4.1

Hi jQuery docs team!
While I was reformatting some code with an automated tool, I noticed that tool removes the quotes in this kind of code:

// Original code
var $p = $('<p>', {
    "class": "b-info", // I am USING quotes for "class"
    text: "Appended text"
});
// After passing the formatter
var $p = $('<p>', {
    class: 'b-info', // Quotes are removed from "class"
    text: "Appended text"
});

So, I went back to jQuery docs in https://api.jquery.com/jquery/ where it is said:

The name "class" must be quoted in the object since it is a JavaScript reserved word, and "className" cannot be used since it refers to the DOM property, not the attribute.

I was wondering if you have identified scenarios/versions where this is RELEVANT.

I did some tests using this minimal code, in:

  • Google Chrome: OK
  • Safari: OK
  • Firefox: OK
  • MS Edge: OK
  • IE 11: OK
  • IE 10 (Emulation): OK
  • IE 9 (Emulation): OK
  • IE 8 (Emulation): FAILS
  • IE 7 (Emulation): FAILS

So, it seems, this code ONLY fails on IE 8 and older versions of that browser, is that correct?
Thanks in advance.
Best regards.

<!doctype html>
<html lang="en">
<body>
    <h1>jQuery test</h1>

    <p>"Appended text" will be appended. Check your console too!</p>

    <script src="./js/jquery-3.4.1.min.js"></script>
    <script>
    	(function($) {
             var $p = $('<p>', {
                 class: 'b-info', // I am not using quotes for "class"
                 text: 'Appended text'
             });

             $('body').append($p);
    	})(jQuery);
    </script>
</body>
</html>
主要言語
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 を短くまとめたダイジェスト。