Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

616
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda