Questions tagged [javascript-proxy]
36 questions
0
votes
2 answers
Why do set() traps in proxies sometimes trigger a TypeError and sometimes not (both after an invalid write operation)?
tl;dr: I've found that sometimes returning false in a proxy's set() trap doesn't trigger any TypeError, and sometimes it does. Why does this happen?
As far as I understand, set() traps in a proxy must return either true or false to denote whether a…

M2K
- 319
- 3
- 11
0
votes
0 answers
Can I find if there is an initialized variable for a particular div id in an html web page?
0
votes
2 answers
How to create a trap for properties on a constructible JavaScript object
Proxy has a trap for new operator, which in theory should allow us to create Proxies that pass constructor arguments through to the target object. Example of how it works looks like this:
function monster1(disposition) {
this.disposition =…

jayarjo
- 16,124
- 24
- 94
- 138
-1
votes
1 answer
Why is Proxy being called for nested elements?
I'm attempting to abstract some Cypress methods into a helper object using getters.
The intended behavior is that I can do something like this:
todoApp.todoPage.todoApp.main.rows.row
.first().should('have.text', 'Pay electric…

user3534080
- 1,201
- 1
- 14
- 21
-1
votes
2 answers
Want to add show more to every tag using javascript
I used parentElement.appendChild(SpanTag) for every class but the span tag gets added only to the last
tag. var divsToControl = document.getElementsByTagName('p'); var spanTag = document.createElement('span'); spanTag.innerText = "...see…

Sagar Basnet
- 13
- 1
-1
votes
1 answer
Use Proxy on Class while maintaining access to existing properties and class type
In an effort to learn how Proxy works I wanted to try and make a Proxied class that can handle any property name, even those that don't exist in the class, while still maintaining access to old properties. I assumed Typescript would let you do this…

valepu
- 3,136
- 7
- 36
- 67