aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/napi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings/napi.cpp')
-rw-r--r--src/bun.js/bindings/napi.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp
index ecae69427..bebdd5134 100644
--- a/src/bun.js/bindings/napi.cpp
+++ b/src/bun.js/bindings/napi.cpp
@@ -1185,9 +1185,20 @@ static JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction,
RETURN_IF_EXCEPTION(scope, {});
+ size_t count = callFrame->argumentCount();
+ MarkedArgumentBuffer args;
+
+ if (count > 6) {
+ for (size_t i = 6; i < count; i++) {
+ args.append(callFrame->uncheckedArgument(i));
+ }
+ }
+
callFrame->setThisValue(prototype->subclass(newTarget));
napi->constructor()(globalObject, callFrame);
- size_t count = callFrame->argumentCount();
+ RETURN_IF_EXCEPTION(scope, {});
+
+ JSC::JSValue thisValue = callFrame->thisValue();
switch (count) {
case 0: {
@@ -1230,15 +1241,11 @@ static JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction,
JSC::ensureStillAliveHere(callFrame->argument(3));
JSC::ensureStillAliveHere(callFrame->argument(4));
JSC::ensureStillAliveHere(callFrame->argument(5));
- for (int i = 6; i < count; i++) {
- JSC::ensureStillAliveHere(callFrame->argument(i));
- }
break;
}
}
- RETURN_IF_EXCEPTION(scope, {});
- RELEASE_AND_RETURN(scope, JSValue::encode(callFrame->thisValue()));
+ RELEASE_AND_RETURN(scope, JSValue::encode(thisValue));
}
NapiClass* NapiClass::create(VM& vm, Zig::GlobalObject* globalObject, const char* utf8name,