Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
How to get CSSStyleDeclaration.backgroundImage set descriptor

I'm trying to override the setters of some style properties in javascript.

Here's an example of what I'm doing.

const setDescriptor = Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype, 'backgroundImage').set;
Object.defineProperty(CSSStyleDeclaration.prototype, 'backgroundImage', {
    set: function (value) {
        const newValue = // Some sort of mutation to value

        setDescriptor.call(this, newValue);
    },
});

When trying to run this inside my browser I'm getting the following error:

Uncaught TypeError: Cannot read properties of undefined (reading 'set')

I know that the interface does not have any reference to styling properties.
However, when accessing an instance of CSSStyleDeclaration from CSSStyleRule.style the properties do exist.

When is that instance populated? How can I override the setters of the properties for all new and old instances?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda