ajvincent / es-membrane

An ECMAScript implementation of a Membrane, allowing users to dynamically hide, override, or extend objects in JavaScript with controlled effects on the original objects.
111 stars 13 forks source link

Gracefully handle disabled traps in the membrane #101

Open ajvincent opened 7 years ago

ajvincent commented 7 years ago

While working on documentation for the es7-membrane GUI, I realized the first trap, getPrototypeOf, is dangerous to disable. When disabled, an es7-membrane proxy trap simply throws when invoked. That's very bad for getPrototypeOf: it would be better to simply return null in that case.

Some traps, like .setPrototypeOf() and .defineProperty(), are safe to throw when disabled. Others need careful consideration.

ajvincent commented 7 years ago

Another factor: .get() relies on both .getOwnPropertyDescriptor() and .getPrototypeOf(), so if .getOwnPropertyDescriptor() is disabled but .get() isn't, .get() should probably still work...

ajvincent commented 7 years ago

Side note: need to check that Reflect.anyMethod(proxy) doesn't pass through extra arguments.

ajvincent commented 6 years ago

Pushing out of 0.9 milestone: I think this is something that only experience with membranes can really define.