Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#342 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
javascript, node.js
Bereich
backend

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
HTML
Sterne
2.1k
Forks
110
Ø Merge
11 T. 1 Std.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus WebReflection/linkedom

Alle Issues in WebReflection/linkedom

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.