Does Object.watch exist for all properties / padding for __noSuchMethod__?

I would like to extend localStorage by executing some code every time a parameter is selected / saved. I could define getter / setter for all existing localStorage properties, but the problem is with the new settings.

For example, localStorage['somenewsetting'] = 123 creates a new parameter. I would like to automatically determine getter / setter for this property so that my add-on code is also executed for new settings.

Basically, I need Object.watch , but for all properties. I found __noSuchMethod__ , but it is not available in Chrome. Is there any gasket for this method? Or is there another way to view all the properties of an object?

Again, I need to make this work in Chrome.

+1
source share
2 answers

No, at least not for Chrome. __noSuchMethod__ only works for functions.

Proxy supported for discussing the next version of ECMAScript (Harmony) and is even already implemented in SpiderMonkey . Until then, you're out of luck, I'm afraid.

- there was a request for the introduction of __noSuchMethod__ in V8 , but it was refused. Requests for the introduction of a proxy server were not more successful: 633 was merged as a duplicate , and the Chromium team does not care about proxy server support .

+2
source

Yes, I want this too. So do many, many other people. Will not happen. Ever. Chrome (V8) follows webkit in terms of the JS API. __noSuchMethod__ is a custom event created by Mozilla and officially rejected from ECMAScript (JavaScript).

In other words, it will never exist: '(

(or, if this happens, it will be after much debate, and soon it will not)

+2
source

All Articles