You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSC napi shim: writing to constructor.prototype pollutes global Object.prototype #172
On the JSC backend, constructors returned by napi_define_class / Napi::Function::New(...) have their user-visible .prototype slot pointing at the global Object.prototype instead of a fresh per-class object. Writing to it from C++ via func.Get("prototype").Set(...) therefore mutates Object.prototype globally, breaking for..in and prototype-chain lookups across the runtime.
V8 and ChakraCore return a fresh per-class object, so the bug is JSC-specific.
In JS: 'X' in {} → true (should be false), and for (const k in {}) ... enumerates X.
Root cause
JSC's JSObjectMakeConstructor defaults the new function's .prototype to Object.prototype when none is supplied. The napi-jsc shim should allocate a fresh object per class.
Workaround
Use InstanceValue / InstanceMethod / InstanceAccessor inside DefineClass. That path goes through napi's internal prototype slot, distinct from the user-visible .prototype on JSC, and works correctly on every backend.
Activity
Fix .prototype pollution on JSC by passing JSClass to JSObjectMakeCon…
File polyfill: drop JS_PROTOTYPE_CHAIN_SHIM workaround now that Babyl…
File polyfill: drop JS_PROTOTYPE_CHAIN_SHIM workaround now that Babyl…