aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-07 14:06:18 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-07 14:06:18 -0800
commit42ea8b24025960bac6e9079c41ca3d4ad0ed90c8 (patch)
treef2393256a96fd8c727fa99045bdf59bd987a1fbc /src
parenta13e64c28645f0a1dcd36bd986fc57cf2d91ef7e (diff)
downloadbun-42ea8b24025960bac6e9079c41ca3d4ad0ed90c8.tar.gz
bun-42ea8b24025960bac6e9079c41ca3d4ad0ed90c8.tar.zst
bun-42ea8b24025960bac6e9079c41ca3d4ad0ed90c8.zip
[node:events] EventEmitter#on and EventEmitter#off should return the EventEmitter instance
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/webcore/JSEventEmitter.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp
index 8ef858166..ad10687f9 100644
--- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp
+++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp
@@ -237,7 +237,7 @@ static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobal
auto result = JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addListenerForBindings(WTFMove(eventType), WTFMove(listener), once, prepend); }));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
vm.writeBarrier(&static_cast<JSObject&>(*castedThis), argument1.value());
- return result;
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(castedThis));
}
static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_addListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSEventEmitter>::ClassParameter castedThis)
@@ -332,7 +332,7 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_removeListener
auto result = JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.removeListenerForBindings(WTFMove(eventType), WTFMove(listener)); }));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
vm.writeBarrier(&static_cast<JSObject&>(*castedThis), argument1.value());
- return result;
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(castedThis));
}
JSC_DEFINE_HOST_FUNCTION(jsEventEmitterPrototypeFunction_removeListener, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
@@ -573,10 +573,9 @@ JSC_DEFINE_HOST_FUNCTION(Events_functionOnce,
EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2);
auto listener = convert<IDLNullable<IDLEventListener<JSEventListener>>>(*lexicalGlobalObject, argument2.value(), *argument0, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 2, "listener", "EventEmitter", "removeListener"); });
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
- auto result = JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addListenerForBindings(WTFMove(eventType), WTFMove(listener), true, false); }));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
vm.writeBarrier(argument0, argument2.value());
- return result;
+ RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(argument0));
}
JSC_DEFINE_HOST_FUNCTION(Events_functionOn,