diff options
author | bptato <nincsnevem662@gmail.com> | 2023-07-02 23:41:02 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-07-02 23:41:11 +0200 |
commit | 3c5aa0645bcc1d2481cdb4b03001afd96fd318e0 (patch) | |
tree | f1ba22a1d7d93a6db28e60e56e04602d023e5f41 /src/html | |
parent | 31cca81850bfe43771767dbffc2879a5061b84cd (diff) | |
download | chawan-3c5aa0645bcc1d2481cdb4b03001afd96fd318e0.tar.gz |
Add XHR/Event stubs
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/dom.nim | 6 | ||||
-rw-r--r-- | src/html/env.nim | 6 | ||||
-rw-r--r-- | src/html/event.nim | 15 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 40e627eb..4abd683f 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -12,6 +12,7 @@ import css/sheet import css/values import data/charset import encoding/decoderstream +import html/event import html/tags import img/bitmap import img/painter @@ -127,8 +128,6 @@ type EnvironmentSettings* = object scripting*: bool - EventTarget* = ref object of RootObj - Collection = ref CollectionObj CollectionObj = object of RootObj islive: bool @@ -402,7 +401,6 @@ jsDestructor(HTMLTextAreaElement) jsDestructor(HTMLLabelElement) jsDestructor(HTMLCanvasElement) jsDestructor(HTMLImageElement) -jsDestructor(EventTarget) jsDestructor(Node) jsDestructor(NodeList) jsDestructor(HTMLCollection) @@ -3043,7 +3041,7 @@ proc registerElements(ctx: JSContext, nodeCID: JSClassID) = register(HTMLImageElement, TAG_IMG) proc addDOMModule*(ctx: JSContext) = - let eventTargetCID = ctx.registerType(EventTarget) + let eventTargetCID = ctx.getClass("EventTarget") let nodeCID = ctx.registerType(Node, parent = eventTargetCID) ctx.registerType(NodeList) ctx.registerType(HTMLCollection) diff --git a/src/html/env.nim b/src/html/env.nim index 174f0a12..06289c4e 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -2,6 +2,7 @@ import selectors import streams import html/dom +import html/event import html/htmlparser import io/headers import io/loader @@ -15,7 +16,8 @@ import js/javascript import js/timeout import types/blob import types/url -import xhr/formdata as formdata_impl +import xhr/formdata +import xhr/xmlhttprequest # NavigatorID proc appCodeName(navigator: Navigator): string {.jsfget.} = "Mozilla" @@ -118,12 +120,14 @@ proc addScripting*(window: Window, selector: Selector[int]) = ctx.addDOMExceptionModule() ctx.addconsoleModule() ctx.addNavigatorModule() + ctx.addEventModule() ctx.addDOMModule() ctx.addURLModule() ctx.addHTMLModule() ctx.addIntlModule() ctx.addBlobModule() ctx.addFormDataModule() + ctx.addXMLHttpRequestModule() ctx.addHeadersModule() ctx.addRequestModule() ctx.addResponseModule() diff --git a/src/html/event.nim b/src/html/event.nim new file mode 100644 index 00000000..d4b6b691 --- /dev/null +++ b/src/html/event.nim @@ -0,0 +1,15 @@ +import js/javascript + +type + Event* = ref object + + EventTarget* = ref object of RootObj + + EventHandler* = proc(event: Event): JSValue + +jsDestructor(Event) +jsDestructor(EventTarget) + +proc addEventModule*(ctx: JSContext) = + ctx.registerType(Event) + ctx.registerType(EventTarget) |