Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

getAttribute("class") trims the value and returns "" when absent

Đang mở
#342 0 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
backend

Hướng nghiên cứu

Start by tracing getAttribute("class") and class selector matching in linkedom, then run the reproduction with the supplied HTML and compare the results with the stated browser expectations. Done means the class value preserves its leading space, a missing class returns null, and [class^=" a"] matches the element.

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

Mô tả

issue:
getAttribute("class") should return the attribute exactly as written. linkedom strips the whitespace (" ab" → "ab") and returns "" instead of null when there is no class. Selectors see the stripped value too, so [class^=" a"] misses.

repro:

import { parseHTML } from "linkedom";
const { document } = parseHTML('<html><body><i class=" ab"></i><b></b></body></html>');
const [i, b] = document.body.children;
console.log(JSON.stringify(i.getAttribute("class")));           // "ab"
console.log(JSON.stringify(b.getAttribute("class")));           // ""
console.log(document.querySelectorAll('[class^=" a"]').length); // 0

expected:
" ab", null, 1 (as Chrome, Firefox, Safari)

system:
linkedom 0.18.13, Node 25.8.1
macOS 27.0, arm64

Ngôn ngữ chính
HTML
Star
2.1k
Fork
110
Merge trung bình
11 ngày 1 giờ
Pull request đã merge (30 ngày)
1

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 WebReflection/linkedom

Tất cả issue của WebReflection/linkedom

Issue tương tự

Thêm issue về Backend & API Design

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.