mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
LibWeb: Use a JS::Handle to keep the EventListener function alive
This commit is contained in:
parent
a119b61782
commit
41f3817b36
5 changed files with 18 additions and 14 deletions
|
@ -0,0 +1,11 @@
|
|||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
JS::Function* EventListener::function()
|
||||
{
|
||||
return m_function.cell();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -12,15 +12,15 @@ class EventListener
|
|||
public:
|
||||
using WrapperType = Bindings::EventListenerWrapper;
|
||||
|
||||
explicit EventListener(JS::Function* function)
|
||||
: m_function(function)
|
||||
explicit EventListener(JS::Handle<JS::Function> function)
|
||||
: m_function(move(function))
|
||||
{
|
||||
}
|
||||
|
||||
JS::Function* function() { return m_function; }
|
||||
JS::Function* function();
|
||||
|
||||
private:
|
||||
JS::Function* m_function { nullptr };
|
||||
JS::Handle<JS::Function> m_function;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue