Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

JSDOMParser: Element is missing a lang accessor

Aperta Adatta ai principianti
#1,026 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@josuesto ci sta già lavorando.

Dal 8/10/2026.

  • #1028 di @afonsojanu — chiusa senza merge
  • #1035 di @josuesto — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
web-dev

Direzione di ricerca

Individua gli accessor degli attributi di Element di JSDOMParser ed esamina le implementazioni circostanti. Aggiungi il comportamento della proprietà lang mostrato nell’issue, quindi verifica che documentElement.lang rifletta l’attributo lang e che assegnarle un valore aggiorni l’attributo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

JSDOMParser's Element reflects several HTML attributes as properties such as className, id, href, src, srcset, but not lang. Code that reads doc.documentElement.lang gets undefined on a JSDOMParser document, and the language tag on a real DOM document.

Readability itself is not broken by this. It reads the value with getAttribute("lang") (Readability.js:1071) and exposes it as lang on the parse result. The problem hits consumers that take a document back from JSDOMParser and read the DOM property.

Firefox for Android's Reader View hit exactly this. It caches a parsed document, reloads it through JSDOMParser, and read doc.documentElement.lang, which gave no language on the cached path. We worked around it with getAttribute, but the accessor is worth having so the parser matches the DOM.

See also: Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=2062976

Suggested fix

Add the accessor next to the others:

  get lang() {                                                                                                                                                                        
    return this.getAttribute("lang") || "";                                                                                                                                           
  },                                                                                                                                                                                  
                                                                                                                                                                                      
  set lang(str) {                                                                                                                                                                     
    this.setAttribute("lang", str);                                                                                                                                                   
  },
Lingua principale
JavaScript
Stelle
11.5k
Fork
737
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mozilla/readability

Tutte le issue di mozilla/readability

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.