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

Đang mở
#1,156 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, jquery
Lĩnh vực
documentation

Hướng nghiên cứu

Xem lại trang tài liệu API jquery tại https://api.jquery.com/jquery/ và so sánh nhận định của trang về việc đặt "class" trong dấu ngoặc kép với ví dụ JavaScript được cung cấp và kết quả theo phiên bản trình duyệt. Kiểm tra xem hướng dẫn này còn chính xác đối với các phiên bản liên quan hay không, sau đó cập nhật tài liệu để nêu rõ các trường hợp áp dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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>
Ngôn ngữ chính
HTML
Star
324
Fork
259
Merge trung bình
1 ngày 30 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của jquery/api.jquery.com

Tất cả issue của jquery/api.jquery.com

Issue tương tự

Thêm issue về Documentation

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.