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

604
Visualizações
What are the ways of intercepting setting of property on an object?

I'm trying to figure out how the setting of a property is being intercepted in jsdom's CSSStyleDeclaration implementation. This is being done for validation purposes. I want to know where this validation is happening. github link

This is the line where the setting is happening. this[lowercaseName] = value;

I'm only aware of one method that can be used to intercept this action. Which is usage of Proxy Object. But the object in question is not a proxy object.

Hence Question: What are the other ways of intercepting(man in the middle) the action of setting properties on an object?

To confirm interception is happening:

const {CSSStyleDeclaration} = require('cssstyle')
const decl = new CSSStyleDeclaration()

decl.setProperty('background-color', 'invalid-value')

decl.getPropertyValue('background-color') // '' returns empty string

decl.setProperty('background-color', '#333')

decl.getPropertyValue('background-color') // '#333'

Use can use this IDE

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

What are the other ways of intercepting(man in the middle) the action of setting properties on an object?

Setters!

The set syntax binds an object property to a function to be called when there is an attempt to set that property.

In your particular example the colour validation is done by a parseColor function called by the background-color setter.

about 4 years ago · Juan Pablo Isaza Relatório
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