aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-10-26 22:41:14 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-10-26 22:41:14 +0200
commitbd38b4839c09f95d01a012471cdddd280ec345f7 (patch)
tree03287b77c1497c37bf821ced5aeae9d060b257ad /core/sys
parent4608d26e6e61731912ef2257f6150d9e43ff2cbf (diff)
sys/wasm/js: add `set_element_style`
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/wasm/js/dom.odin2
-rw-r--r--core/sys/wasm/js/odin.js10
2 files changed, 12 insertions, 0 deletions
diff --git a/core/sys/wasm/js/dom.odin b/core/sys/wasm/js/dom.odin
index ffc58a9a3..902dfc941 100644
--- a/core/sys/wasm/js/dom.odin
+++ b/core/sys/wasm/js/dom.odin
@@ -20,6 +20,8 @@ foreign dom_lib {
device_pixel_ratio :: proc() -> f64 ---
window_set_scroll :: proc(x, y: f64) ---
+
+ set_element_style :: proc(id: string, key: string, value: string) ---
}
get_element_value_string :: proc "contextless" (id: string, buf: []byte) -> string {
diff --git a/core/sys/wasm/js/odin.js b/core/sys/wasm/js/odin.js
index 6f086e595..98b112890 100644
--- a/core/sys/wasm/js/odin.js
+++ b/core/sys/wasm/js/odin.js
@@ -1802,6 +1802,16 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory, ev
}
},
+ set_element_style: (id_ptr, id_len, key_ptr, key_len, value_ptr, value_len) => {
+ let id = wasmMemoryInterface.loadString(id_ptr, id_len);
+ let key = wasmMemoryInterface.loadString(key_ptr, key_len);
+ let value = wasmMemoryInterface.loadString(value_ptr, value_len);
+ let element = getElement(id);
+ if (element) {
+ element.style[key] = value;
+ }
+ },
+
get_element_key_f64: (id_ptr, id_len, key_ptr, key_len) => {
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
let key = wasmMemoryInterface.loadString(key_ptr, key_len);