Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

611
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!