From 8f24a94bd7158c9d8293d76aa9e1ed83337a9ff9 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sat, 27 Mar 2021 14:18:27 -0700 Subject: [PATCH] fix jsformdata (and also to trigger doc rebuilt after https://github.com/nim-lang/Nim/pull/16999) --- src/fusion/js/jsformdata.nim | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/fusion/js/jsformdata.nim b/src/fusion/js/jsformdata.nim index e5158798..28ae7eea 100644 --- a/src/fusion/js/jsformdata.nim +++ b/src/fusion/js/jsformdata.nim @@ -2,6 +2,15 @@ when not defined(js): {.fatal: "Module jsformdata is designed to be used with the JavaScript backend.".} +runnableExamples("-r:off"): + let data: FormData = newFormData() + data["key0"] = "value0".cstring + data.add("key1".cstring, "value1".cstring) + data.delete("key1") + doAssert data.hasKey("key0") + doAssert data["key0"] == "value0".cstring + data.clear() + type FormData* = ref object of JsRoot ## FormData API. func newFormData*(): FormData {.importjs: "new FormData()".} @@ -45,14 +54,3 @@ func `[]`*(this: FormData; name: cstring): cstring {.importjs: "#.get(#)".} func clear*(this: FormData) {.importjs: "(() => { const frmdt = #; Array.from(frmdt.keys()).forEach((key) => frmdt.delete(key)) })()".} ## Convenience func to delete all items from `FormData`. - - -runnableExamples: - if defined(fusionJsFormdataTests): - let data: FormData = newFormData() - data["key0"] = "value0".cstring - data.add("key1".cstring, "value1".cstring) - data.delete("key1") - doAssert data.hasKey("key0") - doAssert data["key0"] == "value0".cstring - data.clear()