SVG fill attributes are not overridden when enable() runs from a deferred script
Mantenedores costumam responder em até 2 dias
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Facilidade para iniciantes
- 88/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- electron, typescript
- Domínio
- frontend
Direção de pesquisa
Leia src/inject/utils/dom.ts, especialmente overrideInlineStyle, addReadyStateCompleteListener e o registro do listener de ready-state. Reproduza com um script adiado e um SVG inline usando fill="#333". Está concluído quando o SVG recebe data-darkreader-inline-fill e é tematizado corretamente quando enable() é executado com readyState interativo.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
I'm using the darkreader npm package in an Electron app. I call DarkReader.enable() from a script that runs while the document is still loading (readyState is "interactive"). Everything gets themed except inline SVG icons that use fill attributes, they stay dark on dark.
I traced it to src/inject/utils/dom.ts. The fill handling in overrideInlineStyle is deferred with addReadyStateCompleteListener because it needs layout to decide between the text and background color heuristics. The problem is that the readystatechange listener that flushes readyStateCompleteListeners is only registered when !isDOMReady(), so it only exists if the module was initialized before readyState reached "interactive". That always holds for the extension since content scripts run at document_start, but a page script using the API typically runs at "interactive", so the listener is never registered and the queued callbacks just sit there forever.
Easy repro: page with an SVG using fill="#333", call DarkReader.enable() from a deferred script. The fill never gets a data-darkreader-inline-fill override. Enable after window load and it works.
The fix is a one liner, register the listener when !isReadyStateComplete() instead. No behavior change for the extension path. Opening a PR with the change.
- Linguagem predominante
- TypeScript
- Estrelas
- 22.6k
- Forks
- 2.8k
- Merge médio
- 1d 17h
- PRs com merge (30d)
- 82
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de darkreader/darkreader
-
Broken Website
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
darkreader/darkreader#16259 ·
Mantenedores costumam responder em até 2 dias
-
Broken Website
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
darkreader/darkreader#16126 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Pay to use?Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 66/100
darkreader/darkreader#16108 · 7 comentários ·
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
darkreader/darkreader#16100 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 2 dias
-
Broken Website
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
darkreader/darkreader#15999 · 5 comentários ·
Mantenedores costumam responder em até 2 dias
Todas as issues de darkreader/darkreader
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
knaw-huc/textannoviz#742 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
cloudflare/realtimekit-ui#219 ·
Mantenedores costumam responder em até 1 dia
-
ui
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaksTalvez já em andamento @argszero assumiu hoje. Abertaarea/tui platform/wsl status/repro-simulated type/bug version/v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
anomalyco/opencode#66773 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
mermaid-js/mermaid-v13#1370 ·
Mantenedores costumam responder em até 1 dia