SVG fill attributes are not overridden when enable() runs from a deferred script

Aberta Para iniciantes
#15,570 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

@KamilDev já está trabalhando nisso.

Desde 10/6/2026.

  • #15571 de @KamilDev — aberto

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

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de darkreader/darkreader

Todas as issues de darkreader/darkreader

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.