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

Is it possible not to push unnecessary state when clicking an <a> element?

Aperta
#2,531 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@KashviYadav09 ci sta già lavorando.

Dal 19/1/2026.

  • #2668 di @KashviYadav09 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
frontend, web-dev

Direzione di ricerca

Inizia individuando il codice sorgente JavaScript che contiene e.prototype.onchange e leggi la gestione di click e popstate. Riproduci i casi di anchor/history descritti nell’issue, quindi verifica che la navigazione verso la stessa posizione non faccia nulla e che la navigazione verso l’URL precedente della cronologia si comporti come proposto.

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

Descrizione

needs discussion

Feature request

Problem or desire

I click an element which has the href just like the location.href when setting routerMode to "history", and then it pushes a new state which is not necessary.
It might be better to use history.back() than history.pushState() when clicking an element which has the href just like the location.href of the previous page in session history.

Proposal

Do nothing when clicking an element which has the href just like the location.href.
Use history.back() when clicking an element which has the href just like the location.href of the previous page in session history.

Implementation

Just change the onchange function to something like this:

e.prototype.onchange = function (i) {
        void 0 === i &&
        (i = d),
        p(
          'click',
          function (e) {
            var n = 'A' === e.target.tagName ? e.target : e.target.parentNode;
            n &&
            'A' === n.tagName &&
            !g(n.href) &&
            (
              e.preventDefault(),
              n = n.href,
              n === location.href ? 1 :      //Add
              n === hrefPre ? window.history.back() :      //Add(hrefPre is used to record the href before)
              window.history.pushState({
                key: n
              }, '', n),
              i({
                event: e,
                source: 'navigate'
              })
            )
          }
        ),
        p('popstate', function (e) {
          i({
            event: e,
            source: 'history'
          })
        })
      }
Lingua principale
JavaScript
Stelle
31.5k
Fork
5.8k
Merge medio
2g 14h
PR unite (30g)
5

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 docsifyjs/docsify

Tutte le issue di docsifyjs/docsify

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.