forms fix

This commit is contained in:
Jorijn van der Graaf 2025-11-10 21:38:38 +01:00
commit 616aadec3b
2 changed files with 8 additions and 5 deletions

View file

@ -319,8 +319,10 @@ function addChangeListener(ptr, handlerID) {
const element = jsmemory.get(ptr);
const handler = function (event) {
const { ExecuteChangeHandler } = window.crafter_webbuild_wasi.instance.exports;
ExecuteChangeHandler(handlerID, event.target.value);
const { ExecuteChangeHandler, WasmFree } = window.crafter_webbuild_wasi.instance.exports;
const ptr = writeStringToWasm(event.target.value);
ExecuteChangeHandler(handlerID, ptr);
WasmFree(ptr);
};
eventHandlers.set(`${ptr}-${handlerID}-change`, handler);
@ -361,8 +363,10 @@ function addInputListener(ptr, handlerID) {
const element = jsmemory.get(ptr);
const handler = function (event) {
const { ExecuteInputHandler } = window.crafter_webbuild_wasi.instance.exports;
ExecuteInputHandler(handlerID, event.data || event.target.value, event.inputType === 'insertCompositionText');
const { ExecuteInputHandler, WasmFree } = window.crafter_webbuild_wasi.instance.exports;
const ptr = writeStringToWasm(event.data || event.target.value);
ExecuteInputHandler(handlerID, ptr, event.inputType === 'insertCompositionText');
WasmFree(ptr);
};
eventHandlers.set(`${ptr}-${handlerID}-input`, handler);

View file

@ -98,7 +98,6 @@ export namespace Crafter::CppDOMBindings {
extern "C" {
__attribute__((export_name("WasmAlloc"))) void* WasmAlloc(std::int32_t size) {
std::cout << std::format("Alloc: {}", size) << std::endl;
return std::malloc(size);
}